roundcubemail/program/lib/Roundcube/rcube_db.php
public function num_rows($result = null)
    {
        if (($result || ($result === null && ($result = $this->last_result))) && $result !== true) {
            // repeat query with SELECT COUNT(*) ...
            if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/ims', $result->queryString, $m)) {
                $query = $this->dbh->query('SELECT COUNT(*) FROM ' . $m[1], PDO::FETCH_NUM);
                return $query ? intval($query->fetchColumn(0)) : false;
            }
            else {
                $num = count($result->fetchAll());
                $result->execute();  // re-execute query because there's no seek(0)
                return $num;
            }
        }

        return false;
    }
public function num_rows($result = null)
    {
        if (($result || ($result === null && ($result = $this->last_result))) && $result !== true) {
            // repeat query with SELECT COUNT(*) ...
            if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/ims', $result->queryString, $m)) {
                $query = $this->dbh->query('SELECT COUNT(*) FROM ' . $m[1], PDO::FETCH_NUM);
                return $query ? intval($query->fetchColumn(0)) : false;
            }
            else {
                $num = count($result->fetchAll());
                $result->execute();  // re-execute query because there's no seek(0)
                return $num;
            }
        }

        return false;
    }
public function num_rows ( $ result = null ) { if ( ( $ result || ( $ result === null && ( $ result = $ this -> last_result ) ) ) && $ result !== true ) { // repeat query with SELECT COUNT(*) ... if ( preg_match ( '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/ims' , $ result -> queryString , $ m ) ) { $ query = $ this -> dbh -> query ( 'SELECT COUNT(*) FROM ' . $ m [ 1 ] , PDO :: FETCH_NUM ) ; return $ query ? intval ( $ query -> fetchColumn ( 0 ) ) : false ; } else { $ num = count ( $ result -> fetchAll ( ) ) ; $ result -> execute ( ) ; // re-execute query because there's no seek(0) return $ num ; } } return false ; }
Get number of rows for a SQL query
If no query handle is specified, the last query will be taken as reference

@param mixed $result Optional query handle

@return mixed Number of rows or false on failure
@deprecated This method shows very poor performance and should be avoided.
Get number of rows for a SQL query If no query handle is specified the last query will be taken as reference