Ticket #11146: wp-db.php.diff
File wp-db.php.diff, 5.3 KB (added by , 16 years ago) |
---|
-
wp-db.php
old new 394 394 $collation_query = "SET NAMES '{$this->charset}'"; 395 395 if ( !empty($this->collate) ) 396 396 $collation_query .= " COLLATE '{$this->collate}'"; 397 $this->query($collation_query );397 $this->query($collation_query, false); 398 398 } 399 399 } 400 400 } … … 679 679 * 680 680 * @since 0.71 681 681 * 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 683 684 * @return int|false Number of rows affected/selected or false on error 684 685 */ 685 function query($query ) {686 function query($query, $maybe_cache = true) { 686 687 if ( ! $this->ready ) 687 688 return false; 688 689 … … 778 779 $formatted_fields[] = $form; 779 780 } 780 781 $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 ); 782 783 } 783 784 784 785 … … 827 828 } 828 829 829 830 $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 ); 831 832 } 832 833 833 834 /** … … 842 843 * @param string|null $query SQL query. If null, use the result from the previous query. 843 844 * @param int $x (optional) Column of value to return. Indexed from 0. 844 845 * @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 845 847 * @return string Database query result 846 848 */ 847 function get_var($query=null, $x = 0, $y = 0 ) {849 function get_var($query=null, $x = 0, $y = 0, $maybe_cache = true) { 848 850 $this->func_call = "\$db->get_var(\"$query\",$x,$y)"; 849 851 if ( $query ) 850 $this->query( $query);852 $this->query( $query, $maybe_cache ); 851 853 852 854 // Extract var out of cached results based x,y vals 853 855 if ( !empty( $this->last_result[$y] ) ) { … … 868 870 * @param string|null $query SQL query. 869 871 * @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. 870 872 * @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 872 875 */ 873 function get_row($query = null, $output = OBJECT, $y = 0 ) {876 function get_row($query = null, $output = OBJECT, $y = 0, $maybe_cache = true) { 874 877 $this->func_call = "\$db->get_row(\"$query\",$output,$y)"; 875 878 if ( $query ) 876 $this->query( $query);879 $this->query( $query, $maybe_cache ); 877 880 else 878 881 return null; 879 882 … … 887 890 } elseif ( $output == ARRAY_N ) { 888 891 return $this->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null; 889 892 } 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*/); 891 894 } 892 895 } 893 896 … … 902 905 * 903 906 * @param string|null $query SQL query. If null, use the result from the previous query. 904 907 * @param int $x Column to return. Indexed from 0. 908 * @param bool $maybe_cache (optional) Set to false to explicitly disable caching if available 905 909 * @return array Database query result. Array indexed from 0 by SQL result row number. 906 910 */ 907 function get_col( $query = null , $x = 0) {911 function get_col( $query = null , $x = 0, $maybe_cache = true ) { 908 912 if ( $query ) 909 $this->query( $query);913 $this->query( $query, $maybe_cache ); 910 914 911 915 $new_array = array(); 912 916 // Extract the column values … … 925 929 * 926 930 * @param string $query SQL query. 927 931 * @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 928 933 * @return mixed Database query results 929 934 */ 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)"; 932 937 933 938 if ( $query ) 934 $this->query( $query);939 $this->query( $query, $maybe_cache ); 935 940 else 936 941 return null; 937 942