This is a matter of taste more than anything else. To my knowledge, neither example is more performant than another.
Think of it like this, you are either calling a method on the object in the global scope ($select->...), or you are calling a method on the object returned from the previous method call (we know this b/c method in the class at hand return $this). This is called a ³fluent interface² btw if you want to do some additional reading on the subject. More often than not, this is an aspect of setter/mutator methods, but in the case of Zend_Db_Select, the fluent interface is a "Feature" of this component. -ralph On 1/5/09 3:47 AM, "Robert Castley" <[email protected]> wrote: > Hi, > > Out of the two following examples which is the most efficient code i.e. which > offers the best performance? > > Example 1: > > $sql = $this->select() > ->from($this->_name) > ->order('timestamp', 'DESC'); > > > > Example 2: > > $sql = $this->select(); > $sql->from($this->_name); > $sql->order('timestamp', 'DESC'); > > > > Cheers, > > > > - Robert > > ________________________________________________________________________ > This email has been scanned for all known viruses by the MessageLabs Email > Security Service and the Macro 4 plc internal virus protection system. > ________________________________________________________________________ > -- Ralph Schindler Software Engineer | [email protected] Zend Framework | http://framework.zend.com/
