--- C:\Users\Edward\Webs\drupal\includes\database.inc 2008-01-15 23:26:00.275000000 -0500 +++ C:\Users\Edward\Webs\drupal\includes\database.inc.formatted 2008-01-16 17:44:33.389357100 -0500 @@ -1,6 +1,7 @@ The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.
'; $message .= 'If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider\'s database server is running. For more help, see the handbook, or contact your hosting provider.
The '. theme('placeholder', $db_type) .' error was: '. theme('placeholder', $error) .'.
'; } - + print theme('maintenance_page', $message); exit; } @@ -204,17 +207,24 @@ $args = $match; return; } - + switch ($match[1]) { - case '%d': // We must use type casting to int to convert FALSE/NULL/(TRUE?) - return (int) array_shift($args); // We don't need db_escape_string as numbers are db-safe + case '%d': + // We must use type casting to int to convert FALSE/NULL/(TRUE?) + // We don't need db_escape_string as numbers are db-safe + return (int) array_shift($args); + case '%s': return db_escape_string(array_shift($args)); + case '%%': return '%'; + case '%f': return (float) array_shift($args); - case '%b': // binary data + + case '%b': + // binary data return db_encode_blob(array_shift($args)); } } @@ -257,12 +267,13 @@ * Name of the primary field. * @param $args * Array of additional arguments. + * * @return * An array: join statements, where statements, field or DISTINCT(field). */ function _db_rewrite_sql($query = '', $primary_table = 'n', $primary_field = 'nid', $args = array()) { - $where = array(); - $join = array(); + $where = array(); + $join = array(); $distinct = FALSE; foreach (module_implements('db_rewrite_sql') as $module) { $result = module_invoke($module, 'db_rewrite_sql', $query, $primary_table, $primary_field, $args); @@ -281,10 +292,10 @@ $where[] = $result; } } - + $where = empty($where) ? '' : '('. implode(') AND (', $where) .')'; $join = empty($join) ? '' : implode(' ', $join); - + return array($join, $where, $distinct); } @@ -303,17 +314,18 @@ * Name of the primary field. * @param $args * An array of arguments, passed to the implementations of hook_db_rewrite_sql. + * * @return * The original query with JOIN and WHERE statements inserted from * hook_db_rewrite_sql implementations. nid is rewritten if needed. */ -function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $args = array()) { +function db_rewrite_sql($query, $primary_table = 'n', $primary_field = 'nid', $args = array()) { list($join, $where, $distinct) = _db_rewrite_sql($query, $primary_table, $primary_field, $args); - + if ($distinct) { $query = db_distinct_field($primary_table, $primary_field, $query); } - + if (!empty($where) || !empty($join)) { $pattern = '{ # Beginning of the string @@ -329,9 +341,9 @@ }x'; preg_match($pattern, $query, $matches); if ($where) { - $n = strlen($matches[1]); + $n = strlen($matches[1]); $second_part = substr($query, $n); - $first_part = substr($matches[1], 0, $n - 5) ." $join WHERE $where AND ( "; + $first_part = substr($matches[1], 0, $n - 5) ." $join WHERE $where AND ( "; // PHP 4 does not support strrpos for strings. We emulate it. $haystack_reverse = strrev($second_part); // No need to use strrev on the needle, we supply GROUP, ORDER, LIMIT @@ -355,7 +367,7 @@ $query = $matches[1] ." $join ". substr($query, strlen($matches[1])); } } - + return $query; } @@ -482,7 +494,7 @@ * @see drupal_install_schema() */ - /** +/** * Create a new table from a Drupal table definition. * * @param $ret @@ -507,6 +519,7 @@ * * @param $fields * An array of key/index column specifiers. + * * @return * An array of field names. */ @@ -531,6 +544,7 @@ * * @param $type * The Schema API type of a field. + * * @return * The placeholder string to embed in a query for that type. */ @@ -541,7 +555,7 @@ case 'text': case 'datetime': return '\'%s\''; - + case 'numeric': // For 'numeric' values, we use '%s', not '\'%s\'' as with // string types, because numeric values should not be enclosed @@ -550,18 +564,18 @@ // presumably no db's "escape string" function will mess with // those characters. return '%s'; - + case 'serial': case 'int': return '%d'; - + case 'float': return '%f'; - + case 'blob': return '%b'; } - + // There is no safe value to return here, so return something that // will cause the query to fail. return 'unsupported type '. $type .'for db_type_placeholder'; @@ -570,3 +584,4 @@ /** * @} End of "defgroup schemaapi". */ +