When I put recursive = 2 to retrieve the data from all the tables it gives me this error:
It seems that when I put recursive = 2 the User model only retrieves the belongsto relation and not the hasmany, this is the code of model User:
<?php
App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
class User extends AppModel {
var $name = 'User';
public $virtualFields = array(
'full_name' => "CONCAT(User.firstname, ' ',User.lastname)"
);
public $displayField = 'full_name';
public $order = array('User.profile_id', 'User.lastname');
public $belongsTo = array(
'Profile' => array(
'className' => 'Profile'
),
'Referrer' => array(
'className' => 'User',
'foreignKey' => 'referrer_id'
)
);
public $hasMany = array(
'Pacient' => array(
'className' => 'Pacient'
),
'UserxGroup' => array(
'className' => 'UserxGroup',
'foreignKey' => 'user_id'
)
);
public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
$passwordHasher = new BlowfishPasswordHasher();
$this->data[$this->alias]['password'] = $passwordHasher->hash(
$this->data[$this->alias]['password']
);
}
return true;
}
var $actsAs = array(
'UploadPack.Upload' => array(
'image' => array(
'styles' => array(
'thumb' => '200x200',
'detail' => '512x512'
)
)
)
);
}
?>
What should I do to have the hasmany relations included in the query?