This problem has me very stumped and I hope you can help me out.
I have a model in CakePHP (2.x) that references another model like this:
<?php
App::uses('MyClass2', 'Model');
class MyClass1 extends AppModel {
Later in the class, I call find('all')
on MyClass2
:
$params = array(
'MyClass2.user_id' => $user_id
);
$my_class2 = new MyClass2();
$data = $my_class2->find('all', $params);
But instead of returning only the rows that match $user_id
, it returns every row in the database. I can confirm that $user_id
is being saved in the database correct and is initialized correctly, but it still always returns all the data instead of only the rows that match $user_id
. What should I do to get the data from MyClass2
inside of MyClass1
that only matched the correct $user_id
?