1
lolhangman
Re: problem with criteria and unset
  • 2009/9/3 12:54

  • lolhangman

  • Just popping in

  • Posts: 2

  • Since: 2009/9/3 8


hey, thank you for your but this wasn't the problem.
In fact I've found the answer :
instead of doing a copy like this :
$citeria2 = $criteria
I use the clone() function like this:
$criteria2 = clone($criteria)

but I still don't know why $criteria used in my fonction is not a copy of $criteria but is a reference...



2
lolhangman
problem with criteria and unset
  • 2009/9/3 8:56

  • lolhangman

  • Just popping in

  • Posts: 2

  • Since: 2009/9/3 8


hello everybody,
I have a problem using criteria and unset function.
Issue is : whane I use cirteria in a function a a parameter and I use unset on that criteria in this function, when I exit function this criteria is empty.

first I call the function with my criteria

$eta_handler->getObjectWithJoin($criteria);

then I use unset in that function

function getObjectWithJoin( $criteria ){

.....

if (!empty($criteria->criteriaElements))
{
.....
foreach ($criteria->criteriaElements as $indice=>$criteriaElement)
{
...
unset($criteria->criteriaElements[$indice-$indice_eval]);
...
}

...

}

}


than I call my function a second time with my criteria
$eta_handler->getObjectWithJoin($criteria);

But this time criteriaElements is empty


I tried with a copy ($criteria2 = criteria) for the second call but I had same result.


Does anybody could explain me what happens or has an idea to have my criteria not empty i nthe second call of my function ?

thanks for that.




TopTop



Login

Who's Online

136 user(s) are online (72 user(s) are browsing Support Forums)


Members: 0


Guests: 136


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits