2009年3月13日星期五

[fw-db] Zend_Db_Select, WHERE clause API

Hello,

Handling priority of WHERE clause statements with the current API can be
disgraceful.
What if an easier method was to use the Reverse Polish Notation to handle it
:

// a > min and a < max
->where('a > ?', $min)
->where('a < ?', $max)
->and()

// a = 42 or (a > min and a < max)
->where('a > ?', $min)
->where('a < ?', $max)
->and()
->where('a = ?', 42)
->or()

// it can also be written :
->where('a = ?', 42)
->where('a > ?', $min)
->where('a < ?', $max)
->and()
->or()

RPN is an "elegant" way of managing priority in general, and easy to
implement with a stack.

Marc Dassonneville

--
View this message in context: http://www.nabble.com/Zend_Db_Select%2C-WHERE-clause-API-tp22498322p22498322.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: