这是我的查询:
$query = $appointments->find();
$query->where(['Appointments.id =' => '786']);
$query->order(['date' => 'ASC']);
这会返回1个结果。现在,当我想要与另一个属于'属于'表我使用此查询:
$query = $appointments->find();
$query->select(['Appointments.id', 'Appointments.start', 'Clients.name', 'Services.Name']);
$query->where(['Appointments.id =' => '786']);
$query->contain(['Clients', 'Users', 'Services']);
$query->order(['date' => 'ASC']);
这会返回0结果,我做错了吗?
这是我的AppointmentsTable.php:
public function initialize(array $config)
{
parent::initialize($config);
$this->table('appointments');
$this->displayField('id');
$this->primaryKey('id');
$this->belongsTo('Users', [
'foreignKey' => 'user_id',
'joinType' => 'INNER'
]);
$this->belongsTo('Clients', [
'foreignKey' => 'client_id',
'joinType' => 'INNER'
]);
$this->belongsTo('Services', [
'foreignKey' => 'service_id'
]);
}