Also, for the record: Referring to the objects in the array directly
works fine. So, syntax like
$secs[$sid] = new CustomSecurity();
$secs[$sid]->load($sid);
is fine, as I would expect. Don't have to define it to a simple
variable like $obj in the code below. Further, if I then do
$sec = $secs[$sid];
in the loop $sec refers correctly to object instances without the need
to unset it.
Thanks again.
Dave
David Moylan wrote:
Solved this. I tried setting a class variable directly and didn't have
the same issue (should have tried that long ago). So that told me that
my error was somewhere in some lower level code when I initialize my
objects. I tracked it down to a problem where I wasn't cloning properly
when I needed to (since PHP4 passes by value, and 5 by reference).
Sorry for the bandwidth and thanks for the help.
Dave
Robert Cummings wrote:
On Thu, 2008-05-29 at 14:01 -0300, Gabriel Sosa wrote:
try doing this
$secs = array();
foreach($_GET['sids'] as $sid){
$obj = null;
$obj = new CustomSecurity();
$obj->set(array('customSecurityID' => $sid));
$secs[] = $obj;
}
No, no, no. If it's a reference issue you need to do the following:
<?php
$secs = array();
foreach($_GET['sids'] as $sid)
{
unset( $obj );
$obj = new CustomSecurity();
$obj->set(array('customSecurityID' => $sid));
$secs[] = $obj;
}
?>
Assignment of null won't break a reference, it'll just make the value
refer to null. You need unset to break the reference. Personally, I'd
like to see the class definition to see what happens inside the set()
method.
Cheers,
Rob.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php