【问题标题】:CDbCommand queryCDbCommand 查询
【发布时间】:2015-08-20 18:16:44
【问题描述】:

我想将 php 引入 CDbCommand 查询,其中id=:id。我想做id=: $model->id

$user = Yii::app()->db->createCommand()
->select('id, username, profile')
->from('tbl_user u')
->join('tbl_profile p', 'u.id=p.user_id')
->where('id=:id')
->queryRow();

【问题讨论】:

    标签: php sql yii


    【解决方案1】:

    试试这个:->where('id=:id', array(':id'=> $model->id))

    【讨论】:

      【解决方案2】:

      在 where 子句中,您可以将属性与参数值匹配,然后使用关联数组指定参数值。

      Where('id=:id',array(':id'=> $model->id)).
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-23
        • 2013-05-19
        相关资源
        最近更新 更多