我是yii的新手,在执行查询时,我得到的是选定的行数,而不是实际选定的数据。
我怎样才能得到所选的实际数据。
$sql = "SELECT DISTINCT a.CONTENT_ID,a.CONTENT_TITLE
FROM TBL_CONTENT_DETAILS a JOIN TBL_CONTENTS b
ON a.CONTENT_ID=b.CONTENT_ID
WHERE (b.CONTENT_TYPE_ID =22 or b.CONTENT_TYPE_ID=53)
and a.CONTENT_ID not in ($notin)";
$connection = Yii::app()->db2;
$command = $connection->createCommand($sql);
$res = $command->execute();
$notin包含逗号分隔的整数id。
使用$command->queryAll();
代替
execute()
将始终返回受影响的行数,而fetchAll()
将获得一个结果数组。
http://www.yiiframework.com/doc/api/1.1/CDbCommand/#queryAll-详细
也许你想要
$rows = $command->queryAll(); // query and return all rows of result
点击此处了解更多信息。