Home > Backend Development > PHP Tutorial > 有关mysql : select count(*) from XXX的有关问题

有关mysql : select count(*) from XXX的有关问题

WBOY
Release: 2016-06-13 13:38:51
Original
1076 people have browsed it

有关mysql : select count(*) from XXX的问题
在mysql控制台里这条语句没啥问题
返回结果0

可是在php里$result=select count(*) from XXX
返回的结果怎么处理?
我得到的$result并不是我期望的0

比如我希望select count(*) from XXX 后,没有找到数据,然后再执行插入数据

请问怎么解决?

刚接触php+mysql没多久,以前用。net+mssql 用惯了,mysql的语句好多都不同

------解决方案--------------------
$data = $db->query($sql);
list($total) = $data->fetchRow($data);

$total 就是你想要的结果.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template