dtgu21994537 2013-12-11 13:11
浏览 72
已采纳

CDBCriteria中SELECT的绑定参数

I'm using Yii CDBCriteria to find records.

I have to put a string value as a custom column in "SELECT" like this:

$criteria = new CDbCriteria;
$criteria->select = array('*, DATE_ADD(createdon, INTERVAL :timezonediff SECOND) as createdon' );       
$criteria->condition = "some_amount > 1000";        
$criteria->params = array(':timezonediff' => "10800");      
$transModel = new TransactionModel;

I'm having a problem where I'm not able to provide the value for ":timezonediff" token in SELECT.

$criteria->params is only working for the tokens in condition but not for SELECT.

I even tried to give an array in $criteria->select, but it didn't work.

Does anyone know if I'm doing something wrong here ?

  • 写回答

3条回答 默认 最新

  • duancenxiao0482 2013-12-17 05:05
    关注

    Thank you all for contributing. I have solved the issue. I was doing a mistake which was causing an error. I was providing this criteria to another object which did not have :timezonediff token.

    Parameters for the tokens even in "select" can be binded in $criteria->params smoothly and it will create no error. So technically there will be no error in the code I posted in question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂