I have the following Model:
class AdminUser extends AppModel {
public $name = ‘AdminUser’;
public $useDbConfig = ‘clientbackend_dev’;
public $useTable = ‘user’;
I need to join another table to do a query. How do I do that?
TIA
I have the following Model:
class AdminUser extends AppModel {
public $name = ‘AdminUser’;
public $useDbConfig = ‘clientbackend_dev’;
public $useTable = ‘user’;
I need to join another table to do a query. How do I do that?
TIA
read this first: https://book.cakephp.org/3.0/en/orm/associations.html
Thanks I should have mentioned I am using 2.9 but your point is well taken.
OK, I read this https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#
I now have this model:
class AdminUser extends AppModel {
public $name = ‘AdminUser’;
public $useDbConfig = ‘clientbackend_dev’;
public $useTable = ‘user’;
public $hasOne = ‘Employee’;
}
And this one:
class Employee extends AppModel {
public $belongsTo = array(
‘AdminUser’ => array(
‘className’ => ‘AdminUser’,
‘foreignKey’ => ‘user_id’
)
);
}
I am still get an error when trying to bring up a page that uses this.
First one should be public $hasOne = [‘Employee’];
How are you trying to use it?
dakota, that did no work. I am still trying to solve the problem and have gotten help and done more troubleshooting. The files are posted on gist,
As always. TIA.