For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > February 2006 > Re: [PEAR] DB_DataObject and the set*(), get*() functions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] DB_DataObject and the set*(), get*() functions
Justin Patrin

2006-02-27, 9:57 pm

On 2/27/06, Chris Boget <chris.boget@wild.net> wrote:
> How is it that these function are working as they do? They aren't define=

d
> in either the child or parent classes. In reading the docs, I think I
> understand correctly that it is being handled by some overloading mechani=

sm
> (how, exactly?) utilizing the _call() method (is that right?). But in
> looking at the DB_DataObject's parent class (DB_DataObject_Overload, I th=

ink
> it is? I can't remember off the top of my head), it looks like that clas=

s
> is defining the _call() method but it also looks to be calling itself (ie=

,
> this->_call()) in processing the data. Am I reading that wrong?
>
> In any case, if someone could explain exactly how the set*() and get*()
> methods are working when not defined, I would be very appreciative!
>


This is implemented through PHP's overloading feature and is handled
through the __call method.

If you're using PHP4 stop now and turn off overloading:
define('DB_DATAOBJECT_NO_OVERLOAD', 1);
overloading in PHP4 is broken (it breaks implicit pass-by-reference in
method calls).

And no, it's not calling itself. Note the extra underscore (_). __call
is the method PHP calls. _call is an internal method on the DB_DO
class which does the real work.

--
Justin Patrin
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com