1

我是 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。

4

2 回答 2

3

$command->queryAll();改为使用

execute()将始终返回受影响的行数,而fetchAll()将为您提供一组结果。

http://www.yiiframework.com/doc/api/1.1/CDbCommand/#queryAll-detail

于 2012-09-06T07:03:12.473 回答
2

也许你想要

$rows = $command->queryAll(); // query and return all rows of result

在此处阅读更多相关信息。

于 2012-09-06T07:02:56.567 回答