CDbCommand or CDbCommandBuilder

Hi,

First let me explain I will be fetching a lot of records from tables, I will not be using ARecord as I wont’ be updating or deleting data for now. So I think I will using CDbCommand or CDbCommandBuilder to fetch the data. This is right?

I’ve looked at the CDbCommand and I’ve managed to get the results with the following code:




$connection = Yii::app()->db;

$sql = "SELECT * FROM Hotels LIMIT 10";

$command = $connection->createCommand($sql);

$data = $command->query();

$this->render('index', $data);

But I will be doing some complex queries with sorting and criteria, should I use CDbCommand or CDbCommandBuilder?

I can’t seem to find much information about the CDbCommandBuilder, is there any good place to see this documentation?

Sorry if all the questions are so noob.

Thanks

for direct calling queries I think the simple CDbCommand have all do you need;

another way:




$connection=new CDbConnection($dsn,$username,$password);

$connection->active=true;

After the DB connection is established, one can execute an SQL statement like the following: 

$command=$connection->createCommand($sqlStatement);

$command->execute();   // a non-query SQL statement execution

// or execute an SQL query and fetch the result set

$reader=$command->query();

// each $row is an array representing a row of data

foreach($reader as $row){

print_r($row);

}



regards

In my understanding CDbCommandBuilder is the "engine" that is used by AR to build its SQL statements.