Yii allows developers to construct SQL statement.
This will help advanced developer to tune his/her SQL query (by using appropriate indexes).
Example:
$connection=Yii::app()->db;
$sql = "SELECT t1.colA, t2.colB, t3.colC, t3.colD
FROM tableA t1
LEFT JOIN tableB t2 ON t1.id=t2.id
LEFT JOIN tableC t3 ON t2.pid=t3.pid
WHERE t1.id BETWEEN 10 AND 100
ORDER BY t1.modifyDate DESC";
$command = $connection->createCommand($sql);
$dataReader = $command->query();
$result = $dataReader->readAll();
Internal:
$command=createCommand($query)
Note: $command is a CDbCommand
|- $dataReader = query()
Note: $dataReader is a CDbDataReader
|- CDBDataReader->readAll() returns array()
Monday, April 2, 2012
Subscribe to:
Post Comments (Atom)
1 comment:
Thank you so much, it's really help me!!
Post a Comment