Exemplo n.º 1
0
    public function getDealerDetails(){

        return (new Query())->select('Coalesce(ds.security, 0) as `dealerSecurity`,count(dc.id) as dealerCompanies,count(da.dealer) as dealerAuctions')
            ->from(Dealers::tableName(). 'd')
            ->leftJoin(DealerCompany::tableName().' dc', 'dc.dealer=d.id')
            ->leftJoin(DealerSecurity::tableName(). 'ds', 'ds.dealer=d.id')
            ->leftJoin(DealerAuctions::tableName().' da', 'da.dealer=d.id')
            ->where([
                'd.id' => $this->id
            ])->one();

    }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSecurity0()
 {
     return $this->hasOne(DealerSecurity::className(), ['id' => 'security']);
 }