yii2:使用composer更新项目后为foreach()提供的参数无效

时间:2016-06-11 07:39:24

标签: yii yii2

我在这行中有错误:

               $count2 = new app\models\Opportunity;
  -->             $count3 = $count2->countType($idP, $allId);    <--

coutType就是这样:

public function countType($type, $allId) {


        $query = (new \yii\db\Query())->select(['count(id)'])->from('opportunity');


        $query->andWhere(['in', 'id', $allId]);

        $query->andWhere(['in', 'project_type_id', $type]);

        $command = $query->createCommand();
        $model = $command->queryAll();
        return $model;
    }

$allId包含以下数据:

array(67) { [0]=> string(3) "473" [1]=> string(3) "472" [2]=> string(3) "471" [3]=> string(3) "470" [4]=> string(3) "469" [5]=> string(3) "468" [6]=> string(3) "467" [7]=> string(3) "466" [8]=> string(3) "465" [9]=> string(3) "464" [10]=> string(3) "463" [11]=> string(3) "462" [12]=> string(3) "461" [13]=> string(3) "460" [14]=> string(3) "451" [15]=> string(3) "450" [16]=> string(3) "449" [17]=> string(3) "448" [18]=> string(3) "447" [19]=> string(3) "446" [20]=> string(3) "445" [21]=> string(3) "444" [22]=> string(3) "443" [23]=> string(3) "442" [24]=> string(3) "436" [25]=> string(3) "435" [26]=> string(3) "434" [27]=> string(3) "433" [28]=> string(3) "432" [29]=> string(3) "431" [30]=> string(3) "430" [31]=> string(3) "426" [32]=> string(3) "425" [33]=> string(3) "424" [34]=> string(3) "423" [35]=> string(3) "422" [36]=> string(3) "421" [37]=> string(3) "420" [38]=> string(3) "419" [39]=> string(3) "418" [40]=> string(3) "417" [41]=> string(3) "416" [42]=> string(3) "415" [43]=> string(3) "414" [44]=> string(3) "413" [45]=> string(3) "412" [46]=> string(3) "411" [47]=> string(3) "410" [48]=> string(3) "409" [49]=> string(3) "407" [50]=> string(3) "406" [51]=> string(3) "405" [52]=> string(3) "404" [53]=> string(3) "403" [54]=> string(3) "402" [55]=> string(3) "401" [56]=> string(3) "400" [57]=> string(3) "399" [58]=> string(3) "393" [59]=> string(3) "392" [60]=> string(3) "391" [61]=> string(3) "390" [62]=> string(3) "389" [63]=> string(3) "388" [64]=> string(3) "387" [65]=> string(3) "386" [66]=> string(3) "382" } 

如何解决我的问题?

0 个答案:

没有答案