2010年1月14日星期四

Re: [fw-mvc] Example of a Multi Condition Delete with Zend framework

By default, if you pass in an array of WHERE conditions, Zend_Db assumes you're using AND. But you can also pass in a complete WHERE condition with OR:

With Zend_Db:

$db->delete($table, "id = 1 OR parentid = 1");

With Zend_Db_Table:

$table->delete("id = 1 OR parentid = 1");

But don't forget to quote the parameters:

$db = $table->getAdapter();
$table->delete("id = {$db->quote($id)} OR parentid = {$db->quote($id)}");

--
Hector


On Thu, Jan 14, 2010 at 10:26 PM, Erdal YAZICIOGLU <erdal.yazicioglu@gmail.com> wrote:

Can somebody give me example of writing multi condition delete with ZF 1.9. Especially with OR.

Delete from table where id=1 or parentid =1

Thanks


没有评论: