示例#1
0
文件: Video.php 项目: IVsevolod/zouk
 public function getItems()
 {
     return $this->hasMany(Item::className(), ['id' => 'entity_1_id'])->viaTable(EntityLink::tableName(), ['entity_2_id' => 'id'], function ($query) {
         $query->onCondition(['entity_1' => Item::THIS_ENTITY, 'entity_2' => Video::THIS_ENTITY]);
     });
 }
示例#2
0
文件: School.php 项目: IVsevolod/zouk
 /**
  * @return Img[]
  */
 public function getImgsSort()
 {
     $query = Img::find()->innerJoin(EntityLink::tableName(), Img::tableName() . '.id = `' . EntityLink::tableName() . '`.entity_2_id')->andWhere(['entity_1' => self::THIS_ENTITY, 'entity_2' => Img::THIS_ENTITY, 'entity_1_id' => $this->id])->orderBy(['sort' => SORT_ASC]);
     return $query->all();
 }