Cdbcommand Sql Parameters

I am having a hard time with these SQL parameter substitution feature. Can anyone tell what I am doing wrong?




$item=4;

$row = Yii::app()->db->createCommand()

                ->select('*')

                ->from('bid_cost')

                ->where('PAY_ITEM=:item',array(':item'=>$item))

                ->text;

echo $row;



The :item is never substituted with 4;

This is because Yii uses PDO.

CDbCommand::getText() / SQL does not hold the param values.

They are hold in the attribute ‘params’ .

The param values will be submitted to the PDO statement on CDbCommand::queryRow() by PDO::bindParam;





  $item=4;

  $command = Yii::app()->db->createCommand()

       ->select('*')

       ->from('bid_cost')

       ->where('PAY_ITEM=:item',array(':item'=>$item));


  var_dump(

           $command->text,

           $command->params,

           $command->queryRow()

          );