yii, Executing a SQL without calling a Model

yii, Executing a SQL without calling a Model

<?
$connection=Yii::app()->db;
$sql = "SELECT id,username FROM users";
$command = $connection->createCommand($sql);
$dataReader=$command->query();
$rows=$dataReader->readAll();
print_r($rows);
?>

Leave a comment

Your email address will not be published. Required fields are marked *