Yii 1 cdbcriteria如何将param传递给join中的on子句

时间:2017-05-31 08:32:18

标签: join yii model relation

我需要将param传递给join

中的on
    $criteria       = new CDbCriteria;
            $criteria->join = "left join invoices v1 on t.id=v1.s_id and v1.year=:year";
           $criteria->params= array(':year'=>$category->year); //will not work

错误参数号无效:绑定变量数与数量不匹配 令牌

或者是否可以在我的模型中实现

public function relations()
    {
    return array(
              'invoices'=>array(self::BELONGS_TO, 'invoices', '', 'on'=>'t.id=invoices.sid and v1.year=:year', 'joinType'=>'left JOIN', 'alias'=>'invoices' ), //how to pass param :year?

如何在连接中传递参数? 谢谢

0 个答案:

没有答案