Yodanto at
CakePHP 3.x ORM:
hasOne relations with custom select() must include fields from related hasOne tables.
Sample:
$query = $mainTable-> find()
-> select([
'field1' => 'MainTables.last_name',
'field2' => 'MainTables.first_name',
'MainTables.id',
'SecondTable.id',
'SecondTable.location',
])
-> contain(['SecondTable'])
-> first();
hasOne relations with custom select() must include fields from related hasOne tables.
Sample:
$query = $mainTable-> find()
-> select([
'field1' => 'MainTables.last_name',
'field2' => 'MainTables.first_name',
'MainTables.id',
'SecondTable.id',
'SecondTable.location',
])
-> contain(['SecondTable'])
-> first();