hi there
i have these tables:
$this->createTable('category', [
'id' => Schema::TYPE_PK,
]);
$this->createTable('question', [
'id' => Schema::TYPE_PK,
'recall' => Schema::TYPE_INTEGER,
'standard' => Schema::TYPE_INTEGER,
]);
$this->createTable('category_relation', [
'id' => Schema::TYPE_PK,
'category_id' => Schema::TYPE_INTEGER,
'post_id' => Schema::TYPE_INTEGER,
'type' => Schema::TYPE_STRING,
]);
$this->addForeignKey('category_ralation_to_category', 'category_relation', 'category_id', 'category', 'id', 'CASCADE', 'CASCADE');
$this->addForeignKey('category_relation_to_question', 'category_relation', 'post_id', 'question', 'id', 'CASCADE', 'CASCADE');
and this relation in Category model:
public function getQuestions(){
return $this->hasMany(Question::className(), ['id' => 'post_id'])
->viaTable(CategoryRelation::tableName(), ['category_id' => 'id']);
}
everything in ok and I get right result from my model like this:
Category::findOne(34)->questions
now, how can add more clause where retrieve result, like get “Category::findOne(34)->questions” where [color="#0000FF"]category_relation.type = ‘standard’[/color] and [color="#0000FF"]question.recall = 1[/color] ?
thanks