0
我有一張臨時表。稱它爲table1
。我想將table1
中的每一行復制到table2
。我相信SELECT INTO
可以在mysql中做到這一點。MYSQL'SELECT INTO'在cakephp中的等價物
現在我想知道如何用cakephp2.4來完成這個任務。
我有一張臨時表。稱它爲table1
。我想將table1
中的每一行復制到table2
。我相信SELECT INTO
可以在mysql中做到這一點。MYSQL'SELECT INTO'在cakephp中的等價物
現在我想知道如何用cakephp2.4來完成這個任務。
$this->loadModel('Table1');
$find_new=$this->Table1->find('all');
$this->set('find_new', $find_new);
foreach($find_new as $find_new):
$this->Tabel2->create();
$this->request->data['Table2']['field1']=$find_new['Table1']['field1'];
$this->request->data['Table2']['field2']=$find_new['Table1']['field2'];
$this->request->data['Table2']['field3']=$find_new['Table1']['field3'];
$this->Table2->save($this->request->data);
endforeach;
return $this->redirect($this->referer());
請分享您已經嘗試的代碼。 – MarkyPython
如果需要,可以在CakePHP中使用原始SQL。 – rrd