Closed
Description
Description
The conditions on belongsTo relation still can not make conditions based on its own data.
in ArticlesTable
$this->belongsTo('Users', [
'className' => 'Users',
'foreignKey' => 'writer_id',
'joinType' => 'INNER',
'conditions' => ['Articles.type_id' => '1']
]);
$this->belongsTo('Admins', [
'className' => 'Admins',
'foreignKey' => 'writer_id',
'joinType' => 'INNER',
'conditions' => ['Articles.type_id' => '2'],
]);
SQLSTATE[42S22]: Column not found: 1054 Unknown column Articles.type_id
How to use the conditions in belongsTo on its own table?
CakePHP Version
4.4
PHP Version
8