我有一个保存相关帖子 ID 的表。
$criteria = new CDbCriteria;
$criteria -> select = 'content_2';
$criteria -> condition = 'content_1=:c';
$criteria -> limit = $count;
$criteria -> params = array(':c' => $id);
$posts_id = SiteContentRelated::model() -> findAll($criteria);
$ids = array();
foreach ($posts_id as $value) {
$ids[] = intval($value['content_2']);
}
$posts = SiteContent::model()->findAllByPk($ids);
echo '<pre style="direction:ltr;">';
print_r(count($posts));
echo "</pre>";
die();
结果:
1
而且我确定表中的行数(3行)。我的错误在哪里?