2017-09-07 12 views
0

私は一時テーブルを持っています。それをtable1と呼んでください。 table1の各行をtable2にコピーしたいと思います。私はSELECT INTOがそれをmysqlで行うことができると信じています。cakephpのMYSQL 'SELECT INTO'と等価です

今私はcakephp2.4でこれをどのように達成できるのだろうかと思っています。

+1

既にお試しいただいたコードをお知らせください。 – MarkyPython

+0

必要な場合は、CakePHPでraw SQLを使用できます。 – rrd

答えて

0
$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());