-1

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

4

4 に答える 4

2

これを行うことができます:
更新クエリを実行する前に時間を記録します。それは言う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";
?>
于 2013-03-08T06:34:21.237 に答える
0

これを試して:

$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);
于 2013-03-08T07:35:09.523 に答える
0

私の知る限り、1 つのクエリで複数のテーブルを更新することはできません。2 番目のクエリを実行し、MySQL 関数 'NOW()' を使用して現在の時刻をフィールドに挿入できます。

INSERT INTO table (id、data、posted) VALUES(0, '12345', NOW());

于 2013-03-08T07:01:34.563 に答える
0
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);

}

私はそれが役立つことを願っています

于 2013-03-08T06:59:33.057 に答える