2009年3月13日星期五

Re: [fw-db] Zend_Db_Select, WHERE clause API

Marc Dassonneville wrote:
> 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
>
>
+1

Your recommendation seems right to me.


--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, Personal: http://sudheer.net

没有评论: