[PHP] OO in PHP5.0 - Referencing Object or not?!

2004-08-22 Thread Raffael Wannenmacher
hello together
look at the following code ...
why is this ..
-- code start
   if ( is_object($this-getManagerObject()-getDataFieldManager()) )
   {
   for ( $j = 0; $j  
$this-getManagerObject()-getDataFieldManager()-getCount(); $j++ )
   {
   if ( 
$this-getManagerObject()-getDataFieldManager()-m_objData[$j]['GI_ID'] 
== $this-getID() )
   {
   $l_objDataField = new GalleryDataField(
   $this-getManagerObject()-getDataFieldManager(),
   
$this-getManagerObject()-getDataFieldManager()-m_objData[$j]
   );

   $l_objDataField-generateXML();
   $l_strData .= $l_objDataField-getXML();
   unset($l_objDataField);
   }
   }
   }
-- code end
.. about 2 seconds slower than this ..
-- code start
   $l_objDataFieldManager = 
$this-getManagerObject()-getDataFieldManager();

   if ( is_object( $l_objDataFieldManager ) )
   {
   for ( $j = 0; $j  $l_objDataFieldManager-getCount(); $j++ )
   {
   if ( $l_objDataFieldManager-m_objData[$j]['GI_ID'] == 
$this-getID() )
   {
   $l_objDataField = new GalleryDataField(
   $l_objDataFieldManager,
   $l_objDataFieldManager-m_objData[$j]
   );

   $l_objDataField-generateXML();
   $l_strData .= $l_objDataField-getXML();
   unset($l_objDataField);
   }
   }
   }
   unset($l_objDataFieldManager);
-- code end
???
i just read, that objects in php 5 automatically returned as reference? 
in my code it doesn't seems like that!!

ps: variable m_objData contains a lot of data from a mysql db
thanks for answers.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] OO in PHP5.0 - Referencing Object or not?!

2004-08-22 Thread Curt Zirzow
* Thus wrote Raffael Wannenmacher:
 hello together
 
 look at the following code ...
 
 why is this ..
 
 -- code start
if ( is_object($this-getManagerObject()-getDataFieldManager()) )
{
for ( $j = 0; $j  
 $this-getManagerObject()-getDataFieldManager()-getCount(); $j++ )
 ...

 -- code end
 
 .. about 2 seconds slower than this ..
 
 -- code start
$l_objDataFieldManager = 
 $this-getManagerObject()-getDataFieldManager();
 
if ( is_object( $l_objDataFieldManager ) )
{
for ( $j = 0; $j  $l_objDataFieldManager-getCount(); $j++ )
{
if ( $l_objDataFieldManager-m_objData[$j]['GI_ID'] == 
 $this-getID() )
...

This would be expected since each time through the loop, because
the first one has to call a method returning an object of which its
method is called returning another object of another method is then
called upon each time the loop iteration occurs, vs. the latter
where one method is called.

...
 -- code end
 
 ???
 
 i just read, that objects in php 5 automatically returned as reference? 
 in my code it doesn't seems like that!!

The code execution time, in your case, has nothing to do with how
the objects are being returned. You are calling several method()
calls to access one object within a loop, you're second way of
accessing the object is the more sensible way to approach this.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php