用户结构
id | name
user_stories
id | user_id | story_name
UsersTable
$this->hasMany('UserStories')->setForeignKey('user_id ');
UserStories
$this->belongsTo('Users')->setForeignKey('user_id');
$query = $this->find();
$query->contain([
'UserStories'
])->select([
'UserStories.name'
]);
错误未知列UserStories.name
答案 0 :(得分:2)
您可以选择包含部分
中的字段$query = $this->find();
$query->contain([
'UserStories' [
'fields' => [
'UserStories.name'
]
]
]);