query($"/> query($">

Home  >  Article  >  Backend Development  >  获取表内总数。解决方法

获取表内总数。解决方法

WBOY
WBOYOriginal
2016-06-13 10:46:30834browse

获取表内总数。

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->    public  function count(){        $db=new Db();        $db->connect();        $query="select count(*) from wenzhang";        $shuju=$db->query($query);        $db->close();        return $shuju;    }


可以为什么我在调用页面接受不到呢?



DB类的query语句
PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->public function query($query)    //发送sql语句 insert update select        {            $this->result=mysql_query($query);        }        


------解决方案--------------------
通常情况下 要用 mysql_fetch_array() 将结果集转化为数组对吧,你的代码中没有啊

$query="select count(*) from wenzhang";
$shuju=$db->query($query);
$row= mysql_fetch_array($shuju);
$db->close();
return $row[0];
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