![]() |
question about method chaining - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: question about method chaining (/showthread.php?tid=2999) |
question about method chaining - El Forum - 09-04-2007 [eluser]杨帅[/eluser] i got a "syntax error, unexpected T_OBJECT_OPERATOR" error, and i searched the forum, now i know it's because the php4 not allow method chaining. i shouldn't use the syntax such as Code: $this->db->orderby() instead of the upper one ,i should use Code: $db=$this->db; Code: if ($this->CI->db->cachedir == '') question about method chaining - El Forum - 09-04-2007 [eluser]coolfactor[/eluser] Code: $this->db->orderby() Method chaining (PHP5 only) is a very convenient shortcut which lets you access multiple methods on the same object in a single line of code: Code: $this->db->where('something')->orderby('something')->limit(5); where(), orderby(), and limit() are all methods of $this->db (an instance of the Database class). The CodeIgniter code you posted is not method chaining. It's just accessing a single property or method on objects attached to other objects. question about method chaining - El Forum - 09-04-2007 [eluser]杨帅[/eluser] thank you coolfactor, you are really cool! |