Aleksander Machniak
2013-04-17 39a034b50d65dca9215059b0e001ec1de41d0406
program/lib/Roundcube/rcube_db.php
@@ -444,17 +444,20 @@
     *
     * @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.
     */
    public function num_rows($result = null)
    {
        if ($result || ($result === null && ($result = $this->last_result))) {
            // repeat query with SELECT COUNT(*) ...
            if (preg_match('/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i', $result->queryString, $m)) {
            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 {
                return count($result->fetchAll());
                $num = count($result->fetchAll());
                $result->execute();  // re-execute query because there's no seek(0)
                return $num;
            }
        }
@@ -650,6 +653,20 @@
     * @param string $str Value to quote
     *
     * @return string Quoted string for use in query
     * @deprecated    Replaced by rcube_db::quote
     * @see           rcube_db::quote
     */
    public function simpleEscape($str)
    {
        return $this->quote($str);
    }
    /**
     * Quotes a string so it can be safely used as a table or column name
     *
     * @param string $str Value to quote
     *
     * @return string Quoted string for use in query
     */
    public function quote_identifier($str)
    {