Yii2 ActiveQuery

时间:2017-05-23 07:38:43

标签: sql yii yii2 yii2-model

当我尝试运行下面提到的查询时,我收到此错误 - strtoupper() expects parameter 1 to be string, array given (/vendor/yiisoft/yii2/db/QueryBuilder.php - Line 1050)

$bookings = \app\models\Bookings::find()
    ->where([
        'AND',
        ['IN', 'member_id', $members_query],
        ['IN', 'resource_id', $resources_query],
        ['>=', 'from_date', $start_date],
        ['<=', 'to_date', $end_date]
    ])->all();

$member_query$resources_query是ActiveQuery对象。我也尝试了下面的变化,但最终出现了同样的错误。

$bookings = \app\models\Bookings::find()
    ->where(['IN', 'member_id', $members_query]),
    ->andWhere(['IN', 'resource_id', $resources_query]),
    ->andWhere(['>=', 'from_date', $start_date]),
    ->andWhere(['<=', 'to_date', $end_date])
    ->all();

0 个答案:

没有答案