Rick
Rick

Reputation: 17013

CakePHP returning double array from find('list) query

I'm using cakephp and am getting back a "double array" where it is giving me 2 arrays where it should be 1, I have looked into the issue as far as cakephp and can't figure it out and just want to move past this for now so I am wondering if anyone knows how to unset a second array if a variable has 2 arrays.. below is the print_r of the array, its just one variable that has this, which I find odd.. so I want to make it so there is not a 2nd set of duplicate values, if I do an array_push it pushes both values for that index into the resulting new array index so that won't work

one variable is equal to the following:

Array ( [0] => 42 [1] => 62 ) Array ( [0] => 42 [1] => 62 ) 

EDIT:

This is not an issue of my printing out the array twice accidentally, as I said above, with a foreach array_push of the variable, i end up with this, which is odd:

Array ( [0] => 4242 [1] => 6262 )

EDIT:

This is the cakephp database call that I am using, I know I didn't ask this in regards to cakephp but since some people think this is impossible i am posting this just so you can see what it does if you want

    $specificfields_array = $this->Mymodel->find('list', array('fields' =>'Mymodel.id'),
                'conditions' => array('emailgroup' => $categorynumber, 'sent' => '0');));

EDIT:

This is what a "foreach" array_push is:

$mynewarray = array();

foreach ($specificfields as $specificfields_current) {

array_push ($mynewarray, $specificfields_current);

}

Upvotes: 0

Views: 1300

Answers (2)

Abba Bryant
Abba Bryant

Reputation: 4012

Can you post the controller, the model and the view file with your print_r calls to the http://bin.cakephp.org/ site and post the links back here so we can see all of your code?

Upvotes: 0

Artefacto
Artefacto

Reputation: 97835

A variable cannot "have two arrays". It can be one array that has two arrays nested. The scenario you describe is impossible (probably there are two print_r there or there is a < character hiding stuff – check the HTML source).

Upvotes: 1

Related Questions