Yii Database Query

Cheatsheet Example


CDB command Update

$id = 5;
$modified_on = NOW; 
$sql = "UPDATE table SET modified_on='".$modified_on."', name='hello ' WHERE result_id=:result_id"; 
$command = Yii::app()->db->createCommand($sql);
$command->bindParam(":result_id", $id , PDO::PARAM_STR );
$command->execute();

CDB command query

$sql = "SELECT action_id FROM action_testcase where testcase_id ='".$this->testcase_id."';";
$cmd = Yii::app()->db->createCommand($sql);
$result = $cmd->queryRow();
$action_id = $result['action_id'];

Share this

Related Posts

Previous
Next Post »