Details
-
Type:
Improvement
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: 0.8.0
-
Component/s: Zend_Db_Select
-
Labels:None
Description
It seems to me that where() and orWhere() in the Zend_Db_Select class are not enough to be able to write all queries. It does not support the nesting of conditions, which doesn't enforce the user with abstraction in somewhat more complex cases. With where() and orWhere() I cannot write this:
select * from mytable where a=3 and (a=b or (a=c and a=d))
A syntax like the following could be a solution:
$select->where($select->and('a=3', $select->or('a=b', $select->and('a=c', 'a=d'))));
(or)
$select->where(
$select->and(
'a=3',
$select->or(
'a=b',
$select->and('a=c', 'a=d')
)
)
);
So I don't really have an elegant solution, but the current situation really is insufficient if you ask me. Also, looking at the current implementation of Zend_Db_Select, it seems like you hardly use the adapter in __toString(), but I guess you're well aware of this and it will improve in the future (Oracle, unlike MySQL for example, uses "
" for certain join syntax).
You might find this interesting by the way: http://troels.arvin.dk/db/rdbms/
Bill: sounds reasonable, thanks.
added multiline solution example