为“选择”表执行查询,并使用where子句“插入”到另一个表


Zend query for "select a table and insert into another with where clause"?

这个查询是在MySql Workbench上运行的,现在我需要它在Zend。

INSERT new_table SELECT * from old_table WHERE date(created_time) < 2015-04-05;

您需要做的就是使用适配器的query方法。

// $db is your DB adapter, e.g. an instance of Zend_Db_Adapter_Mysqli
$db->query('INSERT new_table SELECT * from old_table WHERE date(created_time) < 2015-04-05');