Код: Выделить всё
/**
* @property integer $id
* @property integer $section_id
* @property string $name
*
* @property-read Section $section
*/
class Article extends ActiveRecord {
public static function tableName() {
return '{{%articles}}';
}
public function getSection() {
return $this->hasOne(Section::class, ['id' => 'section_id']);
}
}
/**
* @property integer $id
* @property string $name
*
* @property-read Article[] $articles
*/
class Section extends ActiveRecord {
public static function tableName() {
return '{{%sections}}';
}
public function getArticles(): ActiveQuery {
return $this->hasMany(Article::class, ['section_id' => 'id'])->inverseOf('section');
}
}
Код: Выделить всё
SELECT * FROM `sections` WHERE 0=1
Подскажите почему так происходит? Ну во первых правильный запрос уж тогда должен быть:
Код: Выделить всё
SELECT * FROM `sections` WHERE `id` is null