I am using cakephp 1.2 and I have an array that appears to have a value change even though that variable is not being manipulated. Below is the code to that is causing me trouble.
PLEASE NOTE - UPDATE Changing the variable name makes no difference to the outcome.
function findCountByString($string, $myArr=array()) {
$main_conditions['or'] = array();
$main_conditions['or']['Article.title LIKE '] = '%'.$string.'%';
$main_conditions['or']['Article.html_content LIKE '] = '%'.$string.'%';
$conditions['and'][] = $main_conditions;
$filter_conditions['or'] = array();
if(count($myArr) > 0) {
# UPDATE NUMBER 2
# if I comment out the below line everything is fine, this makes no sense!!!
$filter_conditions['or']['ArticleEntity.entity_id'] = $myArr;
$conditions['and'][] = $filter_conditions;
}
echo "Start of findCountByString()";
var_dump($myArr);
$test = $this->find('count', array(
'conditions' => $conditions,
'joins' => array('LEFT JOIN `articles_entities` AS ArticleEntity ON `ArticleEntity`.`article_id` = `Article`.`id`'),
'group' => 'Article.id'
));
echo "End of findCountByString()";
var_dump($myArr);
return $test;
}
I am getting the following output:
Start of findCountByString()
array(4) {
[0]=>
string(36) "4bdb1d96-c680-4c2c-aae7-104c39d70629"
[1]=>
string(36) "4bdb1d6a-9e38-479d-9ad4-105c39d70629"
[2]=>
string(36) "4bdb1b55-35f0-4d22-ab38-104e39d70629"
[3]=>
&string(36) "4bdb25f4-34d4-46ea-bcb6-104f39d70629"
}
End of findCountByString()
array(4) {
[0]=>
string(36) "4bdb1d96-c680-4c2c-aae7-104c39d70629"
[1]=>
string(36) "4bdb1d6a-9e38-479d-9ad4-105c39d70629"
[2]=>
string(36) "4bdb1b55-35f0-4d22-ab38-104e39d70629"
[3]=>
&string(38) "'4bdb25f4-34d4-46ea-bcb6-104f39d70629'"
}
The the value in my array have changed, and I don't know why?
Any suggestions?