binding params in CDbCommand

Hi all,

Can any one please tell me how to bind params(or values)in cdbcommand statement.Following is my code.



 $qtxt ="SELECT  l.first_name, l.last_name, m1.subject, m1.message_text

          FROM messages m1, messages_user_map m2,user_login l

          WHERE m1.message_id = m2.message_id

          AND m2.pk_school_id = :schoolid";


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

        $schoolId = Yii::app()->user->schoolId;

        $schoolid = '%'.$schoolId.'%'; 

	$command->bindValue(":schoolid", $schoolid, PDO::PARAM_INT);					 

						                    

         $schools =$command->queryColumn();

         $res =$command->queryAll(true);




but the vaules are not getting binded(schoolid)…??

bindParam instead of bindValue is your problem…




//$command-bindValue(":schoolid", $schoolid, PDO::PARAM_INT); // wrong

$command->bindParam(":schoolid",$schoolid,PDO::PARAM_INT); // correct



Data Access Objects (DAO) - Binding Parameters

ooops no use…??though i use param,value is not getting binded…

ooh…I resolved it… :rolleyes:

How?