我有以下表格:
CREATE TABLE match (
id INT NOT NULL PRIMARY KEY,
home_team_id INT,
away_team_id INT,
...
)
CREATE TABLE scorer (
id INT NOT NULL PRIMARY KEY,
match_id INT,
player_id INT,
....
)
在 Match 模型中,我定义了一个类似这样的关系:
class Match extends CActiveRecord {
public function relations() {
return array(
'scorers' => array(
self::HAS_MANY,
'Scorer',
'match_id',
),
...
);
}
}
如何获得至少有一名得分手的所有 Match 模型?