0

私はこの機能を作業ページで分離しています。

public function countRow(){
        $id = $_SESSION['id'];
        $num = 1;
        $query = "SELECT count(*) from `auditsummary` where bizID=? AND statusID=?";
        $sql = $this->db->prepare($query);
        $sql->bindParam(1,$id);
        $sql->bindParam(2,$num);
        $sql->execute();


    }

この関数で実際にやろうとしているのは、クエリの結果である行数を数えることですが、その方法と値を返す方法がわかりません。

4

3 に答える 3

0

Use

$query = "SELECT count(*) AS getCount from `auditsummary` where bizID=? AND statusID=?";

And get the values as you normally does

$count = $row["getCount"];
于 2015-08-24T09:13:11.143 に答える