Is there any way to write a insert query and update query in same function for different tables in codeigniter.
Mean to say i want to update a table and in same query i want to insert a response time in other table please show me way.
Advance thanks
Is there any way to write a insert query and update query in same function for different tables in codeigniter.
Mean to say i want to update a table and in same query i want to insert a response time in other table please show me way.
Advance thanks
これを行うことができます:
更新クエリを実行する前に時間を記録します。それは言うtime1。
次に、クエリを実行した後の時間の差を見つけて、current system time - time1目的のテーブルに挿入します。
編集
サンプルコードの追加:
<?php
$time_start = microtime(true);
//Your query goes here
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Execution time taken $time seconds\n";
?>
これを試して:
$start_time = microtime(true);
$this->db->insert('tablename1',$data);
$end_time = microtime(true);
$response_time = $time_end - $time_start;
$arrdata=array();
$arrdata['response_time']=$response_time;
$this->db->where('id', $id);//if u have any id
$this->db->update('tablename2',$arrdata);
私の知る限り、1 つのクエリで複数のテーブルを更新することはできません。2 番目のクエリを実行し、MySQL 関数 'NOW()' を使用して現在の時刻をフィールドに挿入できます。
INSERT INTO table (id、data、posted) VALUES(0, '12345', NOW());
public function insertUpdate() {
$data = array(
'tableindex'=>'datayouwanttoinsert',
);
$data1 = array(
'tableindex'=>'datayouwanttoupdate',
);
$this->db->insert('databasename.dbo.tablename',$data);
$this->db->update('databasename.dbo.tablename',$data1);
}
私はそれが役立つことを願っています