我需要找到具有相同作者的文章如何使用CakePHP中的匹配()找到具有共同父項的實體?
這裏給定列表中的所有的文章是我的自定義finder方法:
public function findSimilar(Query $query, array $options)
{
if (empty($options['idList'])) {
throw new Exception('idList is not populated');
}
// We are given a list of article IDs
$idList = $options['idList'];
return $query->matching('Authors', function ($q) use ($idList) {
return $q->matching('Articles', function ($q2) use ($idList) {
return $q2->where(['Articles.id IN' => $idList]);
});
});
}
不幸的是我收到以下錯誤消息: PDOException:SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'Articles'
我究竟做錯了什麼?