EllisLab text mark
Advanced Search
     
DataMapper ORM - How to INSERT INTO from SELECT
Posted: 31 October 2012 04:49 PM   [ Ignore ]
Joined: 2012-09-05
2 posts

Hello,
Can somebody provide some guidance on hot to execute a query like shown here:

INSERT INTO tableA (A,B,C,D,E,F)
SELECT A,B,C,D,E
FROM tableB
WHERE a 
'Y' AND DATE) = DATE(DATE(now( )) + CAST(AS SIGNED)) 

I found some examples but they mention that I need to first to create a container Array, then a db->select, push query results into container array and then a db->insert, as shown below.
However that seems counterproductive or time consuming, and adds complexity to the code (at lest from my pint of view)

...
$insert =   array();
$this->db->select("")->from('');
$this->db->where(array('A' => 'Y'DATE'B' ) => DATE(DATE(now( )) + CAST('C' AS SIGNED))));         
$resultset $this->db->get()->result_array();

foreach(
$resultset as $result){
  array_push
($insert, array(
    
''     =>  $reminder[''],
    
''       =>  $reminder[''],
    
''         =>  $reminder[''],
    ...
  ));
}

$this
->db->insert(''$insert);
... 

Hope I’m not miss-understanding here