Queryrow Function Get Number Of Rows Affacted

to get single row i m using queryRow function

$SQL = //SQL QUERY

$data = Yii::app()->db->createCommand($SQL);

$result = $data->queryRow();

print_r(count($result));

print_r always shows 1 even if no data-set returned by query. i want if no data-set is returned it should show 0. so can call some other function

what is the issue ?

Hi,

Hope this helps:

http://www.yiiframework.com/doc/guide/1.1/en/database.dao#fetching-query-results

Hi,

Please check if this helps!

Assuming:

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

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

This will work for insert, update and delete:

$rowCount=$command->execute();

execute(): performs a non-query SQL statement, such as INSERT, UPDATE and DELETE. If successful, it returns the number of rows that are affected by the execution.

For select, you could do the following:

$dataReader=$command->query();

This generates the CDbDataReader instance and CDbDataReader provides a rowCount property

http://www.yiiframework.com/doc/api/1.1/CDbDataReader#rowCount-detail

$rowCount = $dataReader->rowCount;

Regards

NO Anyways I Solved It In Diff Way