Re: Execution order of PHP

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

 



2010/3/10 Andrew Ballard <aballard@xxxxxxxxx>:
> On Wed, Mar 10, 2010 at 9:54 AM, Bruno Fajardo <bsfajardo@xxxxxxxxx> wrote:
> [snip]
>> 2010/3/10 Auke van Slooten <auke@xxxxxxx>:
>>> This is not what I meant. I should perhaps mention that it's an xml-rpc
>>> client and the method calls are remote method calls. The multiCall method
>>> gathers multiple method calls into a single request.
>>>
>>> The trick I'm using now is to set a private property in the $client->__get()
>>> method when the property you're accessing is 'system'. From then untill you
>>> call the method 'multiCall', instead of calling the methods (in this case
>>> methodOne and methodTwo) the client creates a new object with the call
>>> information (method name and arguments) and returns that. In multiCall all
>>> arguments are therefor call information objects and multicall creates a
>>> single request based on that information.
>>
>> Hmm, you cleared that to me now... If you need to first create the
>> property "system" and then call a method in that object "system",
>> can't you do something like:
>>
>> $client->system = null;
>> $client->system->multiCall(
>>    $client->methodOne(),
>>    $client->methodTwo()
>> );
>>
>> I'm not testing these snippets of code, so sorry if I'm getting something wrong.
>>
>> Cheers,
>> Bruno.
>>
> [snip]
>
> I'm not sure you would want to assign null to $client->system. After
> all, __set() might not be defined.

Yes, you're right, Andrew. Setting the property to null is not the
best choice in this case.

>
> I agree with Rob here. If order is really crucial, then call the
> statements in the correct order:
>
> <?php
>
> /**
>  * causes $client to call __get() in order to resolve
>  * 'system'
>  */
> $system = $client->system;
>

This was my point too, to create the object before the call to
multiCall(), I just messed my example with the null assignment... :-)
The code you suggested must solve the OP issue.

Cheers,
Bruno.

>
> /**
>  * You should add some handling here to make sure that
>  * $system is really an object that implements your
>  * multiCall() method, and not something else (like null).
>  */
>
>
> $system->multiCall(
>    $client->methodOne(),
>    $client->methodTwo()
> );
>
> ?>
>
>
>
> Andrew
>

-- 
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