Re: Double method access (Hi everyone! :))

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I also totally agree with Larry that if used judiciously then method/object
chaining can give great results, else otherwise, can create a lot of
overhead in the application.


Netemp

On Sat, Mar 5, 2011 at 1:14 AM, Paola Alvarez <paola.alvarez85@xxxxxxxxx>wrote:

> Hi, thanks a lot Alex and Larry for your very clear answer!
>
> Paola,
>
> On Fri, Mar 4, 2011 at 4:33 PM, larry@xxxxxxxxxxxxxxxx <
> larry@xxxxxxxxxxxxxxxx> wrote:
>
> > That's called method chaining.  ->getColumns() will get called on the
> > object returned by ->getTable().  That is, getTable() returns an object
> > (presumably representing an SQL table, I guess), and that object has a
> > getColumns() method, which you call.
> >
> > This is an extremely common style in Javascript code that has been
> gaining
> > widespread use in PHP OO circles in recent years.  If leveraged properly
> it
> > can create very compact, very readable, very powerful code.  (And if done
> > stupidly can lead to a horrid mess, but that's true of any coding style.)
> >
> > --Larry Garfield
> >
> >
> > On 3/4/11 1:25 PM, Paola Alvarez wrote:
> >
> >> Hi there!,
> >> I have been reading this list before but this is my first post.
> >> Reading some code from Symfony I got this:
> $this->getTable()->getColumns()
> >> ...when you can use this double method access?, I used before the
> >> regular $this->getTable(), but two?. I mean I have been trying but I got
> >> an
> >> error*
> >>
> >> * Fatal error: Call to a member function ... on a non-object in ...
> >>
> >> Thanks!
> >>
> >> Paola
> >>
> >> PS: BTW, sorry my english isnt really good
> >>
> >>
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux