Yii2 innerJoin()

前端 未结 4 744
天命终不由人
天命终不由人 2021-01-12 16:06

I want to implement a sql query in the following way:

INNER JOIN
`Product_has_ProductFeature` t ON `Product`.`id` = t.`productId` AND t.`productFeatureValueI         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-12 16:26

    innerJoin() is a method from the Query class.

    You can try something like this.

    $query = new \yii\db\Query;
    $command = $query->innerJoin(
             'Product_has_ProductFeature',
             `Product`.`id` = t.`productId`)
         ->andWhere('t.`productFeatureValueId` = 1')
         ->createCommand();
    $queryResult = $command->query();
    

提交回复
热议问题