在php与mysql中如何实现conn.execute(asp+access)功能.这是asp中的语句:
TotalUserCount=conn.execute("Select count(id) from [WebUser]")(0)
MySQLPHPselect

解决方案 »

  1.   

    问题补充:
    有没有通过一句代码,就可以获取到值的方法,就像asp里那种简洁.
        $result=$conn->query("select count(id) from from MyUser"); 
            $row=$result->fetch_array();
            echo $row[0];
    像这样都要三步才能获取到值.我觉得比较麻烦.
    有没有类似于asp中conn.execute一样的功能.
      

  2.   

    对于$result=$conn->query("select count(id) from from MyUser"); 
    $row=$result->fetch_array();
    echo $row[0];
    你只要使用 php5.3及以上,就可写作echo $conn->query("select count(id) from from MyUser")->fetch_array()[0];
      

  3.   


    麻烦xuzuning帮我再分析下.我用的是PHP5.3.8,但按这样写会出语法错误:Parse error: syntax error, unexpected '[',
      

  4.   

    哈哈,我的自带框架,于是:$Stmt->setCommand('select count(id) from MyUser');
    echo $Stmt->FetchAsScalar()->getValue();