Daniel Schierbeck wrote:

Raffael Wannenmacher wrote:

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.

As you can read in some of the posts here, it only SEEMS like the objects are passed by reference (it's a conspiracy!). I'm not sure if it'll help you, but try using the ampersand (&) symbol to force passing-by-reference.



Cheers, Daniel

if i put de ampersand ( & ) everywhere, where it should pass as reference, the script runs as longer as without ampersand.. its really confusing !!!

...

"In PHP 5, the infrastructure of the object model was rewritten to work with object handles. Unless you explicitly clone an object by using the clone keyword you will never create behind the scene duplicates of your objects. In PHP 5, there is neither a need to pass objects by reference nor assigning them by reference.

Note: Passing by reference and assigning by reference is still supported, in case you want to actually change a variable’s content (whether object or other type)."
-> source: http://www.zend.com/php5/andi-book-excerpt.php


"Be warned, though—normal variables (i.e. those which aren’t objects) are still copied (from my experiments with the beta), so if you need to pass one by reference you still need to use the & reference operator."
-> source: http://www.sitepoint.com/print/1192


do u have a url to a document where this attitude/behavior is explained for real, in detail?!

thenks!

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



Reply via email to