Home  >  Article  >  Backend Development  >  CI框架数据库查询时怎么不识别别名呢?【在线等】

CI框架数据库查询时怎么不识别别名呢?【在线等】

WBOY
WBOYOriginal
2016-06-23 14:39:02932browse

$query = $this->db->query('SELECT count(*) as countNum FROM tab_message where messageToUserId='.$userId);
foreach($query->result() as $row) {
$messageNum = $row->countNum;
    }

输出$messageNum时没有结果。


回复讨论(解决方案)

没人在吗?没人在吗?没人在吗?没人在吗?没人在吗?

print_r($row); 看到的是什么?

什么都没有。

什么都没有?那不就是查询失败了吗?
是在循环里执行的吗?

是的,在循环里执行的,我用的是CI框架,$this->db->count_all_('我的表名');也得不到结果。

还有,我在数据库中用SQL语句查询过是没有问题的。还有CI框架不支持别名吗?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn