OK, I am little bit lost...
I am pretty new to PHP, and i am trying to use CakePHP for my web-site. my DB is composed of two tables:
- users with user_id, name columns
- copies with copy_id, copy_name, user_id (as foreign key to users) columns.
and I have the matching CakePHP elements:
- User and Copy as a model
- UserController as controller
- i dont use a view since i just sending the json from the controller.
i have added hasMany relation between the user model and the copy model see below.
var $hasMany = array(
'Copy' => array(
'className' => 'Friendship',
'foreignKey' => 'user_id'
)
);
with out the association Every find() query on the users table works well, but after adding the hasMany to the model the same find() queries on the users stop working (print_r does show anything), and every find() query i am applying on the Copy model
$copy = $this->User->Copy->find('all', array(
'condition' => array('Copy.user_id' => '2')
));
ignores the condition part and just return the whole data base.
how can I debug the code execution? when I am adding the debug($var)
nothing happens.
sorry for the length, it is just I am a little bit lost with this..
i have a User model, and a users_controler, that correspond to the users table in my DB. i also have a Friendship model, and a friendship
when i am trying to use the find() function every thing works well, but when i am adding to the model a hasMany association suddenly the results are