qu"/> qu">

获取表内总数。解决方法

WBOY
Release: 2016-06-13 13:13:37
Original
910 people have browsed it

获取表内总数。

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;

    }
Copy after login


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



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);
        }
        
Copy after login


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

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