Make WordPress Core

Ticket #11146: wp-db.php.diff

File wp-db.php.diff, 5.3 KB (added by sirzooro, 16 years ago)
  • wp-db.php

    old new  
    394394                                        $collation_query = "SET NAMES '{$this->charset}'";
    395395                                        if ( !empty($this->collate) )
    396396                                                $collation_query .= " COLLATE '{$this->collate}'";
    397                                         $this->query($collation_query);
     397                                        $this->query($collation_query, false);
    398398                                }
    399399                        }
    400400                }
     
    679679         *
    680680         * @since 0.71
    681681         *
    682          * @param string $query
     682         * @param string $query - query to execute
     683         * @param bool $maybe_cache (optional) Set to false to explicitly disable caching if available
    683684         * @return int|false Number of rows affected/selected or false on error
    684685         */
    685         function query($query) {
     686        function query($query, $maybe_cache = true) {
    686687                if ( ! $this->ready )
    687688                        return false;
    688689
     
    778779                        $formatted_fields[] = $form;
    779780                }
    780781                $sql = "INSERT INTO `$table` (`" . implode( '`,`', $fields ) . "`) VALUES ('" . implode( "','", $formatted_fields ) . "')";
    781                 return $this->query( $this->prepare( $sql, $data) );
     782                return $this->query( $this->prepare( $sql, $data ), false );
    782783        }
    783784
    784785
     
    827828                }
    828829
    829830                $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' WHERE ' . implode( ' AND ', $wheres );
    830                 return $this->query( $this->prepare( $sql, array_merge(array_values($data), array_values($where))) );
     831                return $this->query( $this->prepare( $sql, array_merge(array_values($data), array_values($where))), false );
    831832        }
    832833
    833834        /**
     
    842843         * @param string|null $query SQL query.  If null, use the result from the previous query.
    843844         * @param int $x (optional) Column of value to return.  Indexed from 0.
    844845         * @param int $y (optional) Row of value to return.  Indexed from 0.
     846         * @param bool $maybe_cache (optional) Set to false to explicitly disable caching if available
    845847         * @return string Database query result
    846848         */
    847         function get_var($query=null, $x = 0, $y = 0) {
     849        function get_var($query=null, $x = 0, $y = 0, $maybe_cache = true) {
    848850                $this->func_call = "\$db->get_var(\"$query\",$x,$y)";
    849851                if ( $query )
    850                         $this->query($query);
     852                        $this->query( $query, $maybe_cache );
    851853
    852854                // Extract var out of cached results based x,y vals
    853855                if ( !empty( $this->last_result[$y] ) ) {
     
    868870         * @param string|null $query SQL query.
    869871         * @param string $output (optional) one of ARRAY_A | ARRAY_N | OBJECT constants.  Return an associative array (column => value, ...), a numerically indexed array (0 => value, ...) or an object ( ->column = value ), respectively.
    870872         * @param int $y (optional) Row to return.  Indexed from 0.
    871          * @return mixed Database query result in format specifed by $output
     873         * @param bool $maybe_cache (optional) Set to false to explicitly disable caching if available
     874         * @return mixed Database query result in format specified by $output
    872875         */
    873         function get_row($query = null, $output = OBJECT, $y = 0) {
     876        function get_row($query = null, $output = OBJECT, $y = 0, $maybe_cache = true) {
    874877                $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
    875878                if ( $query )
    876                         $this->query($query);
     879                        $this->query( $query, $maybe_cache );
    877880                else
    878881                        return null;
    879882
     
    887890                } elseif ( $output == ARRAY_N ) {
    888891                        return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null;
    889892                } else {
    890                         $this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/);
     893                        $this->print_error(/*WP_I18N_DB_GETROW_ERROR*/" \$db->get_row(string query, output type, int offset, bool maybe_cache) -- Output type must be one of: OBJECT, ARRAY_A, ARRAY_N"/*/WP_I18N_DB_GETROW_ERROR*/);
    891894                }
    892895        }
    893896
     
    902905         *
    903906         * @param string|null $query SQL query.  If null, use the result from the previous query.
    904907         * @param int $x Column to return.  Indexed from 0.
     908         * @param bool $maybe_cache (optional) Set to false to explicitly disable caching if available
    905909         * @return array Database query result.  Array indexed from 0 by SQL result row number.
    906910         */
    907         function get_col($query = null , $x = 0) {
     911        function get_col( $query = null , $x = 0, $maybe_cache = true ) {
    908912                if ( $query )
    909                         $this->query($query);
     913                        $this->query( $query, $maybe_cache );
    910914
    911915                $new_array = array();
    912916                // Extract the column values
     
    925929         *
    926930         * @param string $query SQL query.
    927931         * @param string $output (optional) ane of ARRAY_A | ARRAY_N | OBJECT | OBJECT_K constants.  With one of the first three, return an array of rows indexed from 0 by SQL result row number.  Each row is an associative array (column => value, ...), a numerically indexed array (0 => value, ...), or an object. ( ->column = value ), respectively.  With OBJECT_K, return an associative array of row objects keyed by the value of each row's first column's value.  Duplicate keys are discarded.
     932         * @param bool $maybe_cache (optional) Set to false to explicitly disable caching if available
    928933         * @return mixed Database query results
    929934         */
    930         function get_results($query = null, $output = OBJECT) {
    931                 $this->func_call = "\$db->get_results(\"$query\", $output)";
     935        function get_results( $query = null, $output = OBJECT, $maybe_cache = true ) {
     936                $this->func_call = "\$db->get_results(\"$query\", $output, $maybe_cache)";
    932937
    933938                if ( $query )
    934                         $this->query($query);
     939                        $this->query( $query, $maybe_cache );
    935940                else
    936941                        return null;
    937942