2008年12月10日星期三

Re: [fw-db] nesting conditions

On Wed, Dec 10, 2008 at 6:56 PM, ViktorG <info@intelligibel.de> wrote:
>
> Hi,
>
> I would like to do something like:
>
> SELECT * FROM tbl WHERE (x = 1 OR x = 2) AND (y = 1 OR y = 2);
>
> Is this possible by using the Zend DB Table Object?

I think the shortcuts (e.g. find()), just work across the primary key.
Though there is support for compound primary keys, I'm not sure if
that is the case in your example.

However, what you could do is this:

$table = new table(); // class table extends Zend_Db_Table_Abstract
$select = $table->select()->where('x IN (1,2)')->where('y IN (1,2)');
$set = $table->fetchAll($select);

Till

没有评论: