? INSTALL.oci.txt ? SIREN.txt ? sites/default/files ? sites/default/modules Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.133 diff -u -p -r1.133 install.php --- install.php 20 Sep 2008 20:22:23 -0000 1.133 +++ install.php 22 Sep 2008 09:06:47 -0000 @@ -160,7 +160,7 @@ function install_main() { function install_verify_drupal() { // Read the variable manually using the @ so we don't trigger an error if it fails. try { - if ($result = db_query("SELECT value FROM {variable} WHERE name = '%s'", 'install_task')) { + if ($result = db_query("SELECT [value] FROM [{variable}] WHERE [name] = %s", 'install_task')) { return unserialize(db_result($result)); } } Index: includes/actions.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/actions.inc,v retrieving revision 1.17 diff -u -p -r1.17 actions.inc --- includes/actions.inc 15 Sep 2008 16:07:47 -0000 1.17 +++ includes/actions.inc 22 Sep 2008 09:06:47 -0000 @@ -66,7 +66,7 @@ function actions_do($action_ids, $object $where_clause = implode(' ', $where); // Strip off leading 'OR '. $where_clause = '(' . strstr($where_clause, " ") . ')'; - $result_db = db_query('SELECT * FROM {actions} WHERE ' . $where_clause, $where_values); + $result_db = db_query('SELECT * FROM [{actions}] WHERE ' . $where_clause, $where_values); while ($action = db_fetch_object($result_db)) { $actions[$action->aid] = $action->parameters ? unserialize($action->parameters) : array(); $actions[$action->aid]['callback'] = $action->callback; @@ -91,7 +91,7 @@ function actions_do($action_ids, $object else { // If it's a configurable action, retrieve stored parameters. if (is_numeric($action_ids)) { - $action = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $action_ids)); + $action = db_fetch_object(db_query("SELECT * FROM [{actions}] WHERE [aid] = %s", $action_ids)); $function = $action->callback; $context = array_merge($context, unserialize($action->parameters)); $result[$action_ids] = $function($object, $context, $a1, $a2); @@ -175,7 +175,7 @@ function actions_list($reset = FALSE) { */ function actions_get_all_actions() { $actions = array(); - $result = db_query("SELECT * FROM {actions}"); + $result = db_query("SELECT * FROM [{actions}]"); while ($action = db_fetch_object($result)) { $actions[$action->aid] = array( 'callback' => $action->callback, @@ -236,7 +236,7 @@ function actions_function_lookup($hash) } // Must be an instance; must check database. - $aid = db_result(db_query("SELECT aid FROM {actions} WHERE MD5(aid) = '%s' AND parameters <> ''", $hash)); + $aid = db_result(db_query("SELECT [aid] FROM [{actions}] WHERE MD5([aid]) = %s AND [parameters] <> %s", $hash, '')); return $aid; } @@ -253,7 +253,7 @@ function actions_synchronize($actions_in $actions_in_code = actions_list(TRUE); } $actions_in_db = array(); - $result = db_query("SELECT * FROM {actions} WHERE parameters = ''"); + $result = db_query("SELECT * FROM [{actions}] WHERE [parameters] = %s", ''); while ($action = db_fetch_object($result)) { $actions_in_db[$action->callback] = array('aid' => $action->aid, 'description' => $action->description); } @@ -269,7 +269,7 @@ function actions_synchronize($actions_in } else { // This is a new singleton that we don't have an aid for; assign one. - db_query("INSERT INTO {actions} (aid, type, callback, parameters, description) VALUES ('%s', '%s', '%s', '%s', '%s')", $callback, $array['type'], $callback, '', $array['description']); + db_query("INSERT INTO [{actions}] ([aid], [type], [callback], [parameters], [description]) VALUES (%s, %s, %s, %s, %s)", $callback, $array['type'], $callback, '', $array['description']); watchdog('actions', "Action '%action' added.", array('%action' => filter_xss_admin($array['description']))); } } @@ -282,14 +282,14 @@ function actions_synchronize($actions_in foreach ($actions_in_db as $callback => $array) { $orphaned[] = $callback; - $placeholder[] = "'%s'"; + $placeholder[] = "%s"; } $orphans = implode(', ', $orphaned); if ($delete_orphans) { $placeholders = implode(', ', $placeholder); - $results = db_query("SELECT a.aid, a.description FROM {actions} a WHERE callback IN ($placeholders)", $orphaned); + $results = db_query("SELECT a.[aid], a.[description] FROM [{actions}] a WHERE [callback] IN ($placeholders)", $orphaned); while ($action = db_fetch_object($results)) { actions_delete($action->aid); watchdog('actions', "Removed orphaned action '%action' from database.", array('%action' => filter_xss_admin($action->description))); @@ -323,15 +323,15 @@ function actions_synchronize($actions_in function actions_save($function, $type, $params, $desc, $aid = NULL) { $serialized = serialize($params); if ($aid) { - db_query("UPDATE {actions} SET callback = '%s', type = '%s', parameters = '%s', description = '%s' WHERE aid = '%s'", $function, $type, $serialized, $desc, $aid); + db_query("UPDATE [{actions}] SET [callback] = %s, [type] = %s, [parameters] = %s, [description] = %s WHERE [aid] = %s", $function, $type, $serialized, $desc, $aid); watchdog('actions', 'Action %action saved.', array('%action' => $desc)); } else { // aid is the callback for singleton actions so we need to keep a // separate table for numeric aids. - db_query('INSERT INTO {actions_aid} VALUES (default)'); + db_query('INSERT INTO [{actions_aid}] VALUES (DEFAULT)'); $aid = db_last_insert_id('actions_aid', 'aid'); - db_query("INSERT INTO {actions} (aid, callback, type, parameters, description) VALUES ('%s', '%s', '%s', '%s', '%s')", $aid, $function, $type, $serialized, $desc); + db_query("INSERT INTO [{actions}] ([aid], [callback], [type], [parameters], [description]) VALUES (%s, %s, %s, %s, %s)", $aid, $function, $type, $serialized, $desc); watchdog('actions', 'Action %action created.', array('%action' => $desc)); } @@ -348,7 +348,7 @@ function actions_save($function, $type, * The appropriate action row from the database as an object. */ function actions_load($aid) { - return db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $aid)); + return db_fetch_object(db_query("SELECT * FROM [{actions}] WHERE [aid] = %s", $aid)); } /** @@ -358,6 +358,6 @@ function actions_load($aid) { * integer The ID of the action to delete. */ function actions_delete($aid) { - db_query("DELETE FROM {actions} WHERE aid = '%s'", $aid); + db_query("DELETE FROM [{actions}] WHERE [aid] = %s", $aid); module_invoke_all('actions_delete', $aid); } Index: includes/batch.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/batch.inc,v retrieving revision 1.21 diff -u -p -r1.21 batch.inc --- includes/batch.inc 20 Sep 2008 20:22:23 -0000 1.21 +++ includes/batch.inc 22 Sep 2008 09:06:47 -0000 @@ -12,7 +12,7 @@ function _batch_page() { $batch =& batch_get(); // Retrieve the current state of batch from db. - if (isset($_REQUEST['id']) && $data = db_result(db_query("SELECT batch FROM {batch} WHERE bid = %d AND token = '%s'", $_REQUEST['id'], drupal_get_token($_REQUEST['id'])))) { + if (isset($_REQUEST['id']) && $data = db_result(db_query("SELECT [batch] FROM [{batch}] WHERE [bid] = %d AND [token] = %s", $_REQUEST['id'], drupal_get_token($_REQUEST['id'])))) { $batch = unserialize($data); } else { @@ -314,7 +314,7 @@ function _batch_finished() { // Cleanup the batch table and unset the global $batch variable. if ($batch['progressive']) { - db_query("DELETE FROM {batch} WHERE bid = %d", $batch['id']); + db_query("DELETE FROM [{batch}] WHERE [bid] = %d", $batch['id']); } $_batch = $batch; $batch = NULL; @@ -358,6 +358,6 @@ function _batch_finished() { */ function _batch_shutdown() { if ($batch = batch_get()) { - db_query("UPDATE {batch} SET batch = '%s' WHERE bid = %d", serialize($batch), $batch['id']); + db_query("UPDATE [{batch}] SET [batch] = %s WHERE [bid] = %d", serialize($batch), $batch['id']); } } Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.228 diff -u -p -r1.228 bootstrap.inc --- includes/bootstrap.inc 20 Sep 2008 20:22:23 -0000 1.228 +++ includes/bootstrap.inc 22 Sep 2008 09:06:47 -0000 @@ -445,7 +445,7 @@ function drupal_get_filename($type, $nam // the database. This is required because this function is called both // before we have a database connection (i.e. during installation) and // when a database connection fails. - elseif (db_is_active() && (($file = db_result(db_query("SELECT filename FROM {system} WHERE name = '%s' AND type = '%s'", $name, $type))) && file_exists($file))) { + elseif (db_is_active() && (($file = db_result(db_query("SELECT [filename] FROM [{system}] WHERE [name] = %s AND [type] = %s", $name, $type))) && file_exists($file))) { $files[$type][$name] = $file; } else { @@ -481,7 +481,7 @@ function variable_init($conf = array()) $variables = $cached->data; } else { - $result = db_query('SELECT * FROM {variable}'); + $result = db_query('SELECT * FROM [{variable}]'); while ($variable = db_fetch_object($result)) { $variables[$variable->name] = unserialize($variable->value); } @@ -539,7 +539,7 @@ function variable_set($name, $value) { function variable_del($name) { global $conf; - db_query("DELETE FROM {variable} WHERE name = '%s'", $name); + db_query("DELETE FROM [{variable}] WHERE [name] = %s", $name); cache_clear_all('variables', 'cache'); unset($conf[$name]); @@ -924,7 +924,7 @@ function drupal_is_denied($ip) { return in_array($ip, $blocked_ips); } else { - $sql = "SELECT 1 FROM {blocked_ips} WHERE ip = '%s'"; + $sql = "SELECT 1 FROM [{blocked_ips}] WHERE [ip] = %s"; return (bool) db_result(db_query($sql, $ip)); } } @@ -1142,7 +1142,7 @@ function language_list($field = 'languag // Init language list if (!isset($languages)) { if (variable_get('language_count', 1) > 1 || module_exists('locale')) { - $result = db_query('SELECT * FROM {languages} ORDER BY weight ASC, name ASC'); + $result = db_query('SELECT * FROM [{languages}] ORDER BY [weight] ASC, [name] ASC'); while ($row = db_fetch_object($result)) { $languages['language'][$row->language] = $row; } @@ -1340,7 +1340,7 @@ function drupal_function_exists($functio return TRUE; } - $file = db_result(db_query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(':name' => $function, ':type' => 'function'))); + $file = db_result(db_query("SELECT [filename] FROM [{registry}] WHERE [name] = :name AND [type] = :type", array(':name' => $function, ':type' => 'function'))); if ($file) { require_once DRUPAL_ROOT . '/' . $file; $checked[$function] = function_exists($function); @@ -1388,7 +1388,7 @@ function drupal_autoload_class($class) { * Helper for registry_check_{interface, class}. */ function _registry_check_code($type, $name) { - $file = db_result(db_query("SELECT filename FROM {registry} WHERE name = :name AND type = :type", array(':name' => $name, ':type' => $type))); + $file = db_result(db_query("SELECT [filename] FROM [{registry}] WHERE [name] = :name AND [type] = :type", array(':name' => $name, ':type' => $type))); if ($file) { require_once DRUPAL_ROOT . '/' . $file; registry_mark_code($type, $name); @@ -1468,11 +1468,11 @@ function registry_cache_path_files() { $type_sql = array(); $params = array(); foreach ($used_code as $type => $names) { - $type_sql[] = "(name IN (" . db_placeholders($names, 'varchar') . ") AND type = '%s')"; + $type_sql[] = "([name] IN (" . db_placeholders($names, 'varchar') . ") AND [type] = %s)"; $params = array_merge($params, $names); $params[] = $type; } - $res = db_query("SELECT DISTINCT filename FROM {registry} WHERE " . implode(' OR ', $type_sql), $params); + $res = db_query("SELECT DISTINCT [filename] FROM [{registry}] WHERE " . implode(' OR ', $type_sql), $params); while ($row = db_fetch_object($res)) { $files[] = $row->filename; } Index: includes/cache.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/cache.inc,v retrieving revision 1.24 diff -u -p -r1.24 cache.inc --- includes/cache.inc 17 Sep 2008 07:11:55 -0000 1.24 +++ includes/cache.inc 22 Sep 2008 09:06:47 -0000 @@ -2,15 +2,15 @@ // $Id: cache.inc,v 1.24 2008/09/17 07:11:55 dries Exp $ /** - * Return data from the persistent cache. Data may be stored as either plain - * text or as serialized data. cache_get will automatically return + * Return data from the persistent cache. Data may be stored as either plain + * text or as serialized data. cache_get will automatically return * unserialized objects and arrays. * * @param $cid * The cache ID of the data to retrieve. * @param $table - * The table $table to store the data in. Valid core values are - * 'cache_filter', 'cache_menu', 'cache_page', or 'cache' for + * The table $table to store the data in. Valid core values are + * 'cache_filter', 'cache_menu', 'cache_page', or 'cache' for * the default cache. * @return The cache or FALSE on failure. */ @@ -23,10 +23,10 @@ function cache_get($cid, $table = 'cache // Reset the variable immediately to prevent a meltdown in heavy load situations. variable_set('cache_flush', 0); // Time to flush old cache data - db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire <= %d", CACHE_PERMANENT, $cache_flush); + db_query("DELETE FROM [{" . $table . "}] WHERE [expire] <> %d AND [expire] <= %d", CACHE_PERMANENT, $cache_flush); } - $cache = db_fetch_object(db_query("SELECT data, created, headers, expire, serialized FROM {" . $table . "} WHERE cid = '%s'", $cid)); + $cache = db_fetch_object(db_query("SELECT [data], [created], [headers], [expire], [serialized] FROM [{" . $table . "}] WHERE [cid] = %s", $cid)); if (isset($cache->data)) { // If the data is permanent or we're not enforcing a minimum cache lifetime // always return the cached data. @@ -84,11 +84,11 @@ function cache_get($cid, $table = 'cache * @param $cid * The cache ID of the data to store. * @param $data - * The data to store in the cache. Complex data types will be automatically + * The data to store in the cache. Complex data types will be automatically * serialized before insertion. * Strings will be stored as plain text and not serialized. * @param $table - * The table $table to store the data in. Valid core values are + * The table $table to store the data in. Valid core values are * 'cache_filter', 'cache_menu', 'cache_page', or 'cache'. * @param $expire * One of the following values: @@ -165,13 +165,13 @@ function cache_clear_all($cid = NULL, $t else if (REQUEST_TIME > ($cache_flush + variable_get('cache_lifetime', 0))) { // Clear the cache for everyone, cache_flush_delay seconds have // passed since the first request to clear the cache. - db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, REQUEST_TIME); + db_query("DELETE FROM [{" . $table . "}] WHERE [expire] <> %d AND [expire] < %d", CACHE_PERMANENT, REQUEST_TIME); variable_set('cache_flush', 0); } } else { // No minimum cache lifetime, flush all temporary cache entries now. - db_query("DELETE FROM {" . $table . "} WHERE expire != %d AND expire < %d", CACHE_PERMANENT, REQUEST_TIME); + db_query("DELETE FROM [{" . $table . "}] WHERE [expire] <> %d AND [expire] < %d", CACHE_PERMANENT, REQUEST_TIME); } } else { @@ -180,7 +180,7 @@ function cache_clear_all($cid = NULL, $t db_delete($table)->execute(); } else { - db_delete($table)->condition('cid', $cid .'%', 'LIKE')->execute(); + db_delete($table)->condition('cid', $cid . '%', 'LIKE')->execute(); } } else { Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.799 diff -u -p -r1.799 common.inc --- includes/common.inc 20 Sep 2008 20:22:23 -0000 1.799 +++ includes/common.inc 22 Sep 2008 09:06:47 -0000 @@ -648,7 +648,7 @@ function _drupal_get_last_caller($backtr // The first trace is the call itself. // It gives us the line and the file of the last call. $call = $backtrace[0]; - + // The second call give us the function where the call originated. if (isset($backtrace[1])) { if (isset($backtrace[1]['class'])) { @@ -907,7 +907,7 @@ function valid_url($url, $absolute = FAL * The name of an event. */ function flood_register_event($name) { - db_query("INSERT INTO {flood} (event, hostname, timestamp) VALUES ('%s', '%s', %d)", $name, ip_address(), REQUEST_TIME); + db_query("INSERT INTO [{flood}] ([event], [hostname], [timestamp]) VALUES (%s, %s, %d)", $name, ip_address(), REQUEST_TIME); } /** @@ -924,7 +924,7 @@ function flood_register_event($name) { * True if the user did not exceed the hourly threshold. False otherwise. */ function flood_is_allowed($name, $threshold) { - $number = db_result(db_query("SELECT COUNT(*) FROM {flood} WHERE event = '%s' AND hostname = '%s' AND timestamp > %d", $name, ip_address(), REQUEST_TIME - 3600)); + $number = db_result(db_query("SELECT COUNT(*) FROM [{flood}] WHERE [event] = %s AND [hostname] = %s AND [timestamp] > %d", $name, ip_address(), REQUEST_TIME - 3600)); return ($number < $threshold ? TRUE : FALSE); } @@ -3223,12 +3223,12 @@ function drupal_schema_fields_sql($table if ($prefix) { $columns = array(); foreach ($fields as $field) { - $columns[] = "$prefix.$field"; + $columns[] = "$prefix.[$field]"; } return $columns; } else { - return $fields; + return '[' . $fields . ']'; } } @@ -3326,7 +3326,7 @@ function drupal_write_record($table, &$o // Build the SQL. $query = ''; if (!count($update)) { - $query = "INSERT INTO {" . $table . "} (" . implode(', ', $fields) . ') VALUES (' . implode(', ', $placeholders) . ')'; + $query = "INSERT INTO [{" . $table . "}] ([" . implode('], [', $fields) . ']) VALUES (' . implode(', ', $placeholders) . ')'; $return = SAVED_NEW; } else { @@ -3335,15 +3335,15 @@ function drupal_write_record($table, &$o if ($query) { $query .= ', '; } - $query .= $field . ' = ' . $placeholders[$id]; + $query .= '[' . $field . '] = ' . $placeholders[$id]; } foreach ($update as $key){ - $conditions[] = "$key = " . db_type_placeholder($schema['fields'][$key]['type']); + $conditions[] = "[$key] = " . db_type_placeholder($schema['fields'][$key]['type']); $values[] = $object->$key; } - $query = "UPDATE {" . $table . "} SET $query WHERE " . implode(' AND ', $conditions); + $query = "UPDATE [{" . $table . "}] SET $query WHERE " . implode(' AND ', $conditions); $return = SAVED_UPDATED; } Index: includes/file.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/file.inc,v retrieving revision 1.135 diff -u -p -r1.135 file.inc --- includes/file.inc 20 Sep 2008 03:49:23 -0000 1.135 +++ includes/file.inc 22 Sep 2008 09:06:47 -0000 @@ -510,9 +510,9 @@ function file_delete($path) { */ function file_space_used($uid = NULL, $status = FILE_STATUS_PERMANENT) { if (!is_null($uid)) { - return (int)db_result(db_query('SELECT SUM(filesize) FROM {files} WHERE uid = %d AND status & %d', array($uid, $status))); + return (int)db_result(db_query('SELECT SUM([filesize]) FROM [{files}] WHERE [uid] = %d AND [status] & %d', array($uid, $status))); } - return (int)db_result(db_query('SELECT SUM(filesize) FROM {files} WHERE status & %d', array($status))); + return (int)db_result(db_query('SELECT SUM([filesize]) FROM [{files}] WHERE [status] & %d', array($status))); } /** @@ -878,7 +878,7 @@ function file_save_data($data, $destinat * error. */ function file_set_status($file, $status = FILE_STATUS_PERMANENT) { - if (db_query('UPDATE {files} SET status = %d WHERE fid = %d', array($status, $file->fid))) { + if (db_query('UPDATE [{files}] SET [status] = %d WHERE [fid] = %d', array($status, $file->fid))) { $file->status = $status; return TRUE; } Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.287 diff -u -p -r1.287 form.inc --- includes/form.inc 21 Sep 2008 06:34:41 -0000 1.287 +++ includes/form.inc 22 Sep 2008 09:06:48 -0000 @@ -2488,7 +2488,7 @@ function batch_process($redirect = NULL, // Initiate db storage in order to get a batch id. We have to provide // at least an empty string for the (not null) 'token' column. - db_query("INSERT INTO {batch} (token, timestamp) VALUES ('', %d)", REQUEST_TIME); + db_query("INSERT INTO [{batch}] ([token], [timestamp]) VALUES (%s, %d)", '', REQUEST_TIME); $batch['id'] = db_last_insert_id('batch', 'bid'); // Now that we have a batch id, we can generate the redirection link in @@ -2497,7 +2497,7 @@ function batch_process($redirect = NULL, $batch['error_message'] = $t('Please continue to the error page', array('@error_url' => url($url, array('query' => array('id' => $batch['id'], 'op' => 'finished'))))); // Actually store the batch data and the token generated form the batch id. - db_query("UPDATE {batch} SET token = '%s', batch = '%s' WHERE bid = %d", drupal_get_token($batch['id']), serialize($batch), $batch['id']); + db_query("UPDATE [{batch}] SET [token] = %s, [batch] = %s WHERE [bid] = %d", drupal_get_token($batch['id']), serialize($batch), $batch['id']); drupal_goto($batch['url'], 'op=start&id=' . $batch['id']); } Index: includes/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.inc,v retrieving revision 1.70 diff -u -p -r1.70 install.inc --- includes/install.inc 20 Sep 2008 20:22:23 -0000 1.70 +++ includes/install.inc 22 Sep 2008 09:06:48 -0000 @@ -88,7 +88,7 @@ function drupal_load_updates() { * @param $module * A module name. * @return - * If the module has updates, an array of available updates sorted by version. + * If the module has updates, an array of available updates sorted by version. * Otherwise, FALSE. */ function drupal_get_schema_versions($module) { @@ -105,10 +105,10 @@ function drupal_get_schema_versions($mod if (count($updates) == 0) { return FALSE; } - + // Make sure updates are run in numeric order, not in definition order. sort($updates, SORT_NUMERIC); - + return $updates; } @@ -134,7 +134,7 @@ function drupal_get_installed_schema_ver if (!$versions) { $versions = array(); - $result = db_query("SELECT name, schema_version FROM {system} WHERE type = '%s'", 'module'); + $result = db_query("SELECT [name], [schema_version] FROM [{system}] WHERE [type] = %s", 'module'); while ($row = db_fetch_object($result)) { $versions[$row->name] = $row->schema_version; } @@ -152,7 +152,7 @@ function drupal_get_installed_schema_ver * The new schema version. */ function drupal_set_installed_schema_version($module, $version) { - db_query("UPDATE {system} SET schema_version = %d WHERE name = '%s'", $version, $module); + db_query("UPDATE [{system}] SET [schema_version] = %d WHERE [name] = %s", $version, $module); } /** @@ -231,7 +231,7 @@ function drupal_detect_database_types() unset($databases['mysql']); $databases = array('mysql' => $mysql_database) + $databases; } - + return $databases; } @@ -239,28 +239,28 @@ abstract class DatabaseInstaller { protected $success = array(); protected $tests = array( 'testCreate' => array( - 'query' => 'CREATE TABLE drupal_install_test (id int NULL)', + 'query' => 'CREATE TABLE [drupal_install_test] ([id] INT NULL)', 'success' => 'CREATE', 'message' => 'Failed to create a test table on your %name database server with the command %query. %name reports the following message: %error.For more help, see the Installation and upgrading handbook. If you are unsure what these terms mean you should probably contact your hosting provider.', 'fatal' => TRUE, ), 'testInsert' => array( - 'query' => 'INSERT INTO drupal_install_test (id) VALUES (1)', + 'query' => 'INSERT INTO [drupal_install_test] ([id]) VALUES (1)', 'success' => 'INSERT', 'message' => 'Failed to insert a value into a test table on your %name database server. We tried inserting a value with the command %query and %name reported the following error: %error.', ), 'testUpdate' => array( - 'query' => 'UPDATE drupal_install_test SET id = 2', + 'query' => 'UPDATE [drupal_install_test] SET [id] = 2', 'success' => 'UPDATE', 'message' => 'Failed to update a value in a test table on your %name database server. We tried updating a value with the command %query and %name reported the following error: %error.', ), 'testDelete' => array( - 'query' => 'DELETE FROM drupal_install_test', + 'query' => 'DELETE FROM [drupal_install_test]', 'success' => 'DELETE', 'message' => 'Failed to delete a value from a test table on your %name database server. We tried deleting a value with the command %query and %name reported the following error: %error.', ), 'testDrop' => array( - 'query' => 'DROP TABLE drupal_install_test', + 'query' => 'DROP TABLE [drupal_install_test]', 'success' => 'DELETE', 'message' => 'Failed to drop a test table from your %name database server. We tried dropping a table with the command %query and %name reported the following error %error.', ), @@ -517,7 +517,7 @@ function _drupal_install_module($module) */ function drupal_install_init_database() { static $included = FALSE; - + if (!$included) { $connection_info = Database::getConnectionInfo(); $driver = $connection_info['default']['driver']; @@ -541,10 +541,10 @@ function drupal_install_system() { require_once DRUPAL_ROOT . '/' . $system_path . '/system.install'; drupal_install_init_database(); module_invoke('system', 'install'); - + $system_versions = drupal_get_schema_versions('system'); $system_version = $system_versions ? max($system_versions) : SCHEMA_INSTALLED; - db_query("INSERT INTO {system} (filename, name, type, owner, status, bootstrap, schema_version) VALUES('%s', '%s', '%s', '%s', %d, %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, 0, $system_version); + db_query("INSERT INTO [{system}] ([filename], [name], [type], [owner], [status], [bootstrap], [schema_version]) VALUES(%s, %s, %s, %s, %d, %d, %d)", $system_path . '/system.module', 'system', 'module', '', 1, 0, $system_version); // Now that we've installed things properly, bootstrap the full Drupal environment drupal_install_init_database(); drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); @@ -580,9 +580,9 @@ function drupal_uninstall_module($module } $paths[$index] = implode('/', $parts); } - $placeholders = implode(', ', array_fill(0, count($paths), "'%s'")); + $placeholders = implode(', ', array_fill(0, count($paths), "%s")); - $result = db_query('SELECT * FROM {menu_links} WHERE router_path IN (' . $placeholders . ') AND external = 0 ORDER BY depth DESC', $paths); + $result = db_query('SELECT * FROM [{menu_links}] WHERE [router_path] IN (' . $placeholders . ') AND [external] = 0 ORDER BY [depth] DESC', $paths); // Remove all such items. Starting from those with the greatest depth will // minimize the amount of re-parenting done by menu_link_delete(). while ($item = db_fetch_array($result)) { @@ -790,7 +790,7 @@ function drupal_install_fix_file($file, /** - * Send the user to a different installer page. + * Send the user to a different installer page. * * This issues an on-site HTTP redirect. Messages (and errors) are erased. * @@ -889,7 +889,7 @@ function drupal_check_profile($profile) * Extract highest severity from requirements array. * * @param $requirements - * An array of requirements, in the same format as is returned by + * An array of requirements, in the same format as is returned by * hook_requirements(). * @return * The highest severity in the array. Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.186 diff -u -p -r1.186 locale.inc --- includes/locale.inc 20 Sep 2008 20:22:23 -0000 1.186 +++ includes/locale.inc 22 Sep 2008 09:06:48 -0000 @@ -119,7 +119,7 @@ function locale_languages_overview_form_ $language->enabled = 0; } $language->weight = $form_state['values']['weight'][$langcode]; - db_query("UPDATE {languages} SET enabled = %d, weight = %d WHERE language = '%s'", $language->enabled, $language->weight, $langcode); + db_query("UPDATE [{languages}] SET [enabled] = %d, [weight] = %d WHERE [language] = %s", $language->enabled, $language->weight, $langcode); $languages[$langcode] = $language; } drupal_set_message(t('Configuration saved.')); @@ -198,7 +198,7 @@ function locale_languages_custom_form() * Language code of the language to edit. */ function locale_languages_edit_form(&$form_state, $langcode) { - if ($language = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $langcode))) { + if ($language = db_fetch_object(db_query("SELECT * FROM [{languages}] WHERE [language] = %s", $langcode))) { $form = array(); _locale_languages_common_controls($form, $language); $form['submit'] = array( @@ -290,7 +290,7 @@ function _locale_languages_common_contro function locale_languages_predefined_form_validate($form, &$form_state) { $langcode = $form_state['values']['langcode']; - if ($duplicate = db_result(db_query("SELECT COUNT(*) FROM {languages} WHERE language = '%s'", $langcode)) != 0) { + if ($duplicate = db_result(db_query("SELECT COUNT(*) FROM [{languages}] WHERE [language] = %s", $langcode)) != 0) { form_set_error('langcode', t('The language %language (%code) already exists.', array('%language' => $form_state['values']['name'], '%code' => $langcode))); } @@ -341,13 +341,13 @@ function locale_languages_edit_form_vali if (!empty($form_state['values']['domain']) && !empty($form_state['values']['prefix'])) { form_set_error('prefix', t('Domain and path prefix values should not be set at the same time.')); } - if (!empty($form_state['values']['domain']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE domain = '%s' AND language <> '%s'", $form_state['values']['domain'], $form_state['values']['langcode']))) { + if (!empty($form_state['values']['domain']) && $duplicate = db_fetch_object(db_query("SELECT [language] FROM [{languages}] WHERE [domain] = %s AND [language] <> %s", $form_state['values']['domain'], $form_state['values']['langcode']))) { form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_state['values']['domain'], '%language' => $duplicate->language))); } if (empty($form_state['values']['prefix']) && language_default('language') != $form_state['values']['langcode'] && empty($form_state['values']['domain'])) { form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.')); } - if (!empty($form_state['values']['prefix']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE prefix = '%s' AND language <> '%s'", $form_state['values']['prefix'], $form_state['values']['langcode']))) { + if (!empty($form_state['values']['prefix']) && $duplicate = db_fetch_object(db_query("SELECT [language] FROM [{languages}] WHERE [prefix] = %s AND [language] <> %s", $form_state['values']['prefix'], $form_state['values']['langcode']))) { form_set_error('prefix', t('The prefix (%prefix) is already tied to a language (%language).', array('%prefix' => $form_state['values']['prefix'], '%language' => $duplicate->language))); } } @@ -356,7 +356,7 @@ function locale_languages_edit_form_vali * Process the language editing form submission. */ function locale_languages_edit_form_submit($form, &$form_state) { - db_query("UPDATE {languages} SET name = '%s', native = '%s', domain = '%s', prefix = '%s', direction = %d WHERE language = '%s'", $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['domain'], $form_state['values']['prefix'], $form_state['values']['direction'], $form_state['values']['langcode']); + db_query("UPDATE [{languages}] SET [name] = %s, [native] = %s, [domain] = %s, [prefix] = %s, [direction] = %d WHERE [language] = %s", $form_state['values']['name'], $form_state['values']['native'], $form_state['values']['domain'], $form_state['values']['prefix'], $form_state['values']['direction'], $form_state['values']['langcode']); $default = language_default(); if ($default->language == $form_state['values']['langcode']) { $properties = array('name', 'native', 'direction', 'enabled', 'plurals', 'formula', 'domain', 'prefix', 'weight'); @@ -414,13 +414,13 @@ function locale_languages_delete_form_su $languages = language_list(); if (isset($languages[$form_state['values']['langcode']])) { // Remove translations first. - db_query("DELETE FROM {locales_target} WHERE language = '%s'", $form_state['values']['langcode']); + db_query("DELETE FROM [{locales_target}] WHERE [language] = %s", $form_state['values']['langcode']); cache_clear_all('locale:' . $form_state['values']['langcode'], 'cache'); // With no translations, this removes existing JavaScript translations file. _locale_rebuild_js($form_state['values']['langcode']); // Remove the language. - db_query("DELETE FROM {languages} WHERE language = '%s'", $form_state['values']['langcode']); - db_query("UPDATE {node} SET language = '' WHERE language = '%s'", $form_state['values']['langcode']); + db_query("DELETE FROM [{languages}] WHERE [language] = %s", $form_state['values']['langcode']); + db_query("UPDATE [{node}] SET [language] = %s WHERE [language] = %s", '', $form_state['values']['langcode']); $variables = array('%locale' => $languages[$form_state['values']['langcode']]->name); drupal_set_message(t('The language %locale has been removed.', $variables)); watchdog('locale', 'The language %locale has been removed.', $variables); @@ -492,7 +492,7 @@ function locale_translate_overview_scree $headers = array_merge(array(t('Language')), array_values($groups)); // Collect summaries of all source strings in all groups. - $sums = db_query("SELECT COUNT(*) AS strings, textgroup FROM {locales_source} GROUP BY textgroup"); + $sums = db_query("SELECT COUNT(*) AS [strings], [textgroup] FROM [{locales_source}] GROUP BY [textgroup]"); $groupsums = array(); while ($group = db_fetch_object($sums)) { $groupsums[$group->textgroup] = $group->strings; @@ -508,7 +508,7 @@ function locale_translate_overview_scree } // Languages with at least one record in the locale table. - $translations = db_query("SELECT COUNT(*) AS translation, t.language, s.textgroup FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid GROUP BY textgroup, language"); + $translations = db_query("SELECT COUNT(*) AS [translation], t.[language], s.[textgroup] FROM [{locales_source}] s INNER JOIN [{locales_target}] t ON s.[lid] = t.[lid] GROUP BY [textgroup], [language]"); while ($data = db_fetch_object($translations)) { $ratio = (!empty($groupsums[$data->textgroup]) && $data->translation > 0) ? round(($data->translation/$groupsums[$data->textgroup])*100., 2) : 0; $rows[$data->language][$data->textgroup] = $data->translation . '/' . $groupsums[$data->textgroup] . " ($ratio%)"; @@ -771,7 +771,7 @@ function locale_translate_export_po_form */ function locale_translate_edit_form(&$form_state, $lid) { // Fetch source string, if possible. - $source = db_fetch_object(db_query('SELECT source, textgroup, location FROM {locales_source} WHERE lid = %d', $lid)); + $source = db_fetch_object(db_query('SELECT [source], [textgroup], [location] FROM [{locales_source}] WHERE [lid] = %d', $lid)); if (!$source) { drupal_set_message(t('String not found.'), 'error'); drupal_goto('admin/build/translate/search'); @@ -818,7 +818,7 @@ function locale_translate_edit_form(&$fo } // Fetch translations and fill in default values in the form. - $result = db_query("SELECT DISTINCT translation, language FROM {locales_target} WHERE lid = %d AND language <> '%s'", $lid, $omit); + $result = db_query("SELECT DISTINCT [translation], [language] FROM [{locales_target}] WHERE [lid] = %d AND [language] <> %s", $lid, $omit); while ($translation = db_fetch_object($result)) { $form['translations'][$translation->language]['#default_value'] = $translation->translation; } @@ -834,19 +834,19 @@ function locale_translate_edit_form(&$fo function locale_translate_edit_form_submit($form, &$form_state) { $lid = $form_state['values']['lid']; foreach ($form_state['values']['translations'] as $key => $value) { - $translation = db_result(db_query("SELECT translation FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key)); + $translation = db_result(db_query("SELECT [translation] FROM [{locales_target}] WHERE [lid] = %d AND [language] = %s", $lid, $key)); if (!empty($value)) { // Only update or insert if we have a value to use. if (!empty($translation)) { - db_query("UPDATE {locales_target} SET translation = '%s' WHERE lid = %d AND language = '%s'", $value, $lid, $key); + db_query("UPDATE [{locales_target}] SET [translation] = %s WHERE [lid] = %d AND [language] = %s", $value, $lid, $key); } else { - db_query("INSERT INTO {locales_target} (lid, translation, language) VALUES (%d, '%s', '%s')", $lid, $value, $key); + db_query("INSERT INTO [{locales_target}] ([lid], [translation], [language]) VALUES (%d, %s, %s)", $lid, $value, $key); } } elseif (!empty($translation)) { // Empty translation entered: remove existing entry from database. - db_query("DELETE FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $key); + db_query("DELETE FROM [{locales_target}] WHERE [lid] = %d AND [language] = %s", $lid, $key); } // Force JavaScript translation file recreation for this language. @@ -875,7 +875,7 @@ function locale_translate_edit_form_subm * String deletion confirmation page. */ function locale_translate_delete_page($lid) { - if ($source = db_fetch_object(db_query('SELECT * FROM {locales_source} WHERE lid = %d', $lid))) { + if ($source = db_fetch_object(db_query('SELECT * FROM [{locales_source}] WHERE [lid] = %d', $lid))) { return drupal_get_form('locale_translate_delete_form', $source); } else { @@ -895,8 +895,8 @@ function locale_translate_delete_form(&$ * Process string deletion submissions. */ function locale_translate_delete_form_submit($form, &$form_state) { - db_query('DELETE FROM {locales_source} WHERE lid = %d', $form_state['values']['lid']); - db_query('DELETE FROM {locales_target} WHERE lid = %d', $form_state['values']['lid']); + db_query('DELETE FROM [{locales_source}] WHERE [lid] = %d', $form_state['values']['lid']); + db_query('DELETE FROM [{locales_target}] WHERE [lid] = %d', $form_state['values']['lid']); // Force JavaScript translation file recreation for all languages. _locale_invalidate_js(); cache_clear_all('locale:', 'cache', TRUE); @@ -948,7 +948,7 @@ function locale_add_language($langcode, $direction = isset($predefined[$langcode][2]) ? $predefined[$langcode][2] : LANGUAGE_LTR; } - db_query("INSERT INTO {languages} (language, name, native, direction, domain, prefix, enabled) VALUES ('%s', '%s', '%s', %d, '%s', '%s', %d)", $langcode, $name, $native, $direction, $domain, $prefix, $enabled); + db_query("INSERT INTO [{languages}] ([language], [name], [native], [direction], [domain], [prefix], [enabled]) VALUES (%s, %s, %s, %d, %s, %s, %d)", $langcode, $name, $native, $direction, $domain, $prefix, $enabled); // Only set it as default if enabled. if ($enabled && $default) { @@ -993,7 +993,7 @@ function _locale_import_po($file, $langc } // Check if we have the language already in the database. - if (!db_fetch_object(db_query("SELECT language FROM {languages} WHERE language = '%s'", $langcode))) { + if (!db_fetch_object(db_query("SELECT [language] FROM [{languages}] WHERE [language] = %s", $langcode))) { drupal_set_message(t('The language selected for import is not supported.'), 'error'); return FALSE; } @@ -1237,10 +1237,10 @@ function _locale_import_one_string($op, // Get the plural formula and update in database. if (isset($header["Plural-Forms"]) && $p = _locale_import_parse_plural_forms($header["Plural-Forms"], $file->filename)) { list($nplurals, $plural) = $p; - db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", $nplurals, $plural, $lang); + db_query("UPDATE [{languages}] SET [plurals] = %d, [formula] = %s WHERE [language] = %s", $nplurals, $plural, $lang); } else { - db_query("UPDATE {languages} SET plurals = %d, formula = '%s' WHERE language = '%s'", 0, '', $lang); + db_query("UPDATE [{languages}] SET [plurals] = %d, [formula] = %s WHERE [language] = %s", 0, '', $lang); } $headerdone = TRUE; } @@ -1302,35 +1302,35 @@ function _locale_import_one_string($op, * The string ID of the existing string modified or the new string added. */ function _locale_import_one_string_db(&$report, $langcode, $source, $translation, $textgroup, $location, $mode, $plid = NULL, $plural = NULL) { - $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup)); + $lid = db_result(db_query("SELECT [lid] FROM [{locales_source}] WHERE [source] = %s AND [textgroup] = %s", $source, $textgroup)); if (!empty($translation)) { if ($lid) { // We have this source string saved already. - db_query("UPDATE {locales_source} SET location = '%s' WHERE lid = %d", $location, $lid); - $exists = (bool) db_result(db_query("SELECT lid FROM {locales_target} WHERE lid = %d AND language = '%s'", $lid, $langcode)); + db_query("UPDATE [{locales_source}] SET [location] = %s WHERE [lid] = %d", $location, $lid); + $exists = (bool) db_result(db_query("SELECT [lid] FROM [{locales_target}] WHERE [lid] = %d AND [language] = %s", $lid, $langcode)); if (!$exists) { // No translation in this language. - db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural); + db_query("INSERT INTO [{locales_target}] ([lid], [language], [translation], [plid], [plural]) VALUES (%d, %s, %s, %d, %d)", $lid, $langcode, $translation, $plid, $plural); $report[0]++; } else if ($mode == LOCALE_IMPORT_OVERWRITE) { // Translation exists, only overwrite if instructed. - db_query("UPDATE {locales_target} SET translation = '%s', plid = %d, plural = %d WHERE language = '%s' AND lid = %d", $translation, $plid, $plural, $langcode, $lid); + db_query("UPDATE [{locales_target}] SET [translation] = %s, [plid] = %d, [plural] = %d WHERE [language] = %s AND [lid] = %d", $translation, $plid, $plural, $langcode, $lid); $report[1]++; } } else { // No such source string in the database yet. - db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', '%s')", $location, $source, $textgroup); - $lid = db_result(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND textgroup = '%s'", $source, $textgroup)); - db_query("INSERT INTO {locales_target} (lid, language, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $langcode, $translation, $plid, $plural); + db_query("INSERT INTO [{locales_source}] ([location], [source], [textgroup]) VALUES (%s, %s, %s)", $location, $source, $textgroup); + $lid = db_result(db_query("SELECT [lid] FROM [{locales_source}] WHERE [source] = %s AND [textgroup] = %s", $source, $textgroup)); + db_query("INSERT INTO [{locales_target}] ([lid], [language], [translation], [plid], [plural]) VALUES (%d, %s, %s, %d, %d)", $lid, $langcode, $translation, $plid, $plural); $report[0]++; } } elseif ($mode == LOCALE_IMPORT_OVERWRITE) { // Empty translation, remove existing if instructed. - db_query("DELETE FROM {locales_target} WHERE language = '%s' AND lid = %d AND plid = %d AND plural = %d", $translation, $langcode, $lid, $plid, $plural); + db_query("DELETE FROM [{locales_target}] WHERE [language] = %s AND [lid] = %d AND [plid] = %d AND [plural] = %d", $translation, $langcode, $lid, $plid, $plural); $report[2]++; } @@ -1666,7 +1666,7 @@ function _locale_parse_js_file($filepath // Remove the quotes and string concatenations from the string. $string = implode('', preg_split('~(?lid); + db_query("UPDATE [{locales_source}] SET [location] = %s WHERE [lid] = %d", $locations, $source->lid); } } else { // We don't have the source string yet, thus we insert it into the database. - db_query("INSERT INTO {locales_source} (location, source, textgroup) VALUES ('%s', '%s', 'default')", $filepath, $string); + db_query("INSERT INTO [{locales_source}] ([location], [source], [textgroup]) VALUES (%s, %s, 'default')", $filepath, $string); } } } @@ -1706,10 +1706,10 @@ function _locale_parse_js_file($filepath */ function _locale_export_get_strings($language = NULL, $group = 'default') { if (isset($language)) { - $result = db_query("SELECT s.lid, s.source, s.location, t.translation, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $language->language, $group); + $result = db_query("SELECT s.[lid], s.[source], s.[location], t.[translation], t.[plid], t.[plural] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = %s WHERE s.[textgroup] = %s ORDER BY t.[plid], t.[plural]", $language->language, $group); } else { - $result = db_query("SELECT s.lid, s.source, s.location, t.plid, t.plural FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid WHERE s.textgroup = '%s' ORDER BY t.plid, t.plural", $group); + $result = db_query("SELECT s.[lid], s.[source], s.[location], t.[plid], t.[plural] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] WHERE s.[textgroup] = %s ORDER BY t.[plid], t.[plural]", $group); } $strings = array(); while ($child = db_fetch_object($result)) { @@ -1937,40 +1937,40 @@ function _locale_translate_seek() { // We have at least one criterion to match if ($query = _locale_translate_seek_query()) { - $join = "SELECT s.source, s.location, s.lid, s.textgroup, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid "; + $join = "SELECT s.[source], s.[location], s.[lid], s.[textgroup], t.[translation], t.[language] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] "; $arguments = array(); $limit_language = FALSE; // Compute LIKE section switch ($query['translation']) { case 'translated': - $where = "WHERE (t.translation LIKE ?)"; - $orderby = "ORDER BY t.translation"; - $arguments[] = '%'. $query['string'] .'%'; + $where = "WHERE (t.[translation] LIKE ?)"; + $orderby = "ORDER BY t.[translation]"; + $arguments[] = '%' . $query['string'] . '%'; break; case 'untranslated': - $where = "WHERE (s.source LIKE ? AND t.translation IS NULL)"; - $orderby = "ORDER BY s.source"; - $arguments[] = '%'. $query['string'] .'%'; + $where = "WHERE (s.[source] LIKE ? AND t.[translation] IS NULL)"; + $orderby = "ORDER BY s.[source]"; + $arguments[] = '%' . $query['string'] . '%'; break; case 'all' : default: - $where = "WHERE (s.source LIKE ? OR t.translation LIKE ?)"; + $where = "WHERE (s.[source] LIKE ? OR t.[translation] LIKE ?)"; $orderby = ''; - $arguments[] = '%'. $query['string'] .'%'; - $arguments[] = '%'. $query['string'] .'%'; + $arguments[] = '%' . $query['string'] . '%'; + $arguments[] = '%' . $query['string'] . '%'; break; } $grouplimit = ''; if (!empty($query['group']) && $query['group'] != 'all') { - $grouplimit = " AND s.textgroup = ?"; + $grouplimit = " AND s.[textgroup] = ?"; $arguments[] = $query['group']; } switch ($query['language']) { // Force search in source strings case "en": - $sql = $join . " WHERE s.source LIKE ? $grouplimit ORDER BY s.source"; + $sql = $join . " WHERE s.[source] LIKE ? $grouplimit ORDER BY s.[source]"; $arguments = array('%' . $query['string'] . '%'); // $where is not used, discard its arguments if (!empty($grouplimit)) { $arguments[] = $query['group']; @@ -1982,7 +1982,7 @@ function _locale_translate_seek() { break; // Some different language default: - $sql = "$join AND t.language = ? $where $grouplimit $orderby"; + $sql = "$join AND t.[language] = ? $where $grouplimit $orderby"; array_unshift($arguments, $query['language']); // Don't show translation flags for other languages, we can't see them with this search. $limit_language = $query['language']; @@ -2092,12 +2092,12 @@ function _locale_rebuild_js($langcode = // Construct the array for JavaScript translations. // We sort on plural so that we have all plural forms before singular forms. - $result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation - FROM {locales_source} s - LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language - WHERE s.location LIKE '%.js%' - AND s.textgroup = 'default' - ORDER BY t.plural DESC", array(':language' => $language->language)); + $result = db_query("SELECT s.[lid], s.[source], t.[plid], t.[plural], t.[translation] + FROM [{locales_source}] s + LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = :language + WHERE s.[location] LIKE '%.js%' + AND s.[textgroup] = 'default' + ORDER BY t.[plural] DESC", array(':language' => $language->language)); $translations = $plurals = array(); while ($data = db_fetch_object($result)) { @@ -2172,14 +2172,14 @@ function _locale_rebuild_js($langcode = // Save the new JavaScript hash (or an empty value if the file // just got deleted). Act only if some operation was executed. if ($status) { - db_query("UPDATE {languages} SET javascript = '%s' WHERE language = '%s'", $language->javascript, $language->language); + db_query("UPDATE [{languages}] SET [javascript] = %s WHERE [language] = %s", $language->javascript, $language->language); // Update the default language variable if the default language has been altered. // This is necessary to keep the variable consistent with the database // version of the language and to prevent checking against an outdated hash. $default_langcode = language_default('language'); if ($default_langcode == $language->language) { - $default = db_fetch_object(db_query("SELECT * FROM {languages} WHERE language = '%s'", $default_langcode)); + $default = db_fetch_object(db_query("SELECT * FROM [{languages}] WHERE [language] = %s", $default_langcode)); variable_set('language_default', $default); } } @@ -2469,9 +2469,9 @@ function locale_batch_by_language($langc // Collect all files to import for all enabled modules and themes. $files = array(); $components = array(); - $query = "SELECT name, filename FROM {system} WHERE status = 1"; + $query = "SELECT [name], [filename] FROM [{system}] WHERE [status] = 1"; if (count($skip)) { - $query .= " AND name NOT IN (" . db_placeholders($skip, 'varchar') . ")"; + $query .= " AND [name] NOT IN (" . db_placeholders($skip, 'varchar') . ")"; } $result = db_query($query, $skip); while ($component = db_fetch_object($result)) { @@ -2504,7 +2504,7 @@ function locale_batch_by_component($comp if (count($languages[1])) { $language_list = join('|', array_keys($languages[1])); // Collect all files to import for all $components. - $result = db_query("SELECT name, filename FROM {system} WHERE status = 1"); + $result = db_query("SELECT [name], [filename] FROM [{system}] WHERE [status] = 1"); while ($component = db_fetch_object($result)) { if (in_array($component->name, $components)) { // Collect all files for this component in all enabled languages, named Index: includes/menu.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/menu.inc,v retrieving revision 1.291 diff -u -p -r1.291 menu.inc --- includes/menu.inc 20 Sep 2008 20:22:23 -0000 1.291 +++ includes/menu.inc 22 Sep 2008 09:06:48 -0000 @@ -279,7 +279,7 @@ function menu_get_ancestors($parts) { $current .= '/'; } } - $placeholders[] = "'%s'"; + $placeholders[] = "%s"; $ancestors[] = $current; } return array($ancestors, $placeholders); @@ -364,7 +364,7 @@ function menu_get_item($path = NULL, $ro $parts = array_slice($original_map, 0, MENU_MAX_PARTS); list($ancestors, $placeholders) = menu_get_ancestors($parts); - if ($router_item = db_fetch_array(db_query_range('SELECT * FROM {menu_router} WHERE path IN (' . implode (',', $placeholders) . ') ORDER BY fit DESC', $ancestors, 0, 1))) { + if ($router_item = db_fetch_array(db_query_range('SELECT * FROM [{menu_router}] WHERE [path] IN (' . implode (',', $placeholders) . ') ORDER BY [fit] DESC', $ancestors, 0, 1))) { $map = _menu_translate($router_item, $original_map); if ($map === FALSE) { $router_items[$path] = FALSE; @@ -855,7 +855,7 @@ function menu_tree_all_data($menu_name = } $args = array_unique($args); $placeholders = implode(', ', array_fill(0, count($args), '%d')); - $where = ' AND ml.plid IN (' . $placeholders . ')'; + $where = ' AND ml.[plid] IN (' . $placeholders . ')'; $parents = $args; $parents[] = $item['mlid']; } @@ -870,10 +870,10 @@ function menu_tree_all_data($menu_name = // LEFT JOIN since there is no match in {menu_router} for an external // link. $data['tree'] = menu_tree_data(db_query(" - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* - FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path - WHERE ml.menu_name = '%s'" . $where . " - ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents); + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], m.[description], ml.* + FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] + WHERE ml.[menu_name] = %s" . $where . " + ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC", $args), $parents); $data['node_links'] = array(); menu_tree_collect_node_links($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. @@ -932,17 +932,17 @@ function menu_tree_page_data($menu_name if ($item['access']) { // Check whether a menu link exists that corresponds to the current path. $args = array($menu_name, $item['href']); - $placeholders = "'%s'"; + $placeholders = "%s"; if (drupal_is_front_page()) { $args[] = ''; - $placeholders .= ", '%s'"; + $placeholders .= ", %s"; } - $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path IN (" . $placeholders . ")", $args)); + $parents = db_fetch_array(db_query("SELECT [p1], [p2], [p3], [p4], [p5], [p6], [p7], [p8] FROM [{menu_links}] WHERE [menu_name] = %s AND [link_path] IN (" . $placeholders . ")", $args)); if (empty($parents)) { // If no link exists, we may be on a local task that's not in the links. // TODO: Handle the case like a local task on a specific node in the menu. - $parents = db_fetch_array(db_query("SELECT p1, p2, p3, p4, p5, p6, p7, p8 FROM {menu_links} WHERE menu_name = '%s' AND link_path = '%s'", $menu_name, $item['tab_root'])); + $parents = db_fetch_array(db_query("SELECT [p1], [p2], [p3], [p4], [p5], [p6], [p7], [p8] FROM [{menu_links}] WHERE [menu_name] = %s AND [link_path] = %s", $menu_name, $item['tab_root'])); } // We always want all the top-level links with plid == 0. $parents[] = '0'; @@ -956,7 +956,7 @@ function menu_tree_page_data($menu_name // Collect all the links set to be expanded, and then add all of // their children to the list as well. do { - $result = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = '%s' AND expanded = 1 AND has_children = 1 AND plid IN (" . $placeholders . ') AND mlid NOT IN (' . $placeholders . ')', array_merge(array($menu_name), $args, $args)); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [menu_name] = %s AND [expanded] = 1 AND [has_children] = 1 AND [plid] IN (" . $placeholders . ') AND [mlid] NOT IN (' . $placeholders . ')', array_merge(array($menu_name), $args, $args)); $num_rows = FALSE; while ($item = db_fetch_array($result)) { $args[] = $item['mlid']; @@ -977,10 +977,10 @@ function menu_tree_page_data($menu_name // LEFT JOIN since there is no match in {menu_router} for an external // link. $data['tree'] = menu_tree_data(db_query(" - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* - FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path - WHERE ml.menu_name = '%s' AND ml.plid IN (" . $placeholders . ") - ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents); + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], m.[description], ml.* + FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] + WHERE ml.[menu_name] = %s AND ml.[plid] IN (" . $placeholders . ") + ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC", $args), $parents); $data['node_links'] = array(); menu_tree_collect_node_links($data['tree'], $data['node_links']); // Cache the data, if it is not already in the cache. @@ -1035,7 +1035,7 @@ function menu_tree_check_access(&$tree, // Use db_rewrite_sql to evaluate view access without loading each full node. $nids = array_keys($node_links); $placeholders = '%d' . str_repeat(', %d', count($nids) - 1); - $result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n WHERE n.status = 1 AND n.nid IN (" . $placeholders . ")"), $nids); + $result = db_query(db_rewrite_sql("SELECT n.[nid] FROM [{node}] n WHERE n.[status] = 1 AND n.[nid] IN (" . $placeholders . ")"), $nids); while ($node = db_fetch_array($result)) { $nid = $node['nid']; foreach ($node_links[$nid] as $mlid => $link) { @@ -1243,7 +1243,7 @@ function menu_get_names($reset = FALSE) if ($reset || empty($names)) { $names = array(); - $result = db_query("SELECT DISTINCT(menu_name) FROM {menu_links} ORDER BY menu_name"); + $result = db_query("SELECT DISTINCT([menu_name]) FROM [{menu_links}] ORDER BY [menu_name]"); while ($name = db_fetch_array($result)) { $names[] = $name['menu_name']; } @@ -1357,7 +1357,7 @@ function menu_local_tasks($level = 0, $r return ''; } // Get all tabs and the root page. - $result = db_query("SELECT * FROM {menu_router} WHERE tab_root = '%s' ORDER BY weight, title", $router_item['tab_root']); + $result = db_query("SELECT * FROM [{menu_router}] WHERE [tab_root] = %s ORDER BY [weight], [title]", $router_item['tab_root']); $map = arg(); $children = array(); $tasks = array(); @@ -1663,7 +1663,7 @@ function menu_get_active_title() { * rendering. */ function menu_link_load($mlid) { - if (is_numeric($mlid) && $item = db_fetch_array(db_query("SELECT m.*, ml.* FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid))) { + if (is_numeric($mlid) && $item = db_fetch_array(db_query("SELECT m.*, ml.* FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] WHERE ml.[mlid] = %d", $mlid))) { _menu_link_translate($item); return $item; } @@ -1788,7 +1788,7 @@ function _menu_navigation_links_rebuild( array_multisort($sort, SORT_NUMERIC, $menu_links); foreach ($menu_links as $item) { - $existing_item = db_fetch_array(db_query("SELECT mlid, menu_name, plid, customized, has_children, updated FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", $item['link_path'], 'system')); + $existing_item = db_fetch_array(db_query("SELECT [mlid], [menu_name], [plid], [customized], [has_children], [updated] FROM [{menu_links}] WHERE [link_path] = %s AND [module] = %s", $item['link_path'], 'system')); if ($existing_item) { $item['mlid'] = $existing_item['mlid']; // A change in hook_menu may move the link to a different menu @@ -1807,18 +1807,18 @@ function _menu_navigation_links_rebuild( $placeholders = db_placeholders($menu, 'varchar'); $paths = array_keys($menu); // Updated and customized items whose router paths are gone need new ones. - $result = db_query("SELECT ml.link_path, ml.mlid, ml.router_path, ml.updated FROM {menu_links} ml WHERE ml.updated = 1 OR (router_path NOT IN ($placeholders) AND external = 0 AND customized = 1)", $paths); + $result = db_query("SELECT ml.[link_path], ml.[mlid], ml.[router_path], ml.[updated] FROM [{menu_links}] ml WHERE ml.[updated] = 1 OR ([router_path] NOT IN ($placeholders) AND [external] = 0 AND [customized] = 1)", $paths); while ($item = db_fetch_array($result)) { $router_path = _menu_find_router_path($menu, $item['link_path']); if (!empty($router_path) && ($router_path != $item['router_path'] || $item['updated'])) { // If the router path and the link path matches, it's surely a working // item, so we clear the updated flag. $updated = $item['updated'] && $router_path != $item['link_path']; - db_query("UPDATE {menu_links} SET router_path = '%s', updated = %d WHERE mlid = %d", $router_path, $updated, $item['mlid']); + db_query("UPDATE [{menu_links}] SET [router_path] = %s, [updated] = %d WHERE [mlid] = %d", $router_path, $updated, $item['mlid']); } } // Find any item whose router path does not exist any more. - $result = db_query("SELECT * FROM {menu_links} WHERE router_path NOT IN ($placeholders) AND external = 0 AND updated = 0 AND customized = 0 ORDER BY depth DESC", $paths); + $result = db_query("SELECT * FROM [{menu_links}] WHERE [router_path] NOT IN ($placeholders) AND [external] = 0 AND [updated] = 0 AND [customized] = 0 ORDER BY [depth] DESC", $paths); // Remove all such items. Starting from those with the greatest depth will // minimize the amount of re-parenting done by menu_link_delete(). while ($item = db_fetch_array($result)) { @@ -1836,10 +1836,10 @@ function _menu_navigation_links_rebuild( */ function menu_link_delete($mlid, $path = NULL) { if (isset($mlid)) { - _menu_delete_item(db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $mlid))); + _menu_delete_item(db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [mlid] = %d", $mlid))); } else { - $result = db_query("SELECT * FROM {menu_links} WHERE link_path = '%s'", $path); + $result = db_query("SELECT * FROM [{menu_links}] WHERE [link_path] = %s", $path); while ($link = db_fetch_array($result)) { _menu_delete_item($link); } @@ -1858,14 +1858,14 @@ function _menu_delete_item($item, $force if ($item && ($item['module'] != 'system' || $item['updated'] || $force)) { // Children get re-attached to the item's parent. if ($item['has_children']) { - $result = db_query("SELECT mlid FROM {menu_links} WHERE plid = %d", $item['mlid']); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [plid] = %d", $item['mlid']); while ($m = db_fetch_array($result)) { $child = menu_link_load($m['mlid']); $child['plid'] = $item['plid']; menu_link_save($child); } } - db_query('DELETE FROM {menu_links} WHERE mlid = %d', $item['mlid']); + db_query('DELETE FROM [{menu_links}] WHERE [mlid] = %d', $item['mlid']); // Update the has_children status of the parent. _menu_update_parental_status($item); @@ -1888,7 +1888,7 @@ function _menu_delete_item($item, $force * - plid The mlid of the parent. * - router_path The path of the relevant router item. * @return - * The mlid of the saved menu link, or FALSE if the menu link could not be + * The mlid of the saved menu link, or FALSE if the menu link could not be * saved. */ function menu_link_save(&$item) { @@ -1914,34 +1914,34 @@ function menu_link_save(&$item) { ); $existing_item = FALSE; if (isset($item['mlid'])) { - $existing_item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['mlid'])); + $existing_item = db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [mlid] = %d", $item['mlid'])); } if (isset($item['plid'])) { - $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['plid'])); + $parent = db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [mlid] = %d", $item['plid'])); } else { // Find the parent - it must be unique. $parent_path = $item['link_path']; - $where = "WHERE link_path = '%s'"; + $where = "WHERE [link_path] = %s"; // Only links derived from router items should have module == 'system', and // we want to find the parent even if it's in a different menu. if ($item['module'] == 'system') { - $where .= " AND module = '%s'"; + $where .= " AND [module] = %s"; $arg2 = 'system'; } else { // If not derived from a router item, we respect the specified menu name. - $where .= " AND menu_name = '%s'"; + $where .= " AND [menu_name] = %s"; $arg2 = $item['menu_name']; } do { $parent = FALSE; $parent_path = substr($parent_path, 0, strrpos($parent_path, '/')); - $result = db_query("SELECT COUNT(*) FROM {menu_links} " . $where, $parent_path, $arg2); + $result = db_query("SELECT COUNT(*) FROM [{menu_links}] " . $where, $parent_path, $arg2); // Only valid if we get a unique result. if (db_result($result) == 1) { - $parent = db_fetch_array(db_query("SELECT * FROM {menu_links} " . $where, $parent_path, $arg2)); + $parent = db_fetch_array(db_query("SELECT * FROM [{menu_links}] " . $where, $parent_path, $arg2)); } } while ($parent === FALSE && $parent_path); } @@ -1959,16 +1959,16 @@ function menu_link_save(&$item) { } if (!$existing_item) { - db_query("INSERT INTO {menu_links} ( - menu_name, plid, link_path, - hidden, external, has_children, - expanded, weight, - module, link_title, options, - customized, updated) VALUES ( - '%s', %d, '%s', + db_query("INSERT INTO [{menu_links}] ( + [menu_name], [plid], [link_path], + [hidden], [external], [has_children], + [expanded], [weight], + [module], [link_title], [options], + [customized], [updated]) VALUES ( + %s, %d, %s, %d, %d, %d, %d, %d, - '%s', '%s', '%s', %d, %d)", + %s, %s, %s, %d, %d)", $item['menu_name'], $item['plid'], $item['link_path'], $item['hidden'], $item['_external'], $item['has_children'], $item['expanded'], $item['weight'], @@ -2014,11 +2014,11 @@ function menu_link_save(&$item) { $item['router_path'] = _menu_find_router_path($menu, $item['link_path']); } } - db_query("UPDATE {menu_links} SET menu_name = '%s', plid = %d, link_path = '%s', - router_path = '%s', hidden = %d, external = %d, has_children = %d, - expanded = %d, weight = %d, depth = %d, - p1 = %d, p2 = %d, p3 = %d, p4 = %d, p5 = %d, p6 = %d, p7 = %d, p8 = %d, p9 = %d, - module = '%s', link_title = '%s', options = '%s', customized = %d WHERE mlid = %d", + db_query("UPDATE [{menu_links}] SET [menu_name] = %s, [plid] = %d, [link_path] = %s, + [router_path] = %s, [hidden] = %d, [external] = %d, [has_children] = %d, + [expanded] = %d, [weight] = %d, [depth] = %d, + [p1] = %d, [p2] = %d, [p3] = %d, [p4] = %d, [p5] = %d, [p6] = %d, [p7] = %d, [p8] = %d, [p9] = %d, + [module] = %s, [link_title] = %s, [options] = %s, [customized] = %d WHERE [mlid] = %d", $item['menu_name'], $item['plid'], $item['link_path'], $item['router_path'], $item['hidden'], $item['_external'], $item['has_children'], $item['expanded'], $item['weight'], $item['depth'], @@ -2062,7 +2062,7 @@ function _menu_clear_page_cache() { */ function _menu_set_expanded_menus() { $names = array(); - $result = db_query("SELECT menu_name FROM {menu_links} WHERE expanded <> 0 GROUP BY menu_name"); + $result = db_query("SELECT [menu_name] FROM [{menu_links}] WHERE [expanded] <> 0 GROUP BY [menu_name]"); while ($n = db_fetch_array($result)) { $names[] = $n['menu_name']; } @@ -2121,8 +2121,8 @@ function menu_link_maintain($module, $op return menu_link_save($menu_link); break; case 'update': - db_query("UPDATE {menu_links} SET link_title = '%s' WHERE link_path = '%s' AND customized = 0 AND module = '%s'", $link_title, $link_path, $module); - $result = db_query("SELECT menu_name FROM {menu_links} WHERE link_path = '%s' AND customized = 0 AND module = '%s'", $link_path, $module); + db_query("UPDATE [{menu_links}] SET [link_title] = %s WHERE [link_path] = %s AND [customized] = 0 AND [module] = %s", $link_title, $link_path, $module); + $result = db_query("SELECT [menu_name] FROM [{menu_links}] WHERE [link_path] = %s AND [customized] = 0 AND [module] = %s", $link_path, $module); while ($item = db_fetch_array($result)) { menu_cache_clear($item['menu_name']); } @@ -2151,12 +2151,12 @@ function menu_link_children_relative_dep $args[] = $item['menu_name']; $p = 'p1'; while ($i <= MENU_MAX_DEPTH && $item[$p]) { - $match .= " AND $p = %d"; + $match .= " AND [$p] = %d"; $args[] = $item[$p]; $p = 'p' . ++$i; } - $max_depth = db_result(db_query_range("SELECT depth FROM {menu_links} WHERE menu_name = '%s'" . $match . " ORDER BY depth DESC", $args, 0, 1)); + $max_depth = db_result(db_query_range("SELECT [depth] FROM [{menu_links}] WHERE [menu_name] = %s" . $match . " ORDER BY [depth] DESC", $args, 0, 1)); return ($max_depth > $item['depth']) ? $max_depth - $item['depth'] : 0; } @@ -2170,26 +2170,26 @@ function menu_link_children_relative_dep function _menu_link_move_children($item, $existing_item) { $args[] = $item['menu_name']; - $set[] = "menu_name = '%s'"; + $set[] = "[menu_name] = %s"; $i = 1; while ($i <= $item['depth']) { $p = 'p' . $i++; - $set[] = "$p = %d"; + $set[] = "[$p] = %d"; $args[] = $item[$p]; } $j = $existing_item['depth'] + 1; while ($i <= MENU_MAX_DEPTH && $j <= MENU_MAX_DEPTH) { - $set[] = 'p' . $i++ . ' = p' . $j++; + $set[] = '[p' . $i++ . '] = [p' . $j++ . ']'; } while ($i <= MENU_MAX_DEPTH) { - $set[] = 'p' . $i++ . ' = 0'; + $set[] = '[p' . $i++ . '] = 0'; } $shift = $item['depth'] - $existing_item['depth']; if ($shift < 0) { $args[] = -$shift; - $set[] = 'depth = depth - %d'; + $set[] = '[depth] = [depth] - %d'; } elseif ($shift > 0) { // The order of $set must be reversed so the new values don't overwrite the @@ -2200,17 +2200,17 @@ function _menu_link_move_children($item, $args = array_reverse($args); $args[] = $shift; - $set[] = 'depth = depth + %d'; + $set[] = '[depth] = [depth] + %d'; } - $where[] = "menu_name = '%s'"; + $where[] = "[menu_name] = %s"; $args[] = $existing_item['menu_name']; $p = 'p1'; for ($i = 1; $i <= MENU_MAX_DEPTH && $existing_item[$p]; $p = 'p' . ++$i) { - $where[] = "$p = %d"; + $where[] = "[$p] = %d"; $args[] = $existing_item[$p]; } - db_query("UPDATE {menu_links} SET " . implode(', ', $set) . " WHERE " . implode(' AND ', $where), $args); + db_query("UPDATE [{menu_links}] SET " . implode(', ', $set) . " WHERE " . implode(' AND ', $where), $args); // Check the has_children status of the parent, while excluding this item. _menu_update_parental_status($existing_item, TRUE); } @@ -2234,7 +2234,7 @@ function _menu_update_parental_status($i } $parent_has_children = ((bool) $query->execute()->fetchField()) ? 1 : 0; - db_query("UPDATE {menu_links} SET has_children = %d WHERE mlid = %d", $parent_has_children, $item['plid']); + db_query("UPDATE [{menu_links}] SET [has_children] = %d WHERE [mlid] = %d", $parent_has_children, $item['plid']); } } @@ -2342,7 +2342,7 @@ function _menu_router_build($callbacks) if ($menu) { // Delete the existing router since we have some data to replace it. - db_query('DELETE FROM {menu_router}'); + db_query('DELETE FROM [{menu_router}]'); } // Apply inheritance rules. foreach ($menu as $path => $v) { @@ -2410,17 +2410,17 @@ function _menu_router_build($callbacks) ); $title_arguments = $item['title arguments'] ? serialize($item['title arguments']) : ''; - db_query("INSERT INTO {menu_router} - (path, load_functions, to_arg_functions, access_callback, - access_arguments, page_callback, page_arguments, fit, - number_parts, tab_parent, tab_root, - title, title_callback, title_arguments, - type, block_callback, description, position, weight) - VALUES ('%s', '%s', '%s', '%s', - '%s', '%s', '%s', %d, - %d, '%s', '%s', - '%s', '%s', '%s', - %d, '%s', '%s', '%s', %d)", + db_query("INSERT INTO [{menu_router}] + ([path], [load_functions], [to_arg_functions], [access_callback], + [access_arguments], [page_callback], [page_arguments], [fit], + [number_parts], [tab_parent], [tab_root], + [title], [title_callback], [title_arguments], + [type], [block_callback], [description], [position], [weight]) + VALUES (%s, %s, %s, %s, + %s, %s, %s, %d, + %d, %s, %s, + %s, %s, %s, + %d, %s, %s, %s, %d)", $path, $item['load_functions'], $item['to_arg_functions'], $item['access callback'], serialize($item['access arguments']), $item['page callback'], serialize($item['page arguments']), $item['_fit'], $item['_number_parts'], $item['tab_parent'], $item['tab_root'], @@ -2497,7 +2497,7 @@ function menu_valid_path($form_item) { } elseif (preg_match('/\/\%/', $path)) { // Path is dynamic (ie 'user/%'), so check directly against menu_router table. - if ($item = db_fetch_array(db_query("SELECT * FROM {menu_router} where path = '%s' ", $path))) { + if ($item = db_fetch_array(db_query("SELECT * FROM [{menu_router}] where [path] = %s ", $path))) { $item['link_path'] = $form_item['link_path']; $item['link_title'] = $form_item['link_title']; $item['external'] = FALSE; Index: includes/module.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/module.inc,v retrieving revision 1.126 diff -u -p -r1.126 module.inc --- includes/module.inc 20 Sep 2008 20:22:23 -0000 1.126 +++ includes/module.inc 22 Sep 2008 09:06:48 -0000 @@ -49,10 +49,10 @@ function module_list($refresh = FALSE, $ } else { if ($bootstrap) { - $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 AND bootstrap = 1 ORDER BY weight ASC, filename ASC"); + $result = db_query("SELECT [name], [filename] FROM [{system}] WHERE [type] = 'module' AND [status] = 1 AND [bootstrap] = 1 ORDER BY [weight] ASC, [filename] ASC"); } else { - $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC"); + $result = db_query("SELECT [name], [filename] FROM [{system}] WHERE [type] = 'module' AND [status] = 1 ORDER BY [weight] ASC, [filename] ASC"); } while ($module = db_fetch_object($result)) { if (file_exists($module->filename)) { @@ -123,12 +123,12 @@ function module_rebuild_cache() { // Update the contents of the system table: if (isset($file->status) || (isset($file->old_filename) && $file->old_filename != $file->filename)) { - db_query("UPDATE {system} SET info = '%s', name = '%s', filename = '%s', bootstrap = %d WHERE filename = '%s'", serialize($files[$filename]->info), $file->name, $file->filename, $bootstrap, $file->old_filename); + db_query("UPDATE [{system}] SET [info] = %s, [name] = %s, [filename] = %s, [bootstrap] = %d WHERE [filename] = %s", serialize($files[$filename]->info), $file->name, $file->filename, $bootstrap, $file->old_filename); } else { // This is a new module. $files[$filename]->status = 0; - db_query("INSERT INTO {system} (name, info, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', %d, %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0, $bootstrap); + db_query("INSERT INTO [{system}] ([name], [info], [type], [filename], [status], [bootstrap]) VALUES (%s, %s, %s, %s, %d, %d)", $file->name, serialize($files[$filename]->info), 'module', $file->filename, 0, $bootstrap); } } $files = _module_build_dependencies($files); @@ -270,10 +270,10 @@ function module_load_all_includes($type, function module_enable($module_list) { $invoke_modules = array(); foreach ($module_list as $module) { - $existing = db_fetch_object(db_query("SELECT status FROM {system} WHERE type = '%s' AND name = '%s'", 'module', $module)); + $existing = db_fetch_object(db_query("SELECT [status] FROM [{system}] WHERE [type] = %s AND [name] = %s", 'module', $module)); if ($existing->status == 0) { module_load_install($module); - db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'module', $module); + db_query("UPDATE [{system}] SET [status] = %d WHERE [type] = %s AND [name] = %s", 1, 'module', $module); drupal_load('module', $module); $invoke_modules[] = $module; } @@ -315,7 +315,7 @@ function module_disable($module_list) { module_load_install($module); module_invoke($module, 'disable'); - db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 0, 'module', $module); + db_query("UPDATE [{system}] SET [status] = %d WHERE [type] = %s AND [name] = %s", 0, 'module', $module); $invoke_modules[] = $module; } } Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.24 diff -u -p -r1.24 path.inc --- includes/path.inc 24 Jun 2008 22:12:15 -0000 1.24 +++ includes/path.inc 22 Sep 2008 09:06:48 -0000 @@ -52,7 +52,7 @@ function drupal_lookup_path($action, $pa // Use $count to avoid looking up paths in subsequent calls if there simply are no aliases if (!isset($count)) { - $count = db_result(db_query('SELECT COUNT(pid) FROM {url_alias}')); + $count = db_result(db_query('SELECT COUNT([pid]) FROM [{url_alias}]')); } if ($action == 'wipe') { @@ -65,7 +65,7 @@ function drupal_lookup_path($action, $pa return $map[$path_language][$path]; } // Get the most fitting result falling back with alias without language - $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language)); + $alias = db_result(db_query("SELECT [dst] FROM [{url_alias}] WHERE [src] = %s AND [language] IN(%s, %s) ORDER BY [language] DESC", $path, $path_language, '')); $map[$path_language][$path] = $alias; return $alias; } @@ -76,7 +76,7 @@ function drupal_lookup_path($action, $pa $src = ''; if (!isset($map[$path_language]) || !($src = array_search($path, $map[$path_language]))) { // Get the most fitting result falling back with alias without language - if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s' AND language IN('%s', '') ORDER BY language DESC", $path, $path_language))) { + if ($src = db_result(db_query("SELECT [src] FROM [{url_alias}] WHERE [dst] = %s AND [language] IN(%s, %s) ORDER BY [language] DESC", $path, $path_language, ''))) { $map[$path_language][$src] = $path; } else { Index: includes/registry.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/registry.inc,v retrieving revision 1.5 diff -u -p -r1.5 registry.inc --- includes/registry.inc 20 Sep 2008 20:22:23 -0000 1.5 +++ includes/registry.inc 22 Sep 2008 09:06:48 -0000 @@ -76,7 +76,7 @@ function _registry_rebuild() { function registry_get_parsed_files() { $files = array(); // We want the result as a keyed array. - $files = db_query("SELECT * FROM {registry_file}")->fetchAllAssoc('filename', PDO::FETCH_ASSOC); + $files = db_query("SELECT * FROM [{registry_file}]")->fetchAllAssoc('filename', PDO::FETCH_ASSOC); return $files; } Index: includes/session.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/session.inc,v retrieving revision 1.59 diff -u -p -r1.59 session.inc --- includes/session.inc 19 Sep 2008 07:53:59 -0000 1.59 +++ includes/session.inc 22 Sep 2008 09:06:48 -0000 @@ -87,7 +87,7 @@ function _sess_read($key) { // Otherwise, if the session is still active, we have a record of the // client's session in the database. - $user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key)); + $user = db_fetch_object(db_query("SELECT u.*, s.* FROM [{users}] u INNER JOIN [{sessions}] s ON u.[uid] = s.[uid] WHERE s.[sid] = %s", $key)); // We found the client's session record and they are an authenticated user if ($user && $user->uid > 0) { @@ -97,7 +97,7 @@ function _sess_read($key) { // Add roles element to $user $user->roles = array(); $user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user'; - $result = db_query("SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d", $user->uid); + $result = db_query("SELECT r.[rid], r.[name] FROM [{role}] r INNER JOIN [{users_roles}] ur ON ur.[rid] = r.[rid] WHERE ur.[uid] = %d", $user->uid); while ($role = db_fetch_object($result)) { $user->roles[$role->rid] = $role->name; } @@ -140,7 +140,7 @@ function _sess_write($key, $value) { return TRUE; } - $result = db_result(db_query("SELECT COUNT(*) FROM {sessions} WHERE sid = '%s'", $key)); + $result = db_result(db_query("SELECT COUNT(*) FROM [{sessions}] WHERE [sid] = %s", $key)); if (!$result) { // Only save session data when when the browser sends a cookie. This keeps @@ -148,18 +148,18 @@ function _sess_write($key, $value) { // and gives more useful statistics. We can't eliminate anonymous session // table rows without breaking "Who's Online" block. if ($user->uid || $value || count($_COOKIE)) { - db_query("INSERT INTO {sessions} (sid, uid, cache, hostname, session, timestamp) VALUES ('%s', %d, %d, '%s', '%s', %d)", $key, $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME); + db_query("INSERT INTO [{sessions}] ([sid], [uid], [cache], [hostname], [session], [timestamp]) VALUES (%s, %d, %d, %s, %s, %d)", $key, $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME); } } else { - db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME, $key); + db_query("UPDATE [{sessions}] SET [uid] = %d, [cache] = %d, [hostname] = %s, [session] = %s, [timestamp] = %d WHERE [sid] = %s", $user->uid, isset($user->cache) ? $user->cache : 0, ip_address(), $value, REQUEST_TIME, $key); if (db_affected_rows()) { // Last access time is updated no more frequently // than once every 180 seconds. // This reduces contention in the users table. if ($user->uid && REQUEST_TIME - $user->access > variable_get('session_write_interval', 180)) { - db_query("UPDATE {users} SET access = %d WHERE uid = %d", REQUEST_TIME, $user->uid); + db_query("UPDATE [{users}] SET [access] = %d WHERE [uid] = %d", REQUEST_TIME, $user->uid); } } } @@ -173,7 +173,7 @@ function _sess_write($key, $value) { function drupal_session_regenerate() { $old_session_id = session_id(); session_regenerate_id(); - db_query("UPDATE {sessions} SET sid = '%s' WHERE sid = '%s'", session_id(), $old_session_id); + db_query("UPDATE [{sessions}] SET [sid] = %s WHERE [sid] = %s", session_id(), $old_session_id); } /** @@ -190,8 +190,8 @@ function drupal_session_regenerate() { * The number of users with sessions. */ function drupal_session_count($timestamp = 0, $anonymous = TRUE) { - $query = $anonymous ? ' AND uid = 0' : ' AND uid > 0'; - return db_result(db_query('SELECT COUNT(sid) AS count FROM {sessions} WHERE timestamp >= %d' . $query, $timestamp)); + $query = $anonymous ? ' AND [uid] = 0' : ' AND [uid] > 0'; + return db_result(db_query('SELECT COUNT([sid]) AS [count] FROM [{sessions}] WHERE [timestamp] >= %d' . $query, $timestamp)); } /** @@ -203,7 +203,7 @@ function drupal_session_count($timestamp * the session id */ function _sess_destroy_sid($sid) { - db_query("DELETE FROM {sessions} WHERE sid = '%s'", $sid); + db_query("DELETE FROM [{sessions}] WHERE [sid] = %s", $sid); } /** @@ -213,7 +213,7 @@ function _sess_destroy_sid($sid) { * the user id */ function drupal_session_destroy_uid($uid) { - db_query('DELETE FROM {sessions} WHERE uid = %d', $uid); + db_query('DELETE FROM [{sessions}] WHERE [uid] = %d', $uid); } /** @@ -227,7 +227,7 @@ function _sess_gc($lifetime) { // for three weeks before deleting them, you need to set gc_maxlifetime // to '1814400'. At that value, only after a user doesn't log in after // three weeks (1814400 seconds) will his/her session be removed. - db_query("DELETE FROM {sessions} WHERE timestamp < %d", REQUEST_TIME - $lifetime); + db_query("DELETE FROM [{sessions}] WHERE [timestamp] < %d", REQUEST_TIME - $lifetime); return TRUE; } Index: includes/theme.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/theme.inc,v retrieving revision 1.437 diff -u -p -r1.437 theme.inc --- includes/theme.inc 20 Sep 2008 20:22:23 -0000 1.437 +++ includes/theme.inc 22 Sep 2008 09:06:48 -0000 @@ -436,7 +436,7 @@ function list_themes($refresh = FALSE) { // Extract from the database only when it is available. // Also check that the site is not in the middle of an install or update. if (db_is_active() && !defined('MAINTENANCE_MODE')) { - $result = db_query("SELECT * FROM {system} WHERE type = '%s'", 'theme'); + $result = db_query("SELECT * FROM [{system}] WHERE [type] = %s", 'theme'); while ($theme = db_fetch_object($result)) { if (file_exists($theme->filename)) { $theme->info = unserialize($theme->info); Index: modules/block/block.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.admin.inc,v retrieving revision 1.19 diff -u -p -r1.19 block.admin.inc --- modules/block/block.admin.inc 16 Jul 2008 21:59:25 -0000 1.19 +++ modules/block/block.admin.inc 22 Sep 2008 09:06:48 -0000 @@ -95,7 +95,7 @@ function block_admin_display_form_submit foreach ($form_state['values'] as $block) { $block['status'] = $block['region'] != BLOCK_REGION_NONE; $block['region'] = $block['status'] ? $block['region'] : ''; - db_query("UPDATE {blocks} SET status = %d, weight = %d, region = '%s' WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $block['status'], $block['weight'], $block['region'], $block['module'], $block['delta'], $block['theme']); + db_query("UPDATE [{blocks}] SET [status] = %d, [weight] = %d, [region] = %s WHERE [module] = %s AND [delta] = %s AND [theme] = %s", $block['status'], $block['weight'], $block['region'], $block['module'], $block['delta'], $block['theme']); } drupal_set_message(t('The block settings have been updated.')); cache_clear_all(); @@ -148,7 +148,7 @@ function block_admin_configure(&$form_st '#value' => $delta, ); - $edit = db_fetch_array(db_query("SELECT pages, visibility, custom, title FROM {blocks} WHERE module = '%s' AND delta = '%s'", $module, $delta)); + $edit = db_fetch_array(db_query("SELECT [pages], [visibility], [custom], [title] FROM [{blocks}] WHERE [module] = %s AND [delta] = %s", $module, $delta)); $form['block_settings'] = array( '#type' => 'fieldset', @@ -197,11 +197,11 @@ function block_admin_configure(&$form_st // Role-based visibility settings. $default_role_options = array(); - $result = db_query("SELECT rid FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $module, $delta); + $result = db_query("SELECT [rid] FROM [{blocks_roles}] WHERE [module] = %s AND [delta] = %s", $module, $delta); while ($role = db_fetch_object($result)) { $default_role_options[] = $role->rid; } - $result = db_query('SELECT rid, name FROM {role} ORDER BY name'); + $result = db_query('SELECT [rid], [name] FROM [{role}] ORDER BY [name]'); $role_options = array(); while ($role = db_fetch_object($result)) { $role_options[$role->rid] = $role->name; @@ -263,7 +263,7 @@ function block_admin_configure(&$form_st function block_admin_configure_validate($form, &$form_state) { if ($form_state['values']['module'] == 'block') { - if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE bid != %d AND info = '%s'", $form_state['values']['delta'], $form_state['values']['info']))) { + if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM [{boxes}] WHERE [bid] <> %d AND [info] = %s", $form_state['values']['delta'], $form_state['values']['info']))) { form_set_error('info', t('Please ensure that each block description is unique.')); } } @@ -271,10 +271,10 @@ function block_admin_configure_validate( function block_admin_configure_submit($form, &$form_state) { if (!form_get_errors()) { - db_query("UPDATE {blocks} SET visibility = %d, pages = '%s', custom = %d, title = '%s' WHERE module = '%s' AND delta = '%s'", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']); - db_query("DELETE FROM {blocks_roles} WHERE module = '%s' AND delta = '%s'", $form_state['values']['module'], $form_state['values']['delta']); + db_query("UPDATE [{blocks}] SET [visibility] = %d, [pages] = %s, [custom] = %d, [title] = %s WHERE [module] = %s AND [delta] = %s", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $form_state['values']['delta']); + db_query("DELETE FROM [{blocks_roles}] WHERE [module] = %s AND [delta] = %s", $form_state['values']['module'], $form_state['values']['delta']); foreach (array_filter($form_state['values']['roles']) as $rid) { - db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $form_state['values']['delta']); + db_query("INSERT INTO [{blocks_roles}] ([rid], [module], [delta]) VALUES (%d, %s, %s)", $rid, $form_state['values']['module'], $form_state['values']['delta']); } module_invoke($form_state['values']['module'], 'block', 'save', $form_state['values']['delta'], $form_state['values']); drupal_set_message(t('The block configuration has been saved.')); @@ -292,7 +292,7 @@ function block_add_block_form(&$form_sta } function block_add_block_form_validate($form, &$form_state) { - if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM {boxes} WHERE info = '%s'", $form_state['values']['info']))) { + if (empty($form_state['values']['info']) || db_result(db_query("SELECT COUNT(*) FROM [{boxes}] WHERE [info] = %s", $form_state['values']['info']))) { form_set_error('info', t('Please ensure that each block description is unique.')); } } @@ -301,17 +301,17 @@ function block_add_block_form_validate($ * Save the new custom block. */ function block_add_block_form_submit($form, &$form_state) { - db_query("INSERT INTO {boxes} (body, info, format) VALUES ('%s', '%s', %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']); + db_query("INSERT INTO [{boxes}] ([body], [info], [format]) VALUES (%s, %s, %d)", $form_state['values']['body'], $form_state['values']['info'], $form_state['values']['format']); $delta = db_last_insert_id('boxes', 'bid'); foreach (list_themes() as $key => $theme) { if ($theme->status) { - db_query("INSERT INTO {blocks} (visibility, pages, custom, title, module, theme, status, weight, delta, cache) VALUES(%d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE); + db_query("INSERT INTO [{blocks}] ([visibility], [pages], [custom], [title], [module], [theme], [status], [weight], [delta], [cache]) VALUES(%d, %s, %d, %s, %s, %s, %d, %d, %d, %d)", $form_state['values']['visibility'], trim($form_state['values']['pages']), $form_state['values']['custom'], $form_state['values']['title'], $form_state['values']['module'], $theme->name, 0, 0, $delta, BLOCK_NO_CACHE); } } foreach (array_filter($form_state['values']['roles']) as $rid) { - db_query("INSERT INTO {blocks_roles} (rid, module, delta) VALUES (%d, '%s', '%s')", $rid, $form_state['values']['module'], $delta); + db_query("INSERT INTO [{blocks_roles}] ([rid], [module], [delta]) VALUES (%d, %s, %s)", $rid, $form_state['values']['module'], $delta); } drupal_set_message(t('The block has been created.')); @@ -337,8 +337,8 @@ function block_box_delete(&$form_state, * Deletion of custom blocks. */ function block_box_delete_submit($form, &$form_state) { - db_query('DELETE FROM {boxes} WHERE bid = %d', $form_state['values']['bid']); - db_query("DELETE FROM {blocks} WHERE module = 'block' AND delta = %d", $form_state['values']['bid']); + db_query('DELETE FROM [{boxes}] WHERE [bid] = %d', $form_state['values']['bid']); + db_query("DELETE FROM [{blocks}] WHERE [module] = 'block' AND [delta] = %d", $form_state['values']['bid']); drupal_set_message(t('The block %name has been removed.', array('%name' => $form_state['values']['info']))); cache_clear_all(); $form_state['redirect'] = 'admin/build/block'; Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.309 diff -u -p -r1.309 block.module --- modules/block/block.module 21 Aug 2008 19:36:36 -0000 1.309 +++ modules/block/block.module 22 Sep 2008 09:06:48 -0000 @@ -183,7 +183,7 @@ function block_block($op = 'list', $delt case 'list': $blocks = array(); - $result = db_query('SELECT bid, info FROM {boxes} ORDER BY info'); + $result = db_query('SELECT [bid], [info] FROM [{boxes}] ORDER BY [info]'); while ($block = db_fetch_object($result)) { $blocks[$block->bid]['info'] = $block->info; // Not worth caching. @@ -206,7 +206,7 @@ function block_block($op = 'list', $delt break; case 'view': - $block = db_fetch_object(db_query('SELECT body, format FROM {boxes} WHERE bid = %d', $delta)); + $block = db_fetch_object(db_query('SELECT [body], [format] FROM [{boxes}] WHERE [bid] = %d', $delta)); $data['content'] = check_markup($block->body, $block->format, FALSE); return $data; } @@ -223,7 +223,7 @@ function _block_rehash() { init_theme(); - $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $theme_key); + $result = db_query("SELECT * FROM [{blocks}] WHERE [theme] = %s", $theme_key); $old_blocks = array(); while ($old_block = db_fetch_array($result)) { $old_blocks[$old_block['module']][$old_block['delta']] = $old_block; @@ -283,14 +283,14 @@ function _block_rehash() { // Remove blocks that are no longer defined by the code from the database. foreach ($old_blocks as $module => $old_module_blocks) { foreach ($old_module_blocks as $delta => $block) { - db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", $module, $delta, $theme_key); + db_query("DELETE FROM [{blocks}] WHERE [module] = %s AND [delta] = %s AND [theme] = %s", $module, $delta, $theme_key); } } return $blocks; } function block_box_get($bid) { - return db_fetch_array(db_query("SELECT * FROM {boxes} WHERE bid = %d", $bid)); + return db_fetch_array(db_query("SELECT * FROM [{boxes}] WHERE [bid] = %d", $bid)); } /** @@ -332,7 +332,7 @@ function block_box_save($edit, $delta) { $edit['format'] = FILTER_FORMAT_DEFAULT; } - db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['format'], $delta); + db_query("UPDATE [{boxes}] SET [body] = %s, [info] = %s, [format] = %d WHERE [bid] = %d", $edit['body'], $edit['info'], $edit['format'], $delta); return TRUE; } @@ -348,7 +348,7 @@ function block_user($type, $edit, &$acco case 'form': if ($category == 'account') { $rids = array_keys($account->roles); - $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids); + $result = db_query("SELECT DISTINCT b.* FROM [{blocks}] b LEFT JOIN [{blocks_roles}] r ON b.[module] = r.[module] AND b.[delta] = r.[delta] WHERE b.[status] = 1 AND b.[custom] <> 0 AND (r.[rid] IN (" . db_placeholders($rids) . ") OR r.[rid] IS NULL) ORDER BY b.[weight], b.[module]", $rids); $form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE); while ($block = db_fetch_object($result)) { $data = module_invoke($block->module, 'block', 'list'); @@ -413,7 +413,7 @@ function _block_load_blocks() { $blocks = array(); $rids = array_keys($user->roles); - $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.theme = '%s' AND b.status = 1 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.region, b.weight, b.module", 'b', 'bid'), array_merge(array($theme_key), $rids)); + $result = db_query(db_rewrite_sql("SELECT DISTINCT b.* FROM [{blocks}] b LEFT JOIN [{blocks_roles}] r ON b.[module] = r.[module] AND b.[delta] = r.[delta] WHERE b.[theme] = %s AND b.[status] = 1 AND (r.[rid] IN (" . db_placeholders($rids) . ") OR r.[rid] IS NULL) ORDER BY b.[region], b.[weight], b.[module]", 'b', 'bid'), array_merge(array($theme_key), $rids)); while ($block = db_fetch_object($result)) { if (!isset($blocks[$block->region])) { $blocks[$block->region] = array(); Index: modules/block/block.test =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.test,v retrieving revision 1.3 diff -u -p -r1.3 block.test --- modules/block/block.test 14 Sep 2008 20:37:28 -0000 1.3 +++ modules/block/block.test 22 Sep 2008 09:06:48 -0000 @@ -37,7 +37,7 @@ class BlockTestCase extends DrupalWebTes // Confirm that the box has been created, and then query the created bid. $this->assertText(t('The block has been created.'), t('Box successfully created.')); - $bid = db_result(db_query("SELECT bid FROM {boxes} WHERE info = '%s'", array($box['info']))); + $bid = db_result(db_query("SELECT [bid] FROM [{boxes}] WHERE [info] = %s", array($box['info']))); // Check to see if the box was created by checking that it's in the database.. $this->assertNotNull($bid, t('Box found in database')); @@ -73,7 +73,7 @@ class BlockTestCase extends DrupalWebTes // Set block title to confirm that interface works and override any custom titles. $this->drupalPost('admin/build/block/configure/' . $block['module'] . '/' . $block['delta'], array('title' => $block['title']), t('Save block')); $this->assertText(t('The block configuration has been saved.'), t('Block title set.')); - $bid = db_result(db_query("SELECT bid FROM {blocks} WHERE module = '%s' AND delta = %d", array($block['module'], $block['delta']))); + $bid = db_result(db_query("SELECT [bid] FROM [{blocks}] WHERE [module] = %s AND [delta] = %d", array($block['module'], $block['delta']))); // Check to see if the block was created by checking that it's in the database. $this->assertNotNull($bid, t('Block found in database')); Index: modules/comment/comment.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.admin.inc,v retrieving revision 1.10 diff -u -p -r1.10 comment.admin.inc --- modules/comment/comment.admin.inc 16 Jul 2008 21:59:26 -0000 1.10 +++ modules/comment/comment.admin.inc 22 Sep 2008 09:06:48 -0000 @@ -68,7 +68,7 @@ function comment_admin_overview($type = array('data' => t('Time'), 'field' => 'timestamp', 'sort' => 'desc'), array('data' => t('Operations')), )); - $result = pager_query('SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, c.homepage, u.name AS registered_name, u.uid, n.title as node_title FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid INNER JOIN {node} n ON n.nid = c.nid WHERE c.status = %d' . tablesort_sql($form['header']['#value']), 50, 0, NULL, $status); + $result = pager_query('SELECT c.[subject], c.[nid], c.[cid], c.[comment], c.[timestamp], c.[status], c.[name], c.[homepage], u.[name] AS [registered_name], u.[uid], n.[title] as [node_title] FROM [{comments}] c INNER JOIN [{users}] u ON u.[uid] = c.[uid] INNER JOIN [{node}] n ON n.[nid] = c.[nid] WHERE c.[status] = %d' . tablesort_sql($form['header']['#value']), 50, 0, NULL, $status); // Build a table listing the appropriate comments. $destination = drupal_get_destination(); @@ -201,7 +201,7 @@ function comment_multiple_delete_confirm foreach (array_filter($edit['comments']) as $cid => $value) { $comment = comment_load($cid); if (is_object($comment) && is_numeric($comment->cid)) { - $subject = db_result(db_query('SELECT subject FROM {comments} WHERE cid = %d', $cid)); + $subject = db_result(db_query('SELECT [subject] FROM [{comments}] WHERE [cid] = %d', $cid)); $form['comments'][$cid] = array('#type' => 'hidden', '#value' => $cid, '#prefix' => '
  • ', '#suffix' => check_plain($subject) . '
  • '); $comment_counter++; } @@ -244,7 +244,7 @@ function comment_multiple_delete_confirm * The comment to be deleted. */ function comment_delete($cid = NULL) { - $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid)); + $comment = db_fetch_object(db_query('SELECT c.*, u.[name] AS [registered_name], u.[uid] FROM [{comments}] c INNER JOIN [{users}] u ON u.[uid] = c.[uid] WHERE c.[cid] = %d', $cid)); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $output = ''; @@ -306,12 +306,12 @@ function _comment_delete_thread($comment } // Delete the comment. - db_query('DELETE FROM {comments} WHERE cid = %d', $comment->cid); + db_query('DELETE FROM [{comments}] WHERE [cid] = %d', $comment->cid); watchdog('content', 'Comment: deleted %subject.', array('%subject' => $comment->subject)); comment_invoke_comment($comment, 'delete'); // Delete the comment's replies. - $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE pid = %d', $comment->cid); + $result = db_query('SELECT c.*, u.[name] AS [registered_name], u.[uid] FROM [{comments}] c INNER JOIN [{users}] u ON u.[uid] = c.[uid] WHERE [pid] = %d', $comment->cid); while ($comment = db_fetch_object($result)) { $comment->name = $comment->uid ? $comment->registered_name : $comment->name; _comment_delete_thread($comment); Index: modules/comment/comment.install =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.install,v retrieving revision 1.26 diff -u -p -r1.26 comment.install --- modules/comment/comment.install 17 Sep 2008 07:11:56 -0000 1.26 +++ modules/comment/comment.install 22 Sep 2008 09:06:48 -0000 @@ -6,7 +6,7 @@ */ function comment_enable() { // Insert records into the node_comment_statistics for nodes that are missing. - db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) SELECT n.nid, n.changed, NULL, n.uid, 0 FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE c.comment_count IS NULL"); + db_query("INSERT INTO [{node_comment_statistics}] ([nid], [last_comment_timestamp], [last_comment_name], [last_comment_uid], [comment_count]) SELECT n.[nid], n.[changed], NULL, n.[uid], 0 FROM [{node}] n LEFT JOIN [{node_comment_statistics}] c ON n.[nid] = c.[nid] WHERE c.[comment_count] IS NULL"); } /** @@ -14,7 +14,7 @@ function comment_enable() { */ function comment_update_1() { // Change any future last comment timestamps to current time. - db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', REQUEST_TIME, REQUEST_TIME); + db_query('UPDATE [{node_comment_statistics}] SET [last_comment_timestamp] = %d WHERE [last_comment_timestamp] > %d', REQUEST_TIME, REQUEST_TIME); // Unstuck node indexing timestamp if needed. if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) { @@ -30,8 +30,8 @@ function comment_update_1() { */ function comment_update_6001() { - $ret[] = update_sql("ALTER TABLE {comments} DROP score"); - $ret[] = update_sql("ALTER TABLE {comments} DROP users"); + $ret[] = update_sql("ALTER TABLE [{comments}] DROP [score]"); + $ret[] = update_sql("ALTER TABLE [{comments}] DROP [users]"); return $ret; } @@ -101,9 +101,9 @@ function comment_update_7000() { */ function comment_update_7001() { $ret = array(); - $ret[] = update_sql("UPDATE {comments} SET status = 3 WHERE status = 0"); - $ret[] = update_sql("UPDATE {comments} SET status = 0 WHERE status = 1"); - $ret[] = update_sql("UPDATE {comments} SET status = 1 WHERE status = 3"); + $ret[] = update_sql("UPDATE [{comments}] SET [status] = 3 WHERE [status] = 0"); + $ret[] = update_sql("UPDATE [{comments}] SET [status] = 0 WHERE [status] = 1"); + $ret[] = update_sql("UPDATE [{comments}] SET [status] = 1 WHERE [status] = 3"); return $ret; } Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.650 diff -u -p -r1.650 comment.module --- modules/comment/comment.module 17 Sep 2008 20:37:31 -0000 1.650 +++ modules/comment/comment.module 22 Sep 2008 09:06:48 -0000 @@ -305,7 +305,7 @@ function comment_block($op = 'list', $de function comment_get_recent($number = 10) { // Step 1: Select a $number of nodes which have new comments, // and are visible to the current user. - $result = db_query_range(db_rewrite_sql("SELECT nc.nid FROM {node_comment_statistics} nc WHERE nc.comment_count > 0 ORDER BY nc.last_comment_timestamp DESC", 'nc'), 0, $number); + $result = db_query_range(db_rewrite_sql("SELECT nc.[nid] FROM [{node_comment_statistics}] nc WHERE nc.[comment_count] > 0 ORDER BY nc.[last_comment_timestamp] DESC", 'nc'), 0, $number); $nids = array(); while ($row = db_fetch_object($result)) { $nids[] = $row->nid; @@ -315,7 +315,7 @@ function comment_get_recent($number = 10 if (!empty($nids)) { // Step 2: From among the comments on the nodes selected in the first query, // find the $number of most recent comments. - $result = db_query_range('SELECT c.nid, c.subject, c.cid, c.timestamp FROM {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE c.nid IN (' . implode(',', $nids) . ') AND n.status = 1 AND c.status = %d ORDER BY c.cid DESC', COMMENT_PUBLISHED, 0, $number); + $result = db_query_range('SELECT c.[nid], c.[subject], c.[cid], c.[timestamp] FROM [{comments}] c INNER JOIN [{node}] n ON n.[nid] = c.[nid] WHERE c.[nid] IN (' . implode(',', $nids) . ') AND n.[status] = 1 AND c.[status] = %d ORDER BY c.[cid] DESC', COMMENT_PUBLISHED, 0, $number); while ($comment = db_fetch_object($result)) { $comments[] = $comment; } @@ -353,9 +353,9 @@ function comment_new_page_count($num_com else { // Threaded comments. // Find the first thread with a new comment. - $result = db_query('(SELECT thread FROM {comments} WHERE nid = %d AND status = 0 ORDER BY timestamp DESC LIMIT %d) ORDER BY SUBSTRING(thread, 1, (LENGTH(thread) - 1)) LIMIT 1', $node->nid, $new_replies); + $result = db_query('(SELECT [thread] FROM [{comments}] WHERE [nid] = %d AND [status] = 0 ORDER BY [timestamp] DESC LIMIT %d) ORDER BY ' . db_substr() . '([thread], 1, (' . db_strlen() . '([thread]) - 1)) LIMIT 1', $node->nid, $new_replies); $thread = substr(db_result($result), 0, -1); - $result_count = db_query("SELECT COUNT(*) FROM {comments} WHERE nid = %d AND status = 0 AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < '" . $thread . "'", $node->nid); + $result_count = db_query("SELECT COUNT(*) FROM [{comments}] WHERE [nid] = %d AND [status] = 0 AND " . db_substr() . "([thread], 1, (" . db_strlen() . "([thread]) - 1)) < '" . $thread . "'", $node->nid); $count = db_result($result_count); $pageno = $count / $comments_per_page; } @@ -560,7 +560,7 @@ function comment_nodeapi(&$node, $op, $a switch ($op) { case 'load': if ($node->comment != COMMENT_NODE_DISABLED) { - return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); + return db_fetch_array(db_query("SELECT [last_comment_timestamp], [last_comment_name], [comment_count] FROM [{node_comment_statistics}] WHERE [nid] = %d", $node->nid)); } return array('last_comment_timestamp' => $node->created, 'last_comment_name' => '', 'comment_count' => 0); @@ -571,24 +571,24 @@ function comment_nodeapi(&$node, $op, $a break; case 'insert': - db_query('INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->changed, $node->uid); + db_query('INSERT INTO [{node_comment_statistics}] ([nid], [last_comment_timestamp], [last_comment_name], [last_comment_uid], [comment_count]) VALUES (%d, %d, NULL, %d, 0)', $node->nid, $node->changed, $node->uid); break; case 'delete': - db_query('DELETE FROM {comments} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {node_comment_statistics} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{comments}] WHERE [nid] = %d', $node->nid); + db_query('DELETE FROM [{node_comment_statistics}] WHERE [nid] = %d', $node->nid); break; case 'update index': $text = ''; - $comments = db_query('SELECT subject, comment, format FROM {comments} WHERE nid = %d AND status = %d', $node->nid, COMMENT_PUBLISHED); + $comments = db_query('SELECT [subject], [comment], [format] FROM [{comments}] WHERE [nid] = %d AND [status] = %d', $node->nid, COMMENT_PUBLISHED); while ($comment = db_fetch_object($comments)) { $text .= '

    ' . check_plain($comment->subject) . '

    ' . check_markup($comment->comment, $comment->format, FALSE); } return $text; case 'search result': - $comments = db_result(db_query('SELECT comment_count FROM {node_comment_statistics} WHERE nid = %d', $node->nid)); + $comments = db_result(db_query('SELECT [comment_count] FROM [{node_comment_statistics}] WHERE [nid] = %d', $node->nid)); return format_plural($comments, '1 comment', '@count comments'); case 'rss item': @@ -606,8 +606,8 @@ function comment_nodeapi(&$node, $op, $a */ function comment_user($type, $edit, &$user, $category = NULL) { if ($type == 'delete') { - db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid); - db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid); + db_query('UPDATE [{comments}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); + db_query('UPDATE [{node_comment_statistics}] SET [last_comment_uid] = 0 WHERE [last_comment_uid] = %d', $user->uid); } } @@ -666,7 +666,7 @@ function comment_save($edit) { ); if ($edit['cid']) { // Update the comment in the database. - db_query("UPDATE {comments} SET status = %d, timestamp = %d, subject = '%s', comment = '%s', format = %d, uid = %d, name = '%s', mail = '%s', homepage = '%s' WHERE cid = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']); + db_query("UPDATE [{comments}] SET [status] = %d, [timestamp] = %d, [subject] = %s, [comment] = %s, [format] = %d, [uid] = %d, [name] = %s, [mail] = %s, [homepage] = %s WHERE [cid] = %d", $edit['status'], $edit['timestamp'], $edit['subject'], $edit['comment'], $edit['format'], $edit['uid'], $edit['name'], $edit['mail'], $edit['homepage'], $edit['cid']); // Allow modules to respond to the updating of a comment. comment_invoke_comment($edit, 'update'); // Add an entry to the watchdog log. @@ -678,7 +678,7 @@ function comment_save($edit) { if ($edit['pid'] == 0) { // This is a comment with no parent comment (depth 0): we start // by retrieving the maximum thread level. - $max = db_result(db_query('SELECT MAX(thread) FROM {comments} WHERE nid = %d', $edit['nid'])); + $max = db_result(db_query('SELECT MAX([thread]) FROM [{comments}] WHERE [nid] = %d', $edit['nid'])); // Strip the "/" from the end of the thread. $max = rtrim($max, '/'); // Finally, build the thread field for this new comment. @@ -693,7 +693,7 @@ function comment_save($edit) { // Strip the "/" from the end of the parent thread. $parent->thread = (string) rtrim((string) $parent->thread, '/'); // Get the max value in *this* thread. - $max = db_query("SELECT MAX(thread) FROM {comments} WHERE thread LIKE :thread AND nid = :nid", array(':thread' => $parent->thread .'%', ':nid' => $edit['nid']))->fetchField(); + $max = db_query("SELECT MAX([thread]) FROM [{comments}] WHERE [thread] LIKE :thread AND [nid] = :nid", array(':thread' => $parent->thread . '%', ':nid' => $edit['nid']))->fetchField(); if ($max == '') { // First child of this parent. @@ -719,7 +719,7 @@ function comment_save($edit) { $edit['name'] = $user->name; } - db_query("INSERT INTO {comments} (nid, pid, uid, subject, comment, format, hostname, timestamp, status, thread, name, mail, homepage) VALUES (%d, %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s')", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']); + db_query("INSERT INTO [{comments}] ([nid], [pid], [uid], [subject], [comment], [format], [hostname], [timestamp], [status], [thread], [name], [mail], [homepage]) VALUES (%d, %d, %d, %s, %s, %d, %s, %d, %d, %s, %s, %s, %s)", $edit['nid'], $edit['pid'], $edit['uid'], $edit['subject'], $edit['comment'], $edit['format'], ip_address(), $edit['timestamp'], $edit['status'], $thread, $edit['name'], $edit['mail'], $edit['homepage']); $edit['cid'] = db_last_insert_id('comments', 'cid'); // Tell the other modules a new comment has been submitted. comment_invoke_comment($edit, 'insert'); @@ -897,10 +897,10 @@ function comment_render($node, $cid = 0) if ($cid && is_numeric($cid)) { // Single comment view. - $query = 'SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d'; + $query = 'SELECT c.[cid], c.[pid], c.[nid], c.[subject], c.[comment], c.[format], c.[timestamp], c.[name], c.[mail], c.[homepage], u.[uid], u.[name] AS [registered_name], u.[signature], u.[picture], u.[data], c.[status] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d'; $query_args = array($cid); if (!user_access('administer comments')) { - $query .= ' AND c.status = %d'; + $query .= ' AND c.[status] = %d'; $query_args[] = COMMENT_PUBLISHED; } @@ -917,23 +917,23 @@ function comment_render($node, $cid = 0) } else { // Multiple comment view. - $query_count = 'SELECT COUNT(*) FROM {comments} c WHERE c.nid = %d'; - $query = 'SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.format, c.timestamp, c.name, c.mail, c.homepage, u.uid, u.name AS registered_name, u.signature, u.picture, u.data, c.thread, c.status FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = %d'; + $query_count = 'SELECT COUNT(*) FROM [{comments}] c WHERE c.[nid] = %d'; + $query = 'SELECT c.[cid] as [cid], c.[pid], c.[nid], c.[subject], c.[comment], c.[format], c.[timestamp], c.[name], c.[mail], c.[homepage], u.[uid], u.[name] AS [registered_name], u.[signature], u.[picture], u.[data], c.[thread], c.[status] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[nid] = %d'; $query_args = array($nid); if (!user_access('administer comments')) { - $query .= ' AND c.status = %d'; - $query_count .= ' AND c.status = %d'; + $query .= ' AND c.[status] = %d'; + $query_count .= ' AND c.[status] = %d'; $query_args[] = COMMENT_PUBLISHED; } if ($mode == COMMENT_MODE_FLAT_COLLAPSED || $mode == COMMENT_MODE_FLAT_EXPANDED) { - $query .= ' ORDER BY c.cid'; + $query .= ' ORDER BY c.[cid]'; } else { // See comment above. Analysis reveals that this doesn't cost too // much. It scales much much better than having the whole comment // structure. - $query .= ' ORDER BY SUBSTRING(c.thread, 1, (LENGTH(c.thread) - 1))'; + $query .= ' ORDER BY ' . db_substr() . '(c.[thread], 1, (' . db_strlen() . '(c.[thread]) - 1))'; } $query = db_rewrite_sql($query, 'c', 'cid'); @@ -1007,20 +1007,20 @@ function comment_render($node, $cid = 0) function comment_operations($action = NULL) { if ($action == 'publish') { $operations = array( - 'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_PUBLISHED . ' WHERE cid = %d'), + 'publish' => array(t('Publish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_PUBLISHED . ' WHERE [cid] = %d'), 'delete' => array(t('Delete the selected comments'), '') ); } elseif ($action == 'unpublish') { $operations = array( - 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_NOT_PUBLISHED . ' WHERE cid = %d'), + 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_NOT_PUBLISHED . ' WHERE [cid] = %d'), 'delete' => array(t('Delete the selected comments'), '') ); } else { $operations = array( - 'publish' => array(t('Publish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_PUBLISHED . ' WHERE cid = %d'), - 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE {comments} SET status = ' . COMMENT_NOT_PUBLISHED . ' WHERE cid = %d'), + 'publish' => array(t('Publish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_PUBLISHED . ' WHERE [cid] = %d'), + 'unpublish' => array(t('Unpublish the selected comments'), 'UPDATE [{comments}] SET [status] = ' . COMMENT_NOT_PUBLISHED . ' WHERE [cid] = %d'), 'delete' => array(t('Delete the selected comments'), '') ); } @@ -1041,7 +1041,7 @@ function comment_operations($action = NU * The comment object. */ function comment_load($cid) { - return db_fetch_object(db_query('SELECT * FROM {comments} WHERE cid = %d', $cid)); + return db_fetch_object(db_query('SELECT * FROM [{comments}] WHERE [cid] = %d', $cid)); } /** @@ -1056,7 +1056,7 @@ function comment_num_replies($pid) { static $cache; if (!isset($cache[$pid])) { - $cache[$pid] = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE pid = %d AND status = %d', $pid, COMMENT_PUBLISHED)); + $cache[$pid] = db_result(db_query('SELECT COUNT([cid]) FROM [{comments}] WHERE [pid] = %d AND [status] = %d', $pid, COMMENT_PUBLISHED)); } return $cache[$pid]; @@ -1083,7 +1083,7 @@ function comment_num_new($nid, $timestam $timestamp = ($timestamp > NODE_NEW_LIMIT ? $timestamp : NODE_NEW_LIMIT); // Use the timestamp to retrieve the number of new comments. - $result = db_result(db_query('SELECT COUNT(c.cid) FROM {node} n INNER JOIN {comments} c ON n.nid = c.nid WHERE n.nid = %d AND timestamp > %d AND c.status = %d', $nid, $timestamp, COMMENT_PUBLISHED)); + $result = db_result(db_query('SELECT COUNT(c.[cid]) FROM [{node}] n INNER JOIN [{comments}] c ON n.[nid] = c.[nid] WHERE n.[nid] = %d AND [timestamp] > %d AND c.[status] = %d', $nid, $timestamp, COMMENT_PUBLISHED)); return $result; } @@ -1122,7 +1122,7 @@ function comment_validate($edit) { $node = node_load($edit['nid']); if (variable_get('comment_anonymous_' . $node->type, COMMENT_ANONYMOUS_MAYNOT_CONTACT) > COMMENT_ANONYMOUS_MAYNOT_CONTACT) { if ($edit['name']) { - $taken = db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE LOWER(name) = '%s'", $edit['name'])); + $taken = db_result(db_query("SELECT COUNT([uid]) FROM [{users}] WHERE LOWER([name]) = %s", $edit['name'])); if ($taken != 0) { form_set_error('name', t('The name you used belongs to a registered user.')); } @@ -1462,7 +1462,7 @@ function comment_form_add_preview($form, $output = ''; // Isn't this line a duplication of the first $output above? if ($edit['pid']) { - $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $edit['pid'], COMMENT_PUBLISHED)); + $comment = db_fetch_object(db_query('SELECT c.*, u.[uid], u.[name] AS [registered_name], u.[signature], u.[picture], u.[data] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d AND c.[status] = %d', $edit['pid'], COMMENT_PUBLISHED)); $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; $output .= theme('comment_view', $comment, $node); @@ -1803,17 +1803,17 @@ function _comment_get_display_setting($s * - comment_count: the total number of approved/published comments on this node. */ function _comment_update_node_statistics($nid) { - $count = db_result(db_query('SELECT COUNT(cid) FROM {comments} WHERE nid = %d AND status = %d', $nid, COMMENT_PUBLISHED)); + $count = db_result(db_query('SELECT COUNT([cid]) FROM [{comments}] WHERE [nid] = %d AND [status] = %d', $nid, COMMENT_PUBLISHED)); if ($count > 0) { // Comments exist. - $last_reply = db_fetch_object(db_query_range('SELECT cid, name, timestamp, uid FROM {comments} WHERE nid = %d AND status = %d ORDER BY cid DESC', $nid, COMMENT_PUBLISHED, 0, 1)); - db_query("UPDATE {node_comment_statistics} SET comment_count = %d, last_comment_timestamp = %d, last_comment_name = '%s', last_comment_uid = %d WHERE nid = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid); + $last_reply = db_fetch_object(db_query_range('SELECT [cid], [name], [timestamp], [uid] FROM [{comments}] WHERE [nid] = %d AND [status] = %d ORDER BY [cid] DESC', $nid, COMMENT_PUBLISHED, 0, 1)); + db_query("UPDATE [{node_comment_statistics}] SET [comment_count] = %d, [last_comment_timestamp] = %d, [last_comment_name] = %s, [last_comment_uid] = %d WHERE [nid] = %d", $count, $last_reply->timestamp, $last_reply->uid ? '' : $last_reply->name, $last_reply->uid, $nid); } else { // Comments do not exist. - $node = db_fetch_object(db_query("SELECT uid, created FROM {node} WHERE nid = %d", $nid)); - db_query("UPDATE {node_comment_statistics} SET comment_count = 0, last_comment_timestamp = %d, last_comment_name = '', last_comment_uid = %d WHERE nid = %d", $node->created, $node->uid, $nid); + $node = db_fetch_object(db_query("SELECT [uid], [created] FROM [{node}] WHERE [nid] = %d", $nid)); + db_query("UPDATE [{node_comment_statistics}] SET [comment_count] = %d, [last_comment_timestamp] = %d, [last_comment_name] = %s, [last_comment_uid] = %d WHERE [nid] = %d", 0, $node->created, '', $node->uid, $nid); } } @@ -1933,9 +1933,9 @@ function comment_unpublish_action($comme } else { $cid = $context['cid']; - $subject = db_result(db_query("SELECT subject FROM {comments} WHERE cid = %d", $cid)); + $subject = db_result(db_query("SELECT [subject] FROM [{comments}] WHERE [cid] = %d", $cid)); } - db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $cid); + db_query('UPDATE [{comments}] SET [status] = %d WHERE [cid] = %d', COMMENT_NOT_PUBLISHED, $cid); watchdog('action', 'Unpublished comment %subject.', array('%subject' => $subject)); } @@ -1977,7 +1977,7 @@ function comment_unpublish_by_keyword_ac function comment_unpublish_by_keyword_action($comment, $context) { foreach ($context['keywords'] as $keyword) { if (strstr($comment->comment, $keyword) || strstr($comment->subject, $keyword)) { - db_query('UPDATE {comments} SET status = %d WHERE cid = %d', COMMENT_NOT_PUBLISHED, $comment->cid); + db_query('UPDATE [{comments}] SET [status] = %d WHERE [cid] = %d', COMMENT_NOT_PUBLISHED, $comment->cid); watchdog('action', 'Unpublished comment %subject.', array('%subject' => $comment->subject)); break; } @@ -1991,9 +1991,9 @@ function comment_ranking() { return array( 'comments' => array( 'title' => t('Number of comments'), - 'join' => 'LEFT JOIN {node_comment_statistics} node_comment_statistics ON node_comment_statistics.nid = i.sid', + 'join' => 'LEFT JOIN [{node_comment_statistics}] [node_comment_statistics] ON [node_comment_statistics].[nid] = i.[sid]', // Inverse law that maps the highest reply count on the site to 1 and 0 to 0. - 'score' => '2.0 - 2.0 / (1.0 + node_comment_statistics.comment_count * %f)', + 'score' => '2.0 - 2.0 / (1.0 + [node_comment_statistics].[comment_count] * %f)', 'arguments' => array(variable_get('node_cron_comments_scale', 0)), ), ); Index: modules/comment/comment.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.pages.inc,v retrieving revision 1.6 diff -u -p -r1.6 comment.pages.inc --- modules/comment/comment.pages.inc 24 Jun 2008 17:01:33 -0000 1.6 +++ modules/comment/comment.pages.inc 22 Sep 2008 09:06:48 -0000 @@ -15,7 +15,7 @@ */ function comment_edit($cid) { global $user; - $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d', $cid)); + $comment = db_fetch_object(db_query('SELECT c.*, u.[uid], u.[name] AS [registered_name], u.[data] FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d', $cid)); $comment = drupal_unpack($comment); $comment->name = $comment->uid ? $comment->registered_name : $comment->name; @@ -69,7 +69,7 @@ function comment_reply($node, $pid = NUL // $pid indicates that this is a reply to a comment. if ($pid) { // Load the comment whose cid = $pid - if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = %d', $pid, COMMENT_PUBLISHED))) { + if ($comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.signature, u.picture, u.data FROM [{comments}] c INNER JOIN [{users}] u ON c.[uid] = u.[uid] WHERE c.[cid] = %d AND c.[status] = %d', $pid, COMMENT_PUBLISHED))) { // If that comment exists, make sure that the current comment and the // parent comment both belong to the same parent node. if ($comment->nid != $node->nid) { Index: modules/comment/comment.test =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.test,v retrieving revision 1.14 diff -u -p -r1.14 comment.test --- modules/comment/comment.test 19 Sep 2008 03:11:53 -0000 1.14 +++ modules/comment/comment.test 22 Sep 2008 09:06:48 -0000 @@ -309,7 +309,7 @@ class CommentInterfaceTest extends Comme $this->assertText('This discussion is closed', t('Posting to node with comments disabled')); $this->assertNoField('edit-comment', t('Comment body field found.')); - // Attempt to post to node with read-only comments. + // Attempt to post to node with read-only comments. $this->node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1, 'comment' => COMMENT_NODE_READ_ONLY)); $this->assertTrue($this->node, t('Article node created.')); $this->drupalGet('comment/reply/' . $this->node->nid); @@ -450,14 +450,14 @@ class CommentAnonymous extends CommentHe $this->drupalLogin($this->admin_user); $this->setAnonymousUserComment(FALSE, FALSE); - // Attempt to view comments while disallowed. + // Attempt to view comments while disallowed. // NOTE: if authenticated user has permission to post comments, then a // "Login or register to post comments" type link may be shown. $this->drupalLogout(); $this->drupalGet('node/' . $this->node->nid); $this->assertNoRaw('
    ', t('Comments were not displayed.')); $this->assertNoLink('Add new comment', t('Link to add comment was found.')); - + // Attempt to view node-comment form while disallowed. $this->drupalGet('comment/reply/' . $this->node->nid); $this->assertText('You are not authorized to view comments', t('Error attempting to post comment.')); Index: modules/dblog/dblog.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.admin.inc,v retrieving revision 1.8 diff -u -p -r1.8 dblog.admin.inc --- modules/dblog/dblog.admin.inc 19 Jul 2008 07:44:45 -0000 1.8 +++ modules/dblog/dblog.admin.inc 22 Sep 2008 09:06:48 -0000 @@ -55,14 +55,14 @@ function dblog_overview() { $header = array( ' ', - array('data' => t('Type'), 'field' => 'w.type'), - array('data' => t('Date'), 'field' => 'w.wid', 'sort' => 'desc'), + array('data' => t('Type'), 'field' => 'w.[type]'), + array('data' => t('Date'), 'field' => 'w.[wid]', 'sort' => 'desc'), t('Message'), - array('data' => t('User'), 'field' => 'u.name'), + array('data' => t('User'), 'field' => 'u.[name]'), array('data' => t('Operations')), ); - $sql = "SELECT w.wid, w.uid, w.severity, w.type, w.timestamp, w.message, w.variables, w.link, u.name FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid"; + $sql = "SELECT w.[wid], w.[uid], w.[severity], w.[type], w.[timestamp], w.[message], w.[variables], w.[link], u.[name] FROM [{watchdog}] w INNER JOIN [{users}] u ON w.[uid] = u.[uid]"; $tablesort = tablesort_sql($header); if (!empty($filter['where'])) { $result = pager_query($sql . " WHERE " . $filter['where'] . $tablesort, 50, 0, NULL, $filter['args']); @@ -108,7 +108,7 @@ function dblog_top($type) { array('data' => t('Message'), 'field' => 'message') ); - $result = pager_query("SELECT COUNT(wid) AS count, message, variables FROM {watchdog} WHERE type = '%s' GROUP BY message, variables " . tablesort_sql($header), 30, 0, "SELECT COUNT(DISTINCT(message)) FROM {watchdog} WHERE type = '%s'", $type); + $result = pager_query("SELECT COUNT([wid]) AS [count], [message], [variables] FROM [{watchdog}] WHERE [type] = %s GROUP BY [message], [variables] " . tablesort_sql($header), 30, 0, "SELECT COUNT(DISTINCT([message])) FROM [{watchdog}] WHERE [type] = %s", $type); $rows = array(); while ($dblog = db_fetch_object($result)) { @@ -131,7 +131,7 @@ function dblog_top($type) { function dblog_event($id) { $severity = watchdog_severity_levels(); $output = ''; - $result = db_query('SELECT w.*, u.name, u.uid FROM {watchdog} w INNER JOIN {users} u ON w.uid = u.uid WHERE w.wid = %d', $id); + $result = db_query('SELECT w.*, u.[name], u.[uid] FROM [{watchdog}] w INNER JOIN [{users}] u ON w.[uid] = u.[uid] WHERE w.[wid] = %d', $id); if ($dblog = db_fetch_object($result)) { $rows = array( array( @@ -221,14 +221,14 @@ function dblog_filters() { if (!empty($types)) { $filters['type'] = array( 'title' => t('Type'), - 'where' => "w.type = '%s'", + 'where' => "w.[type] = %s", 'options' => $types, ); } $filters['severity'] = array( 'title' => t('Severity'), - 'where' => 'w.severity = %d', + 'where' => 'w.[severity] = %d', 'options' => watchdog_severity_levels(), ); Index: modules/dblog/dblog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.module,v retrieving revision 1.27 diff -u -p -r1.27 dblog.module --- modules/dblog/dblog.module 21 Aug 2008 19:36:37 -0000 1.27 +++ modules/dblog/dblog.module 22 Sep 2008 09:06:48 -0000 @@ -96,8 +96,8 @@ function dblog_init() { */ function dblog_cron() { // Cleanup the watchdog table - $max = db_result(db_query('SELECT MAX(wid) FROM {watchdog}')); - db_query('DELETE FROM {watchdog} WHERE wid <= %d', $max - variable_get('dblog_row_limit', 1000)); + $max = db_result(db_query('SELECT MAX([wid]) FROM [{watchdog}]')); + db_query('DELETE FROM [{watchdog}] WHERE [wid] <= %d', $max - variable_get('dblog_row_limit', 1000)); } /** @@ -105,14 +105,14 @@ function dblog_cron() { */ function dblog_user($op, &$edit, &$user) { if ($op == 'delete') { - db_query('UPDATE {watchdog} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE [{watchdog}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); } } function _dblog_get_message_types() { $types = array(); - $result = db_query('SELECT DISTINCT(type) FROM {watchdog} ORDER BY type'); + $result = db_query('SELECT DISTINCT([type]) FROM [{watchdog}] ORDER BY [type]'); while ($object = db_fetch_object($result)) { $types[] = $object->type; } @@ -122,10 +122,10 @@ function _dblog_get_message_types() { function dblog_watchdog($log = array()) { $current_db = db_set_active(); - db_query("INSERT INTO {watchdog} - (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) + db_query("INSERT INTO [{watchdog}] + ([uid], [type], [message], [variables], [severity], [link], [location], [referer], [hostname], [timestamp]) VALUES - (%d, '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', %d)", + (%d, %s, %s, %s, %d, %s, %s, %s, %s, %d)", $log['user']->uid, $log['type'], $log['message'], Index: modules/dblog/dblog.test =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.test,v retrieving revision 1.9 diff -u -p -r1.9 dblog.test --- modules/dblog/dblog.test 17 Sep 2008 07:11:56 -0000 1.9 +++ modules/dblog/dblog.test 22 Sep 2008 09:06:48 -0000 @@ -60,7 +60,7 @@ class DBLogTestCase extends DrupalWebTes $current_limit = variable_get('dblog_row_limit', 1000); $this->assertTrue($current_limit == $row_limit, t('[Cache] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); // Verify dblog row limit equals specified row limit. - $current_limit = unserialize(db_result(db_query("SELECT value FROM {variable} WHERE name = '%s'", 'dblog_row_limit'))); + $current_limit = unserialize(db_result(db_query("SELECT [value] FROM [{variable}] WHERE [name] = %s", 'dblog_row_limit'))); $this->assertTrue($current_limit == $row_limit, t('[Variable table] Row limit variable of @count equals row limit of @limit', array('@count' => $current_limit, '@limit' => $row_limit))); } @@ -73,7 +73,7 @@ class DBLogTestCase extends DrupalWebTes // Generate additional log entries. $this->generateLogEntries($row_limit + 10); // Verify dblog row count exceeds row limit. - $count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog}')); + $count = db_result(db_query('SELECT COUNT([wid]) FROM [{watchdog}]')); $this->assertTrue($count > $row_limit, t('Dblog row count of @count exceeds row limit of @limit', array('@count' => $count, '@limit' => $row_limit))); // Run cron job. @@ -81,7 +81,7 @@ class DBLogTestCase extends DrupalWebTes $this->assertResponse(200); $this->assertText(t('Cron ran successfully'), t('Cron ran successfully')); // Verify dblog row count equals row limit plus one because cron adds a record after it runs. - $count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog}')); + $count = db_result(db_query('SELECT COUNT([wid]) FROM [{watchdog}]')); $this->assertTrue($count == $row_limit + 1, t('Dblog row count of @count equals row limit of @limit plus one', array('@count' => $count, '@limit' => $row_limit))); } @@ -199,7 +199,7 @@ class DBLogTestCase extends DrupalWebTes // Logout user. $this->drupalLogout(); // Fetch row ids in watchdog that relate to the user. - $result = db_query('SELECT wid FROM {watchdog} WHERE uid = %d', $user->uid); + $result = db_query('SELECT [wid] FROM [{watchdog}] WHERE [uid] = %d', $user->uid); while ($row = db_fetch_array($result)) { $ids[] = $row['wid']; } @@ -208,7 +208,7 @@ class DBLogTestCase extends DrupalWebTes // Delete user. user_delete(array(), $user->uid); // Count rows that have uids for the user. - $count = db_result(db_query('SELECT COUNT(wid) FROM {watchdog} WHERE uid = %d', $user->uid)); + $count = db_result(db_query('SELECT COUNT([wid]) FROM [{watchdog}] WHERE [uid] = %d', $user->uid)); $this->assertTrue($count == 0, t('DBLog contains @count records for @name', array('@count' => $count, '@name' => $user->name))); // Count rows in watchdog that previously related to the deleted user. @@ -222,7 +222,7 @@ class DBLogTestCase extends DrupalWebTes $this->assertTrue($count_after == $count_before, t('DBLog contains @count records for @name that now have uid = 0', array('@count' => $count_before, '@name' => $user->name))); unset($ids); // Fetch row ids in watchdog that relate to the user. - $result = db_query('SELECT wid FROM {watchdog} WHERE uid = %d', $user->uid); + $result = db_query('SELECT [wid] FROM [{watchdog}] WHERE [uid] = %d', $user->uid); while ($row = db_fetch_array($result)) { $ids[] = $row['wid']; } Index: modules/filter/filter.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v retrieving revision 1.13 diff -u -p -r1.13 filter.admin.inc --- modules/filter/filter.admin.inc 24 Jul 2008 16:27:51 -0000 1.13 +++ modules/filter/filter.admin.inc 22 Sep 2008 09:06:48 -0000 @@ -50,7 +50,7 @@ function filter_admin_overview_submit($f foreach ($form_state['values'] as $id => $data) { if (is_array($data) && isset($data['weight'])) { // Only update if this is a form element with weight. - db_query("UPDATE {filter_formats} SET weight = %d WHERE format = %d", $data['weight'], $id); + db_query("UPDATE [{filter_formats}] SET [weight] = %d WHERE [format] = %d", $data['weight'], $id); } } drupal_set_message(t('The input format ordering has been saved.')); @@ -179,7 +179,7 @@ function filter_admin_format_form(&$form function filter_admin_format_form_validate($form, &$form_state) { if (!isset($form_state['values']['format'])) { $name = trim($form_state['values']['name']); - $result = db_fetch_object(db_query("SELECT format FROM {filter_formats} WHERE name='%s'", $name)); + $result = db_fetch_object(db_query("SELECT [format] FROM [{filter_formats}] WHERE [name] = %s", $name)); if ($result) { form_set_error('name', t('Filter format names need to be unique. A format named %name already exists.', array('%name' => $name))); } @@ -198,21 +198,21 @@ function filter_admin_format_form_submit // Add a new filter format. if (!$format) { $new = TRUE; - db_query("INSERT INTO {filter_formats} (name) VALUES ('%s')", $name); - $format = db_result(db_query("SELECT MAX(format) AS format FROM {filter_formats}")); + db_query("INSERT INTO [{filter_formats}] ([name]) VALUES (%s)", $name); + $format = db_result(db_query("SELECT MAX([format]) AS [format] FROM [{filter_formats}]")); drupal_set_message(t('Added input format %format.', array('%format' => $name))); } else { drupal_set_message(t('The input format settings have been updated.')); } - db_query("DELETE FROM {filters} WHERE format = %d", $format); + db_query("DELETE FROM [{filters}] WHERE [format] = %d", $format); foreach ($form_state['values']['filters'] as $id => $checked) { if ($checked) { list($module, $delta) = explode('/', $id); // Add new filters to the bottom. $weight = isset($current[$id]->weight) ? $current[$id]->weight : 10; - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format, $module, $delta, $weight); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", $format, $module, $delta, $weight); // Check if there are any 'no cache' filters. $cache &= !module_invoke($module, 'filter', 'no cache', $delta); @@ -237,7 +237,7 @@ function filter_admin_format_form_submit $roles = ',' . implode(',', $roles) . ','; } - db_query("UPDATE {filter_formats} SET cache = %d, name='%s', roles = '%s' WHERE format = %d", $cache, $name, $roles, $format); + db_query("UPDATE [{filter_formats}] SET [cache] = %d, [name] = %s, [roles] = %s WHERE [format] = %d", $cache, $name, $roles, $format); cache_clear_all($format . ':', 'cache_filter', TRUE); @@ -258,7 +258,7 @@ function filter_admin_format_form_submit */ function filter_admin_delete() { $format = arg(4); - $format = db_fetch_object(db_query('SELECT * FROM {filter_formats} WHERE format = %d', $format)); + $format = db_fetch_object(db_query('SELECT * FROM [{filter_formats}] WHERE [format] = %d', $format)); if ($format) { if ($format->format != variable_get('filter_default_format', 1)) { @@ -281,14 +281,14 @@ function filter_admin_delete() { * Process filter delete form submission. */ function filter_admin_delete_submit($form, &$form_state) { - db_query("DELETE FROM {filter_formats} WHERE format = %d", $form_state['values']['format']); - db_query("DELETE FROM {filters} WHERE format = %d", $form_state['values']['format']); + db_query("DELETE FROM [{filter_formats}] WHERE [format] = %d", $form_state['values']['format']); + db_query("DELETE FROM [{filters}] WHERE [format] = %d", $form_state['values']['format']); $default = variable_get('filter_default_format', 1); // Replace existing instances of the deleted format with the default format. - db_query("UPDATE {node_revisions} SET format = %d WHERE format = %d", $default, $form_state['values']['format']); - db_query("UPDATE {comments} SET format = %d WHERE format = %d", $default, $form_state['values']['format']); - db_query("UPDATE {boxes} SET format = %d WHERE format = %d", $default, $form_state['values']['format']); + db_query("UPDATE [{node_revisions}] SET [format] = %d WHERE [format] = %d", $default, $form_state['values']['format']); + db_query("UPDATE [{comments}] SET [format] = %d WHERE [format] = %d", $default, $form_state['values']['format']); + db_query("UPDATE [{boxes}] SET [format] = %d WHERE [format] = %d", $default, $form_state['values']['format']); cache_clear_all($form_state['values']['format'] . ':', 'cache_filter', TRUE); drupal_set_message(t('Deleted input format %format.', array('%format' => $form_state['values']['name']))); @@ -402,7 +402,7 @@ function theme_filter_admin_order($form) function filter_admin_order_submit($form, &$form_state) { foreach ($form_state['values']['weights'] as $id => $weight) { list($module, $delta) = explode('/', $id); - db_query("UPDATE {filters} SET weight = %d WHERE format = %d AND module = '%s' AND delta = %d", $weight, $form_state['values']['format'], $module, $delta); + db_query("UPDATE [{filters}] SET [weight] = %d WHERE [format] = %d AND [module] = %s AND [delta] = %d", $weight, $form_state['values']['format'], $module, $delta); } drupal_set_message(t('The filter ordering has been saved.')); Index: modules/filter/filter.install =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v retrieving revision 1.9 diff -u -p -r1.9 filter.install --- modules/filter/filter.install 14 Apr 2008 17:48:37 -0000 1.9 +++ modules/filter/filter.install 22 Sep 2008 09:06:48 -0000 @@ -112,11 +112,11 @@ function filter_update_7000() { */ function filter_update_7001() { $ret = array(); - $result = db_query("SELECT format FROM {filter_formats}"); + $result = db_query("SELECT [format] FROM [{filter_formats}]"); while ($format = db_fetch_object($result)) { // Deprecated constants FILTER_HTML_STRIP = 1 and FILTER_HTML_ESCAPE = 2. if (variable_get('filter_html_' . $format->format, 1) == 2) { - $ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (" . $format->format . ", 'filter', 4, 0)"); + $ret[] = update_sql("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (" . $format->format . ", 'filter', 4, 0)"); } variable_del('filter_html_' . $format->format); } Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.227 diff -u -p -r1.227 filter.module --- modules/filter/filter.module 19 Sep 2008 07:53:59 -0000 1.227 +++ modules/filter/filter.module 22 Sep 2008 09:06:48 -0000 @@ -304,7 +304,7 @@ function filter_formats($index = NULL) { if (!$all) { $or = db_or()->condition('format', variable_get('filter_default_format', 1)); foreach ($user->roles as $rid => $role) { - $or->condition('roles', '%'. (int)$rid .'%', 'LIKE'); + $or->condition('roles', '%' . (int)$rid . '%', 'LIKE'); } $query->condition($or); } @@ -357,7 +357,7 @@ function filter_format_allowcache($forma static $cache = array(); $format = filter_resolve_format($format); if (!isset($cache[$format])) { - $cache[$format] = db_result(db_query('SELECT cache FROM {filter_formats} WHERE format = %d', $format)); + $cache[$format] = db_result(db_query('SELECT [cache] FROM [{filter_formats}] WHERE [format] = %d', $format)); } return $cache[$format]; } @@ -370,7 +370,7 @@ function filter_list_format($format) { if (!isset($filters[$format])) { $filters[$format] = array(); - $result = db_query("SELECT * FROM {filters} WHERE format = %d ORDER BY weight, module, delta", $format); + $result = db_query("SELECT * FROM [{filters}] WHERE [format] = %d ORDER BY [weight], [module], [delta]", $format); while ($filter = db_fetch_object($result)) { $list = module_invoke($filter->module, 'filter', 'list'); if (isset($list) && is_array($list) && isset($list[$filter->delta])) { @@ -552,7 +552,7 @@ function _filter_tips($format, $long = F $formats = filter_formats(); } else { - $formats = array(db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE format = %d", $format))); + $formats = array(db_fetch_object(db_query("SELECT * FROM [{filter_formats}] WHERE [format] = %d", $format))); } $tips = array(); Index: modules/filter/filter.test =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.test,v retrieving revision 1.6 diff -u -p -r1.6 filter.test --- modules/filter/filter.test 15 Aug 2008 07:49:42 -0000 1.6 +++ modules/filter/filter.test 22 Sep 2008 09:06:48 -0000 @@ -44,7 +44,7 @@ class FilterAdminTestCase extends Drupal $this->assertRaw(htmlentities($edit['allowed_html_1']), t('Tag displayed.')); - $result = db_fetch_object(db_query('SELECT * FROM {cache_filter}')); + $result = db_fetch_object(db_query('SELECT * FROM [{cache_filter}]')); $this->assertFalse($result, t('Cache cleared.')); // Reorder filters. @@ -54,7 +54,7 @@ class FilterAdminTestCase extends Drupal $this->drupalPost('admin/settings/filters/' . $filtered . '/order', $edit, t('Save configuration')); $this->assertText(t('The filter ordering has been saved.'), t('Order saved successfully.')); - $result = db_query('SELECT * FROM {filters} WHERE format = %d ORDER BY weight ASC', $filtered); + $result = db_query('SELECT * FROM [{filters}] WHERE [format] = %d ORDER BY [weight] ASC', $filtered); $filters = array(); while ($filter = db_fetch_object($result)) { if ($filter->delta == $second_filter || $filter->delta == $first_filter) { @@ -154,7 +154,7 @@ class FilterAdminTestCase extends Drupal * @return Array Array containing filtered and full filter ids. */ function checkFilterFormats() { - $result = db_query('SELECT format, name FROM {filter_formats}'); + $result = db_query('SELECT [format], [name] FROM [{filter_formats}]'); $filtered = -1; $full = -1; @@ -177,7 +177,7 @@ class FilterAdminTestCase extends Drupal * @return object Filter object. */ function getFilter($name) { - return db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE name = '%s'", $name)); + return db_fetch_object(db_query("SELECT * FROM [{filter_formats}] WHERE [name] = %s", $name)); } } @@ -226,7 +226,7 @@ class FilterTestCase extends DrupalWebTe 'filters[filter/' . $filter . ']' => TRUE, ); $this->drupalPost('admin/settings/filters/add', $edit, t('Save configuration')); - return db_fetch_object(db_query("SELECT * FROM {filter_formats} WHERE name = '%s'", $edit['name'])); + return db_fetch_object(db_query("SELECT * FROM [{filter_formats}] WHERE [name] = %s", $edit['name'])); } function deleteFormat($format) { Index: modules/help/help.test =================================================================== RCS file: /cvs/drupal/drupal/modules/help/help.test,v retrieving revision 1.2 diff -u -p -r1.2 help.test --- modules/help/help.test 30 May 2008 07:30:51 -0000 1.2 +++ modules/help/help.test 22 Sep 2008 09:06:48 -0000 @@ -76,7 +76,7 @@ class HelpTestCase extends DrupalWebTest */ private function getModuleList() { $this->modules = array(); - $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC"); + $result = db_query("SELECT [name], [filename], [info] FROM [{system}] WHERE [type] = 'module' AND [status] = 1 ORDER BY [weight] ASC, [filename] ASC"); while ($module = db_fetch_object($result)) { if (file_exists($module->filename)) { $fullname = unserialize($module->info); Index: modules/locale/locale.install =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.install,v retrieving revision 1.30 diff -u -p -r1.30 locale.install --- modules/locale/locale.install 14 Apr 2008 17:48:37 -0000 1.30 +++ modules/locale/locale.install 22 Sep 2008 09:06:48 -0000 @@ -12,7 +12,7 @@ function locale_install() { // Create tables. drupal_install_schema('locale'); - db_query("INSERT INTO {languages} (language, name, native, direction, enabled, weight, javascript) VALUES ('en', 'English', 'English', '0', '1', '0', '')"); + db_query("INSERT INTO [{languages}] ([language], [name], [native], [direction], [enabled], [weight], [javascript]) VALUES (%s, %s, %s, %d, %d, %d, %s)", 'en', 'English', 'English', '0', '1', '0', ''); } /** @@ -100,17 +100,17 @@ function locale_update_6000() { db_create_table($ret, 'languages', $schema['languages']); // Save the languages - $ret[] = update_sql("INSERT INTO {languages} (language, name, native, direction, enabled, plurals, formula, domain, prefix, weight) SELECT locale, name, name, 0, enabled, plurals, formula, '', locale, 0 FROM {locales_meta}"); + $ret[] = update_sql("INSERT INTO [{languages}] ([language], [name], [native], [direction], [enabled], [plurals], [formula], [domain], [prefix], [weight]) SELECT [locale], [name], [name], 0, [enabled], [plurals], [formula], '', [locale], 0 FROM [{locales_meta}]"); // Save the language count in the variable table - $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1')); + $count = db_result(db_query('SELECT COUNT(*) FROM [{languages}] WHERE [enabled] = 1')); variable_set('language_count', $count); // Save the default language in the variable table - $default = db_fetch_object(db_query('SELECT * FROM {locales_meta} WHERE isdefault = 1')); + $default = db_fetch_object(db_query('SELECT * FROM [{locales_meta}] WHERE [isdefault] = 1')); variable_set('language_default', (object) array('language' => $default->locale, 'name' => $default->name, 'native' => '', 'direction' => 0, 'enabled' => 1, 'plurals' => $default->plurals, 'formula' => $default->formula, 'domain' => '', 'prefix' => $default->locale, 'weight' => 0)); - $ret[] = update_sql("DROP TABLE {locales_meta}"); + $ret[] = update_sql("DROP TABLE [{locales_meta}]"); return $ret; } @@ -122,7 +122,7 @@ function locale_update_6000() { */ function locale_update_6001() { $ret = array(); - $ret[] = update_sql('UPDATE {locales_target} SET language = locale'); + $ret[] = update_sql('UPDATE [{locales_target}] SET [language] = [locale]'); db_drop_field($ret, 'locales_target', 'locale'); return $ret; } @@ -132,7 +132,7 @@ function locale_update_6001() { */ function locale_update_6002() { $ret = array(); - $ret[] = update_sql("DELETE FROM {locales_target} WHERE translation = ''"); + $ret[] = update_sql("DELETE FROM [{locales_target}] WHERE [translation] = ''"); return $ret; } @@ -141,7 +141,7 @@ function locale_update_6002() { */ function locale_update_6003() { $ret = array(); - $ret[] = update_sql("DELETE FROM {locales_source} WHERE lid NOT IN (SELECT lid FROM {locales_target})"); + $ret[] = update_sql("DELETE FROM [{locales_source}] WHERE [lid] NOT IN (SELECT [lid] FROM [{locales_target}])"); return $ret; } @@ -196,7 +196,7 @@ function locale_update_6005() { } } // Update language count variable that might be overwritten. - $count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1')); + $count = db_result(db_query('SELECT COUNT(*) FROM [{languages}] WHERE [enabled] = 1')); variable_set('language_count', $count); return array(); } @@ -210,7 +210,7 @@ function locale_update_6005() { */ function locale_uninstall() { // Delete all JavaScript translation files - $files = db_query('SELECT javascript FROM {languages}'); + $files = db_query('SELECT [javascript] FROM [{languages}]'); while ($file = db_fetch_object($files)) { if (!empty($file)) { file_delete(file_create_path($file->javascript)); @@ -361,7 +361,7 @@ function locale_schema() { ), 'translation' => array( 'type' => 'text', - 'mysql_type' => 'blob', + 'mysql_type' => 'BLOB', 'not null' => TRUE, 'description' => t('Translation string value in this language.'), ), Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.223 diff -u -p -r1.223 locale.module --- modules/locale/locale.module 20 Sep 2008 20:22:24 -0000 1.223 +++ modules/locale/locale.module 22 Sep 2008 09:06:48 -0000 @@ -363,7 +363,7 @@ function locale($string = NULL, $langcod // Refresh database stored cache of translations for given language. // We only store short strings used in current version, to improve // performance and consume less memory. - $result = db_query("SELECT s.source, t.translation, t.language FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.textgroup = 'default' AND s.version = '%s' AND LENGTH(s.source) < 75", $langcode, VERSION); + $result = db_query("SELECT s.[source], t.[translation], t.[language] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = %s WHERE s.[textgroup] = 'default' AND s.[version] = %s AND " . db_strlen() . "(s.[source]) < 75", $langcode, VERSION); while ($data = db_fetch_object($result)) { $locale_t[$langcode][$data->source] = (empty($data->translation) ? TRUE : $data->translation); } @@ -376,7 +376,7 @@ function locale($string = NULL, $langcod if (!isset($locale_t[$langcode][$string])) { // We do not have this translation cached, so get it from the DB. - $translation = db_fetch_object(db_query("SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.source = '%s' AND s.textgroup = 'default'", $langcode, $string)); + $translation = db_fetch_object(db_query("SELECT s.[lid], t.[translation], s.[version] FROM [{locales_source}] s LEFT JOIN [{locales_target}] t ON s.[lid] = t.[lid] AND t.[language] = %s WHERE s.[source] = %s AND s.[textgroup] = 'default'", $langcode, $string)); if ($translation) { // We have the source string at least. // Cache translation string or TRUE if no translation exists. @@ -386,13 +386,13 @@ function locale($string = NULL, $langcod // This is the first use of this string under current Drupal version. Save version // and clear cache, to include the string into caching next time. Saved version is // also a string-history information for later pruning of the tables. - db_query("UPDATE {locales_source} SET version = '%s' WHERE lid = %d", VERSION, $translation->lid); + db_query("UPDATE [{locales_source}] SET [version] = %s WHERE [lid] = %d", VERSION, $translation->lid); cache_clear_all('locale:', 'cache', TRUE); } } else { // We don't have the source string, cache this as untranslated. - db_query("INSERT INTO {locales_source} (location, source, textgroup, version) VALUES ('%s', '%s', 'default', '%s')", request_uri(), $string, VERSION); + db_query("INSERT INTO [{locales_source}] ([location], [source], [textgroup], [version]) VALUES (%s, %s, 'default', %s)", request_uri(), $string, VERSION); $locale_t[$langcode][$string] = TRUE; // Clear locale cache so this string can be added in a later request. cache_clear_all('locale:', 'cache', TRUE); Index: modules/menu/menu.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v retrieving revision 1.33 diff -u -p -r1.33 menu.admin.inc --- modules/menu/menu.admin.inc 18 Sep 2008 10:44:19 -0000 1.33 +++ modules/menu/menu.admin.inc 22 Sep 2008 09:06:48 -0000 @@ -10,7 +10,7 @@ * Menu callback which shows an overview page of all the custom menus and their descriptions. */ function menu_overview_page() { - $result = db_query("SELECT * FROM {menu_custom} ORDER BY title"); + $result = db_query("SELECT * FROM [{menu_custom}] ORDER BY [title]"); $content = array(); while ($menu = db_fetch_array($result)) { $menu['href'] = 'admin/build/menu-customize/' . $menu['menu_name']; @@ -29,10 +29,10 @@ function menu_overview_page() { function menu_overview_form(&$form_state, $menu) { global $menu_admin; $sql = " - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* - FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path - WHERE ml.menu_name = '%s' - ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC"; + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], m.[description], ml.* + FROM [{menu_links}] ml LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] + WHERE ml.[menu_name] = %s + ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC"; $result = db_query($sql, $menu['menu_name']); $tree = menu_tree_data($result); $node_links = array(); @@ -452,7 +452,7 @@ function menu_delete_menu_page($menu) { function menu_delete_menu_confirm(&$form_state, $menu) { $form['#menu'] = $menu; $caption = ''; - $num_links = db_result(db_query("SELECT COUNT(*) FROM {menu_links} WHERE menu_name = '%s'", $menu['menu_name'])); + $num_links = db_result(db_query("SELECT COUNT(*) FROM [{menu_links}] WHERE [menu_name] = %s", $menu['menu_name'])); if ($num_links) { $caption .= '

    ' . format_plural($num_links, 'Warning: There is currently 1 menu item in %title. It will be deleted (system-defined items will be reset).', 'Warning: There are currently @count menu items in %title. They will be deleted (system-defined items will be reset).', array('%title' => $menu['title'])) . '

    '; } @@ -467,25 +467,25 @@ function menu_delete_menu_confirm_submit $menu = $form['#menu']; $form_state['redirect'] = 'admin/build/menu'; // System-defined menus may not be deleted - only menus defined by this module. - if (in_array($menu['menu_name'], menu_list_system_menus()) || !db_result(db_query("SELECT COUNT(*) FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']))) { + if (in_array($menu['menu_name'], menu_list_system_menus()) || !db_result(db_query("SELECT COUNT(*) FROM [{menu_custom}] WHERE [menu_name] = %s", $menu['menu_name']))) { return; } // Reset all the menu links defined by the system via hook_menu. - $result = db_query("SELECT * FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.menu_name = '%s' AND ml.module = 'system' ORDER BY m.number_parts ASC", $menu['menu_name']); + $result = db_query("SELECT * FROM [{menu_links}] ml INNER JOIN [{menu_router}] m ON ml.[router_path] = m.[path] WHERE ml.[menu_name] = %s AND ml.[module] = 'system' ORDER BY m.[number_parts] ASC", $menu['menu_name']); while ($item = db_fetch_array($result)) { menu_reset_item($item); } // Delete all links to the overview page for this menu. - $result = db_query("SELECT mlid FROM {menu_links} ml WHERE ml.link_path = '%s'", 'admin/build/menu-customize/' . $menu['menu_name']); + $result = db_query("SELECT [mlid] FROM [{menu_links}] ml WHERE ml.[link_path] = %s", 'admin/build/menu-customize/' . $menu['menu_name']); while ($m = db_fetch_array($result)) { menu_link_delete($m['mlid']); } // Delete all the links in the menu and the menu from the list of custom menus. - db_query("DELETE FROM {menu_links} WHERE menu_name = '%s'", $menu['menu_name']); - db_query("DELETE FROM {menu_custom} WHERE menu_name = '%s'", $menu['menu_name']); + db_query("DELETE FROM [{menu_links}] WHERE [menu_name] = %s", $menu['menu_name']); + db_query("DELETE FROM [{menu_custom}] WHERE [menu_name] = %s", $menu['menu_name']); // Delete all the blocks for this menu. - db_query("DELETE FROM {blocks} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']); - db_query("DELETE FROM {blocks_roles} WHERE module = 'menu' AND delta = '%s'", $menu['menu_name']); + db_query("DELETE FROM [{blocks}] WHERE [module] = 'menu' AND [delta] = %s", $menu['menu_name']); + db_query("DELETE FROM [{blocks_roles}] WHERE [module] = 'menu' AND [delta] = %s", $menu['menu_name']); menu_cache_clear_all(); cache_clear_all(); $t_args = array('%title' => $menu['title']); @@ -507,8 +507,8 @@ function menu_edit_menu_validate($form, if ($form['#insert']) { // We will add 'menu-' to the menu name to help avoid name-space conflicts. $item['menu_name'] = 'menu-' . $item['menu_name']; - if (db_result(db_query("SELECT menu_name FROM {menu_custom} WHERE menu_name = '%s'", $item['menu_name'])) || - db_result(db_query_range("SELECT menu_name FROM {menu_links} WHERE menu_name = '%s'", $item['menu_name'], 0, 1))) { + if (db_result(db_query("SELECT [menu_name] FROM [{menu_custom}] WHERE [menu_name] = %s", $item['menu_name'])) || + db_result(db_query_range("SELECT [menu_name] FROM [{menu_links}] WHERE [menu_name] = %s", $item['menu_name'], 0, 1))) { form_set_error('menu_name', t('The menu already exists.')); } } @@ -527,13 +527,13 @@ function menu_edit_menu_submit($form, &$ $link['link_path'] = $path . $menu['menu_name']; $link['router_path'] = $path . '%'; $link['module'] = 'menu'; - $link['plid'] = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", 'admin/build/menu', 'system')); + $link['plid'] = db_result(db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = %s AND [module] = %s", 'admin/build/menu', 'system')); menu_link_save($link); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", $menu['menu_name'], $menu['title'], $menu['description']); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", $menu['menu_name'], $menu['title'], $menu['description']); } else { - db_query("UPDATE {menu_custom} SET title = '%s', description = '%s' WHERE menu_name = '%s'", $menu['title'], $menu['description'], $menu['menu_name']); - $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", $path . $menu['menu_name']); + db_query("UPDATE [{menu_custom}] SET [title] = %s, [description] = %s WHERE [menu_name] = %s", $menu['title'], $menu['description'], $menu['menu_name']); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = %s", $path . $menu['menu_name']); while ($m = db_fetch_array($result)) { $link = menu_link_load($m['mlid']); $link['link_title'] = $menu['title']; Index: modules/menu/menu.install =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.install,v retrieving revision 1.13 diff -u -p -r1.13 menu.install --- modules/menu/menu.install 18 Sep 2008 10:44:19 -0000 1.13 +++ modules/menu/menu.install 22 Sep 2008 09:06:48 -0000 @@ -9,9 +9,9 @@ function menu_install() { drupal_install_schema('menu'); $t = get_t(); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'navigation', $t('Navigation'), $t('The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.')); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'main-menu', $t('Main menu'), $t('The Main menu is often used by themes to show the major sections of a site.')); - db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'secondary-menu', $t('Secondary menu'), $t('The Secondary menu is often used for pages like legal notices, contact details, and other navigation items that play a lesser role than the Main menu.')); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", 'navigation', $t('Navigation'), $t('The navigation menu is provided by Drupal and is the main interactive menu for any site. It is usually the only menu that contains personalized links for authenticated users, and is often not even visible to anonymous users.')); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", 'main-menu', $t('Main menu'), $t('The Main menu is often used by themes to show the major sections of a site.')); + db_query("INSERT INTO [{menu_custom}] ([menu_name], [title], [description]) VALUES (%s, %s, %s)", 'secondary-menu', $t('Secondary menu'), $t('The Secondary menu is often used for pages like legal notices, contact details, and other navigation items that play a lesser role than the Main menu.')); } /** Index: modules/menu/menu.module =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v retrieving revision 1.168 diff -u -p -r1.168 menu.module --- modules/menu/menu.module 15 Sep 2008 20:48:08 -0000 1.168 +++ modules/menu/menu.module 22 Sep 2008 09:06:48 -0000 @@ -151,15 +151,15 @@ function menu_theme() { */ function menu_enable() { menu_rebuild(); - $link = db_fetch_array(db_query("SELECT mlid AS plid, menu_name from {menu_links} WHERE link_path = 'admin/build/menu' AND module = 'system'")); + $link = db_fetch_array(db_query("SELECT [mlid] AS [plid], [menu_name] FROM [{menu_links}] WHERE [link_path] = %s AND [module] = %s", 'admin/build/menu', 'system')); $link['router_path'] = 'admin/build/menu-customize/%'; $link['module'] = 'menu'; - $result = db_query("SELECT * FROM {menu_custom}"); + $result = db_query("SELECT * FROM [{menu_custom}]"); while ($menu = db_fetch_array($result)) { $link['mlid'] = 0; $link['link_title'] = $menu['title']; $link['link_path'] = 'admin/build/menu-customize/' . $menu['menu_name']; - if (!db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND plid = %d", $link['link_path'], $link['plid']))) { + if (!db_result(db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = %s AND [plid] = %d", $link['link_path'], $link['plid']))) { menu_link_save($link); } } @@ -177,7 +177,7 @@ function menu_overview_title($menu) { * Load the data for a single custom menu. */ function menu_load($menu_name) { - return db_fetch_array(db_query("SELECT * FROM {menu_custom} WHERE menu_name = '%s'", $menu_name)); + return db_fetch_array(db_query("SELECT * FROM [{menu_custom}] WHERE [menu_name] = %s", $menu_name)); } /** @@ -302,7 +302,7 @@ function menu_nodeapi(&$node, $op) { break; case 'delete': // Delete all menu module links that point to this node. - $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu'", array(':path' => 'node/'. $node->nid)); + $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = :path AND [module] = 'menu'", array(':path' => 'node/'. $node->nid)); while ($m = db_fetch_array($result)) { menu_link_delete($m['mlid']); } @@ -314,13 +314,13 @@ function menu_nodeapi(&$node, $op) { $item = array(); if (isset($node->nid)) { // Give priority to the default menu - $mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", array( + $mlid = db_result(db_query_range("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = :path AND [menu_name] = :menu_name AND [module] = 'menu' ORDER BY [mlid] ASC", array( ':path' => 'node/'. $node->nid, ':menu_name' => $menu_name, ), 0, 1)); // Check all menus if a link does not exist in the default menu. if (!$mlid) { - $mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu' ORDER BY mlid ASC", array( + $mlid = db_result(db_query_range("SELECT [mlid] FROM [{menu_links}] WHERE [link_path] = :path AND [module] = 'menu' ORDER BY [mlid] ASC", array( ':path' => 'node/'. $node->nid, ), 0, 1)); } Index: modules/menu/menu.test =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.test,v retrieving revision 1.2 diff -u -p -r1.2 menu.test --- modules/menu/menu.test 30 May 2008 07:30:51 -0000 1.2 +++ modules/menu/menu.test 22 Sep 2008 09:06:48 -0000 @@ -199,7 +199,7 @@ class MenuTestCase extends DrupalWebTest $this->assertText($title, 'Menu item was added'); // Retrieve menu item. - $item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE link_title = '%s'", $title)); + $item = db_fetch_array(db_query("SELECT * FROM [{menu_links}] WHERE [link_title] = %s", $title)); // Check the structure in the DB of the two menu items. // In general, if $n = $item['depth'] then $item['p'. $n] == $item['mlid'] and $item['p' . ($n - 1)] == $item['plid'] (unless depth == 0). @@ -374,7 +374,7 @@ class MenuTestCase extends DrupalWebTest private function getStandardMenuItem() { // Retrieve menu link id (presumably the Log out menu item, but not necessary). - $mlid = db_result(db_query("SELECT MIN(mlid) FROM {menu_links} WHERE module = 'system' AND hidden = 0 AND has_children = 0")); + $mlid = db_result(db_query("SELECT MIN([mlid]) FROM [{menu_links}] WHERE [module] = 'system' AND [hidden] = 0 AND [has_children] = 0")); $this->assertTrue($mlid > 0, 'Standard menu link id was found'); // Load menu item. // Use api function so that link is translated for rendering. Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.57 diff -u -p -r1.57 content_types.inc --- modules/node/content_types.inc 16 Jul 2008 21:59:27 -0000 1.57 +++ modules/node/content_types.inc 22 Sep 2008 09:06:48 -0000 @@ -383,7 +383,7 @@ function node_type_delete_confirm(&$form $message = t('Are you sure you want to delete the content type %type?', array('%type' => $type->name)); $caption = ''; - $num_nodes = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE type = '%s'", $type->type)); + $num_nodes = db_result(db_query("SELECT COUNT(*) FROM [{node}] WHERE [type] = %s", $type->type)); if ($num_nodes) { $caption .= '

    ' . format_plural($num_nodes, 'Warning: there is currently 1 %type post on your site. It may not be able to be displayed or edited correctly, once you have removed this content type.', 'Warning: there are currently @count %type posts on your site. They may not be able to be displayed or edited correctly, once you have removed this content type.', array('%type' => $type->name)) . '

    '; } Index: modules/node/node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.26 diff -u -p -r1.26 node.admin.inc --- modules/node/node.admin.inc 15 Sep 2008 20:48:08 -0000 1.26 +++ modules/node/node.admin.inc 22 Sep 2008 09:06:48 -0000 @@ -13,7 +13,7 @@ function node_configure() { // Only show rebuild button if there are either 0, or 2 or more, rows // in the {node_access} table, or if there are modules that // implement hook_node_grants(). - if (db_result(db_query('SELECT COUNT(*) FROM {node_access}')) != 1 || count(module_implements('node_grants')) > 0) { + if (db_result(db_query('SELECT COUNT(*) FROM [{node_access}]')) != 1 || count(module_implements('node_grants')) > 0) { $status = '

    ' . t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Possible causes for permission problems are disabling modules or configuration changes to permissions. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings.') . '

    '; $status .= '

    ' . t('Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.') . '

    '; @@ -181,18 +181,18 @@ function node_build_filter_query() { case 'status': // Note: no exploitable hole as $key/$value have already been checked when submitted list($key, $value) = explode('-', $value, 2); - $where[] = 'n.' . $key . ' = %d'; + $where[] = 'n.[' . $key . '] = %d'; break; case 'category': $table = "tn$index"; - $where[] = "$table.tid = %d"; - $join .= "INNER JOIN {term_node} $table ON n.nid = $table.nid "; + $where[] = "$table.[tid] = %d"; + $join .= "INNER JOIN [{term_node}] $table ON n.[nid] = $table.[nid] "; break; case 'type': - $where[] = "n.type = '%s'"; + $where[] = "n.[type] = %s"; break; case 'language': - $where[] = "n.language = '%s'"; + $where[] = "n.[language] = %s"; break; } $args[] = $value; @@ -456,7 +456,7 @@ function node_admin_content($form_state) function node_admin_nodes() { // Enable language column if translation module is enabled // or if we have any node with language. - $multilanguage = (module_exists('translation') || db_result(db_query("SELECT COUNT(*) FROM {node} WHERE language != ''"))); + $multilanguage = (module_exists('translation') || db_result(db_query("SELECT COUNT(*) FROM [{node}] WHERE [language] <> %s", ''))); // Build the sortable table header. $header = array(); @@ -480,7 +480,7 @@ function node_admin_nodes() { $filter = node_build_filter_query(); $sort = tablesort_sql($header, '', 'n.changed DESC'); - $result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']); + $result = pager_query(db_rewrite_sql('SELECT n.*, u.[name] FROM [{node}] n '. $filter['join'] .' INNER JOIN [{users}] u ON n.[uid] = u.[uid] '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']); // Build the 'Update options' form. $form['options'] = array( @@ -623,7 +623,7 @@ function node_multiple_delete_confirm(&$ $form['nodes'] = array('#prefix' => '', '#tree' => TRUE); // array_filter returns only elements with TRUE values foreach ($nodes as $nid => $value) { - $title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid)); + $title = db_result(db_query('SELECT [title] FROM [{node}] WHERE [nid] = %d', $nid)); $form['nodes'][$nid] = array( '#type' => 'hidden', '#value' => $nid, Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.977 diff -u -p -r1.977 node.module --- modules/node/node.module 17 Sep 2008 20:37:32 -0000 1.977 +++ modules/node/node.module 22 Sep 2008 09:06:48 -0000 @@ -142,7 +142,7 @@ function node_theme() { * Implementation of hook_cron(). */ function node_cron() { - db_query('DELETE FROM {history} WHERE timestamp < %d', NODE_NEW_LIMIT); + db_query('DELETE FROM [{history}] WHERE [timestamp] < %d', NODE_NEW_LIMIT); } /** @@ -188,10 +188,10 @@ function node_tag_new($nid) { if ($user->uid) { if (node_last_viewed($nid)) { - db_query('UPDATE {history} SET timestamp = %d WHERE uid = %d AND nid = %d', REQUEST_TIME, $user->uid, $nid); + db_query('UPDATE [{history}] SET [timestamp] = %d WHERE [uid] = %d AND [nid] = %d', REQUEST_TIME, $user->uid, $nid); } else { - @db_query('INSERT INTO {history} (uid, nid, timestamp) VALUES (%d, %d, %d)', $user->uid, $nid, REQUEST_TIME); + @db_query('INSERT INTO [{history}] ([uid], [nid], [timestamp]) VALUES (%d, %d, %d)', $user->uid, $nid, REQUEST_TIME); } } } @@ -205,7 +205,7 @@ function node_last_viewed($nid) { static $history; if (!isset($history[$nid])) { - $history[$nid] = db_fetch_object(db_query("SELECT timestamp FROM {history} WHERE uid = %d AND nid = %d", $user->uid, $nid)); + $history[$nid] = db_fetch_object(db_query("SELECT [timestamp] FROM [{history}] WHERE [uid] = %d AND [nid] = %d", $user->uid, $nid)); } return (isset($history[$nid]->timestamp) ? $history[$nid]->timestamp : 0); @@ -507,7 +507,7 @@ function node_types_rebuild() { function node_type_save($info) { $is_existing = FALSE; $existing_type = !empty($info->old_type) ? $info->old_type : $info->type; - $is_existing = db_result(db_query("SELECT COUNT(*) FROM {node_type} WHERE type = '%s'", $existing_type)); + $is_existing = db_result(db_query("SELECT COUNT(*) FROM [{node_type}] WHERE [type] = %s", $existing_type)); if (!isset($info->help)) { $info->help = ''; } @@ -525,13 +525,13 @@ function node_type_save($info) { } if ($is_existing) { - db_query("UPDATE {node_type} SET type = '%s', name = '%s', module = '%s', has_title = %d, title_label = '%s', has_body = %d, body_label = '%s', description = '%s', help = '%s', min_word_count = %d, custom = %d, modified = %d, locked = %d WHERE type = '%s'", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type); + db_query("UPDATE [{node_type}] SET [type] = %s, [name] = %s, [module] = %s, [has_title] = %d, [title_label] = %s, [has_body] = %d, [body_label] = %s, [description] = %s, [help] = %s, [min_word_count] = %d, [custom] = %d, [modified] = %d, [locked] = %d WHERE [type] = %s", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $existing_type); module_invoke_all('node_type', 'update', $info); return SAVED_UPDATED; } else { - db_query("INSERT INTO {node_type} (type, name, module, has_title, title_label, has_body, body_label, description, help, min_word_count, custom, modified, locked, orig_type) VALUES ('%s', '%s', '%s', %d, '%s', %d, '%s', '%s', '%s', %d, %d, %d, %d, '%s')", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $info->orig_type); + db_query("INSERT INTO [{node_type}] ([type], [name], [module], [has_title], [title_label], [has_body], [body_label], [description], [help], [min_word_count], [custom], [modified], [locked], [orig_type]) VALUES (%s, %s, %s, %d, %s, %d, %s, %s, %s, %d, %d, %d, %d, %s)", $info->type, $info->name, $info->module, $info->has_title, $info->title_label, $info->has_body, $info->body_label, $info->description, $info->help, $info->min_word_count, $info->custom, $info->modified, $info->locked, $info->orig_type); module_invoke_all('node_type', 'insert', $info); return SAVED_NEW; @@ -546,7 +546,7 @@ function node_type_save($info) { */ function node_type_delete($type) { $info = node_get_types('type', $type); - db_query("DELETE FROM {node_type} WHERE type = '%s'", $type); + db_query("DELETE FROM [{node_type}] WHERE [type] = %s", $type); module_invoke_all('node_type', 'delete', $info); } @@ -562,7 +562,7 @@ function node_type_delete($type) { * The number of nodes whose node type field was modified. */ function node_type_update_nodes($old_type, $type) { - db_query("UPDATE {node} SET type = '%s' WHERE type = '%s'", $type, $old_type); + db_query("UPDATE [{node}] SET [type] = %s WHERE [type] = %s", $type, $old_type); return db_affected_rows(); } @@ -584,7 +584,7 @@ function _node_types_build() { $_node_names[$type] = $info['name']; } - $type_result = db_query(db_rewrite_sql('SELECT nt.type, nt.* FROM {node_type} nt ORDER BY nt.type ASC', 'nt', 'type')); + $type_result = db_query(db_rewrite_sql('SELECT nt.[type], nt.* FROM [{node_type}] nt ORDER BY nt.[type] ASC', 'nt', 'type')); while ($type_object = db_fetch_object($type_result)) { // Check for node types from disabled modules and mark their types for removal. // Types defined by the node module in the database (rather than by a separate @@ -746,13 +746,13 @@ function node_load($param = array(), $re return is_object($nodes[$param]) ? clone $nodes[$param] : $nodes[$param]; } } - $cond = 'n.nid = %d'; + $cond = 'n.[nid] = %d'; $arguments[] = $param; } elseif (is_array($param)) { // Turn the conditions into a query. foreach ($param as $key => $value) { - $cond[] = 'n.' . db_escape_table($key) . " = '%s'"; + $cond[] = 'n.[' . db_escape_table($key) . "] = %s"; $arguments[] = $value; } $cond = implode(' AND ', $cond); @@ -764,25 +764,25 @@ function node_load($param = array(), $re // Retrieve a field list based on the site's schema. $fields = drupal_schema_fields_sql('node', 'n'); $fields = array_merge($fields, drupal_schema_fields_sql('node_revisions', 'r')); - $fields = array_merge($fields, array('u.name', 'u.picture', 'u.data')); + $fields = array_merge($fields, array('u.[name]', 'u.[picture]', 'u.[data]')); // Remove fields not needed in the query: n.vid and r.nid are redundant, // n.title is unnecessary because the node title comes from the // node_revisions table. We'll keep r.vid, r.title, and n.nid. - $fields = array_diff($fields, array('n.vid', 'n.title', 'r.nid')); + $fields = array_diff($fields, array('n.[vid]', 'n.[title]', 'r.[nid]')); $fields = implode(', ', $fields); // Rename timestamp field for clarity. - $fields = str_replace('r.timestamp', 'r.timestamp AS revision_timestamp', $fields); + $fields = str_replace('r.[timestamp]', 'r.[timestamp] AS [revision_timestamp]', $fields); // Change name of revision uid so it doesn't conflict with n.uid. - $fields = str_replace('r.uid', 'r.uid AS revision_uid', $fields); + $fields = str_replace('r.[uid]', 'r.[uid] AS [revision_uid]', $fields); // Retrieve the node. // No db_rewrite_sql is applied so as to get complete indexing for search. if ($revision) { array_unshift($arguments, $revision); - $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE ' . $cond, $arguments)); + $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM [{node}] n INNER JOIN [{users}] u ON u.[uid] = n.[uid] INNER JOIN [{node_revisions}] r ON r.[nid] = n.[nid] AND r.[vid] = %d WHERE ' . $cond, $arguments)); } else { - $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE ' . $cond, $arguments)); + $node = db_fetch_object(db_query('SELECT ' . $fields . ' FROM [{node}] n INNER JOIN [{users}] u ON u.[uid] = n.[uid] INNER JOIN [{node_revisions}] r ON r.[vid] = n.[vid] WHERE ' . $cond, $arguments)); } if ($node && $node->nid) { @@ -959,7 +959,7 @@ function node_save(&$node) { $op = 'update'; } if ($update_node) { - db_query('UPDATE {node} SET vid = %d WHERE nid = %d', $node->vid, $node->nid); + db_query('UPDATE [{node}] SET [vid] = %d WHERE [nid] = %d', $node->vid, $node->nid); } // Call the node specific callback (if any). This can be @@ -1001,8 +1001,8 @@ function node_delete($nid) { $node = node_load($nid); if (node_access('delete', $node)) { - db_query('DELETE FROM {node} WHERE nid = %d', $node->nid); - db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{node}] WHERE [nid] = %d', $node->nid); + db_query('DELETE FROM [{node_revisions}] WHERE [nid] = %d', $node->nid); // Call the node-specific callback (if any): node_invoke($node, 'delete'); @@ -1221,12 +1221,12 @@ function node_search($op = 'search', $ke return t('Content'); case 'reset': - db_query("UPDATE {search_dataset} SET reindex = %d WHERE type = 'node'", REQUEST_TIME); + db_query("UPDATE [{search_dataset}] SET [reindex] = %d WHERE [type] = 'node'", REQUEST_TIME); return; case 'status': - $total = db_result(db_query('SELECT COUNT(*) FROM {node} WHERE status = 1')); - $remaining = db_result(db_query("SELECT COUNT(*) FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE n.status = 1 AND d.sid IS NULL OR d.reindex <> 0")); + $total = db_result(db_query('SELECT COUNT(*) FROM [{node}] WHERE [status] = 1')); + $remaining = db_result(db_query("SELECT COUNT(*) FROM [{node}] n LEFT JOIN [{search_dataset}] d ON d.[type] = 'node' AND d.[sid] = n.[nid] WHERE n.[status] = 1 AND d.[sid] IS NULL OR d.[reindex] <> 0")); return array('remaining' => $remaining, 'total' => $total); case 'admin': @@ -1257,12 +1257,12 @@ function node_search($op = 'search', $ke // Build matching conditions list($join1, $where1) = _db_rewrite_sql(); $arguments1 = array(); - $conditions1 = 'n.status = 1'; + $conditions1 = 'n.[status] = 1'; if ($type = search_query_extract($keys, 'type')) { $types = array(); foreach (explode(',', $type) as $t) { - $types[] = "n.type = '%s'"; + $types[] = "n.[type] = %s"; $arguments1[] = $t; } $conditions1 .= ' AND (' . implode(' OR ', $types) . ')'; @@ -1272,18 +1272,18 @@ function node_search($op = 'search', $ke if ($category = search_query_extract($keys, 'category')) { $categories = array(); foreach (explode(',', $category) as $c) { - $categories[] = "tn.tid = %d"; + $categories[] = "tn.[tid] = %d"; $arguments1[] = $c; } $conditions1 .= ' AND (' . implode(' OR ', $categories) . ')'; - $join1 .= ' INNER JOIN {term_node} tn ON n.vid = tn.vid'; + $join1 .= ' INNER JOIN [{term_node}] tn ON n.[vid] = tn.[vid]'; $keys = search_query_insert($keys, 'category'); } if ($languages = search_query_extract($keys, 'language')) { $categories = array(); foreach (explode(',', $languages) as $l) { - $categories[] = "n.language = '%s'"; + $categories[] = "n.[language] = %s"; $arguments1[] = $l; } $conditions1 .= ' AND (' . implode(' OR ', $categories) . ')'; @@ -1299,17 +1299,17 @@ function node_search($op = 'search', $ke $total = 1; $arguments2 = array(); $join2 = ''; - $select2 = 'i.relevance AS score'; + $select2 = 'i.[relevance] AS [score]'; } else { $total = $rankings['total']; $arguments2 = $rankings['arguments']; $join2 = implode(' ', $rankings['join']); - $select2 = '('. implode(' + ', $rankings['score']) .') AS score'; + $select2 = '('. implode(' + ', $rankings['score']) .') AS [score]'; } // Do search. - $find = do_search($keys, 'node', 'INNER JOIN {node} n ON n.nid = i.sid ' . $join1, $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2); + $find = do_search($keys, 'node', 'INNER JOIN [{node}] n ON n.[nid] = i.[sid] ' . $join1, $conditions1 . (empty($where1) ? '' : ' AND ' . $where1), $arguments1, $select2, $join2, $arguments2); // Load results. $results = array(); @@ -1383,8 +1383,8 @@ function node_ranking() { */ function node_user($op, &$edit, &$user) { if ($op == 'delete') { - db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid); - db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE [{node}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); + db_query('UPDATE [{node_revisions}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); } } @@ -1416,7 +1416,7 @@ function theme_node_search_admin($form) function node_comment_mode($nid) { static $comment_mode; if (!isset($comment_mode[$nid])) { - $comment_mode[$nid] = db_result(db_query('SELECT comment FROM {node} WHERE nid = %d', $nid)); + $comment_mode[$nid] = db_result(db_query('SELECT [comment] FROM [{node}] WHERE [nid] = %d', $nid)); } return $comment_mode[$nid]; } @@ -1452,7 +1452,7 @@ function _node_revision_access($node, $o // different revisions so there is no need for a separate database check. // Also, if you try to revert to or delete the current revision, that's // not good. - if ($is_current_revision && (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) == 1 || $op == 'update' || $op == 'delete')) { + if ($is_current_revision && (db_result(db_query('SELECT COUNT([vid]) FROM [{node_revisions}] WHERE [nid] = %d', $node->nid)) == 1 || $op == 'update' || $op == 'delete')) { $access[$node->vid] = FALSE; } elseif (user_access('administer nodes')) { @@ -1661,7 +1661,7 @@ function node_init() { } function node_last_changed($nid) { - $node = db_fetch_object(db_query('SELECT changed FROM {node} WHERE nid = %d', $nid)); + $node = db_fetch_object(db_query('SELECT [changed] FROM [{node}] WHERE [nid] = %d', $nid)); return ($node->changed); } @@ -1670,7 +1670,7 @@ function node_last_changed($nid) { */ function node_revision_list($node) { $revisions = array(); - $result = db_query('SELECT r.vid, r.title, r.log, r.uid, n.vid AS current_vid, r.timestamp, u.name FROM {node_revisions} r LEFT JOIN {node} n ON n.vid = r.vid INNER JOIN {users} u ON u.uid = r.uid WHERE r.nid = %d ORDER BY r.timestamp DESC', $node->nid); + $result = db_query('SELECT r.[vid], r.[title], r.[log], r.[uid], n.[vid] AS [current_vid], r.[timestamp], u.[name] FROM [{node_revisions}] r LEFT JOIN [{node}] n ON n.[vid] = r.[vid] INNER JOIN [{users}] u ON u.[uid] = r.[uid] WHERE r.[nid] = %d ORDER BY r.[timestamp] DESC', $node->nid); while ($revision = db_fetch_object($result)) { $revisions[$revision->vid] = $revision; } @@ -1712,7 +1712,7 @@ function node_feed($nids = FALSE, $chann if ($nids === FALSE) { $nids = array(); - $result = db_query_range(db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10)); + $result = db_query_range(db_rewrite_sql('SELECT n.[nid], n.[created] FROM [{node}] n WHERE n.[promote] = 1 AND n.[status] = 1 ORDER BY n.[created] DESC'), 0, variable_get('feed_default_items', 10)); while ($row = db_fetch_object($result)) { $nids[] = $row->nid; } @@ -1793,7 +1793,7 @@ function node_feed($nids = FALSE, $chann * Menu callback; Generate a listing of promoted nodes. */ function node_page_default() { - $result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10)); + $result = pager_query(db_rewrite_sql('SELECT n.[nid], n.[sticky], n.[created] FROM [{node}] n WHERE n.[promote] = 1 AND n.[status] = 1 ORDER BY n.[sticky] DESC, n.[created] DESC'), variable_get('default_nodes_main', 10)); $output = ''; $num_rows = FALSE; @@ -1840,10 +1840,10 @@ function node_update_index() { $limit = (int)variable_get('search_cron_limit', 100); // Store the maximum possible comments per thread (used for ranking by reply count) - variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}')))); - variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}')))); + variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX([comment_count]) FROM [{node_comment_statistics}]')))); + variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX([totalcount]) FROM [{node_counter}]')))); - $result = db_query_range("SELECT n.nid FROM {node} n LEFT JOIN {search_dataset} d ON d.type = 'node' AND d.sid = n.nid WHERE d.sid IS NULL OR d.reindex <> 0 ORDER BY d.reindex ASC, n.nid ASC", 0, $limit); + $result = db_query_range("SELECT n.[nid] FROM [{node}] n LEFT JOIN [{search_dataset}] d ON d.[type] = 'node' AND d.[sid] = n.[nid] WHERE d.[sid] IS NULL OR d.[reindex] <> 0 ORDER BY d.[reindex] ASC, n.[nid] ASC", 0, $limit); while ($node = db_fetch_object($result)) { _node_index_node($node); @@ -2101,7 +2101,7 @@ function node_access($op, $node, $accoun $grants = array(); foreach (node_access_grants($op, $account) as $realm => $gids) { foreach ($gids as $gid) { - $grants[] = "(gid = $gid AND realm = '$realm')"; + $grants[] = "([gid] = $gid AND [realm] = '$realm')"; } } @@ -2110,7 +2110,7 @@ function node_access($op, $node, $accoun $grants_sql = 'AND (' . implode(' OR ', $grants) . ')'; } - $sql = "SELECT COUNT(*) FROM {node_access} WHERE (nid = 0 OR nid = %d) $grants_sql AND grant_$op >= 1"; + $sql = "SELECT COUNT(*) FROM [{node_access}] WHERE ([nid] = 0 OR [nid] = %d) $grants_sql AND [grant_$op] >= 1"; $result = db_query($sql, $node->nid); return (db_result($result)); } @@ -2140,7 +2140,7 @@ function _node_access_join_sql($node_ali return ''; } - return 'INNER JOIN {node_access} ' . $node_access_alias . ' ON ' . $node_access_alias . '.nid = ' . $node_alias . '.nid'; + return 'INNER JOIN [{node_access}] ' . $node_access_alias . ' ON ' . $node_access_alias . '.[nid] = ' . $node_alias . '.[nid]'; } /** @@ -2165,7 +2165,7 @@ function _node_access_where_sql($op = 'v $grants = array(); foreach (node_access_grants($op, $account) as $realm => $gids) { foreach ($gids as $gid) { - $grants[] = "($node_access_alias.gid = $gid AND $node_access_alias.realm = '$realm')"; + $grants[] = "($node_access_alias.[gid] = $gid AND $node_access_alias.[realm] = '$realm')"; } } @@ -2174,7 +2174,7 @@ function _node_access_where_sql($op = 'v $grants_sql = 'AND (' . implode(' OR ', $grants) . ')'; } - $sql = "$node_access_alias.grant_$op >= 1 $grants_sql"; + $sql = "$node_access_alias.[grant_$op] >= 1 $grants_sql"; return $sql; } @@ -2213,7 +2213,7 @@ function node_access_view_all_nodes() { $grants = array(); foreach (node_access_grants('view') as $realm => $gids) { foreach ($gids as $gid) { - $grants[] = "(gid = $gid AND realm = '$realm')"; + $grants[] = "([gid] = $gid AND [realm] = '$realm')"; } } @@ -2222,7 +2222,7 @@ function node_access_view_all_nodes() { $grants_sql = 'AND (' . implode(' OR ', $grants) . ')'; } - $sql = "SELECT COUNT(*) FROM {node_access} WHERE nid = 0 $grants_sql AND grant_view >= 1"; + $sql = "SELECT COUNT(*) FROM [{node_access}] WHERE [nid] = 0 $grants_sql AND [grant_view] >= 1"; $result = db_query($sql); $access = db_result($result); } @@ -2342,7 +2342,7 @@ function node_access_write_grants($node, } // Only write grants; denies are implicit. if ($grant['grant_view'] || $grant['grant_update'] || $grant['grant_delete']) { - db_query("INSERT INTO {node_access} (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (%d, '%s', %d, %d, %d, %d)", $node->nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']); + db_query("INSERT INTO [{node_access}] ([nid], [realm], [gid], [grant_view], [grant_update], [grant_delete]) VALUES (%d, %s, %d, %d, %d, %d)", $node->nid, $grant['realm'], $grant['gid'], $grant['grant_view'], $grant['grant_update'], $grant['grant_delete']); } } } @@ -2400,7 +2400,7 @@ function node_access_needs_rebuild($rebu * hook_taxonomy, hook_node_type...) might consider using the non-batch mode. */ function node_access_rebuild($batch_mode = FALSE) { - db_query("DELETE FROM {node_access}"); + db_query("DELETE FROM [{node_access}]"); // Only recalculate if the site is using a node_access module. if (count(module_implements('node_grants'))) { if ($batch_mode) { @@ -2418,7 +2418,7 @@ function node_access_rebuild($batch_mode if (!ini_get('safe_mode')) { set_time_limit(240); } - $result = db_query("SELECT nid FROM {node}"); + $result = db_query("SELECT [nid] FROM [{node}]"); while ($node = db_fetch_object($result)) { $loaded_node = node_load($node->nid, NULL, TRUE); // To preserve database integrity, only aquire grants if the node @@ -2431,7 +2431,7 @@ function node_access_rebuild($batch_mode } else { // Not using any node_access modules. Add the default grant. - db_query("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0)"); + db_query("INSERT INTO [{node_access}] VALUES (0, 0, 'all', 1, 0, 0)"); } if (!isset($batch)) { @@ -2453,12 +2453,12 @@ function _node_access_rebuild_batch_oper // Initiate multistep processing. $context['sandbox']['progress'] = 0; $context['sandbox']['current_node'] = 0; - $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT nid) FROM {node}')); + $context['sandbox']['max'] = db_result(db_query('SELECT COUNT(DISTINCT [nid]) FROM [{node}]')); } // Process the next 20 nodes. $limit = 20; - $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit); + $result = db_query_range("SELECT [nid] FROM [{node}] WHERE [nid] > %d ORDER BY [nid] ASC", $context['sandbox']['current_node'], 0, $limit); while ($row = db_fetch_array($result)) { $loaded_node = node_load($row['nid'], NULL, TRUE); // To preserve database integrity, only aquire grants if the node @@ -2771,22 +2771,22 @@ function node_save_action($node) { */ function node_assign_owner_action(&$node, $context) { $node->uid = $context['owner_uid']; - $owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid'])); + $owner_name = db_result(db_query("SELECT [name] FROM [{users}] WHERE [uid] = %d", $context['owner_uid'])); watchdog('action', 'Changed owner of @type %title to uid %name.', array('@type' => node_get_types('type', $node), '%title' => $node->title, '%name' => $owner_name)); } function node_assign_owner_action_form($context) { $description = t('The username of the user to which you would like to assign ownership.'); - $count = db_result(db_query("SELECT COUNT(*) FROM {users}")); + $count = db_result(db_query("SELECT COUNT(*) FROM [{users}]")); $owner_name = ''; if (isset($context['owner_uid'])) { - $owner_name = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", $context['owner_uid'])); + $owner_name = db_result(db_query("SELECT [name] FROM [{users}] WHERE [uid] = %d", $context['owner_uid'])); } // Use dropdown for fewer than 200 users; textbox for more than that. if (intval($count) < 200) { $options = array(); - $result = db_query("SELECT uid, name FROM {users} WHERE uid > 0 ORDER BY name"); + $result = db_query("SELECT [uid], [name] FROM [{users}] WHERE [uid] > 0 ORDER BY [name]"); while ($data = db_fetch_object($result)) { $options[$data->name] = $data->name; } @@ -2813,7 +2813,7 @@ function node_assign_owner_action_form($ } function node_assign_owner_action_validate($form, $form_state) { - $count = db_result(db_query("SELECT COUNT(*) FROM {users} WHERE name = '%s'", $form_state['values']['owner_name'])); + $count = db_result(db_query("SELECT COUNT(*) FROM [{users}] WHERE [name] = %s", $form_state['values']['owner_name'])); if (intval($count) != 1) { form_set_error('owner_name', t('Please enter a valid username.')); } @@ -2821,7 +2821,7 @@ function node_assign_owner_action_valida function node_assign_owner_action_submit($form, $form_state) { // Username can change, so we need to store the ID, not the username. - $uid = db_result(db_query("SELECT uid from {users} WHERE name = '%s'", $form_state['values']['owner_name'])); + $uid = db_result(db_query("SELECT [uid] from [{users}] WHERE [name] = %s", $form_state['values']['owner_name'])); return array('owner_uid' => $uid); } Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.37 diff -u -p -r1.37 node.pages.inc --- modules/node/node.pages.inc 19 Sep 2008 07:39:00 -0000 1.37 +++ modules/node/node.pages.inc 22 Sep 2008 09:06:49 -0000 @@ -575,12 +575,12 @@ function node_revision_delete_confirm($f function node_revision_delete_confirm_submit($form, &$form_state) { $node_revision = $form['#node_revision']; - db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node_revision->nid, $node_revision->vid); + db_query("DELETE FROM [{node_revisions}] WHERE [nid] = %d AND [vid] = %d", $node_revision->nid, $node_revision->vid); node_invoke_nodeapi($node_revision, 'delete revision'); watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $node_revision->type, '%title' => $node_revision->title, '%revision' => $node_revision->vid)); drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($node_revision->revision_timestamp), '@type' => node_get_types('name', $node_revision), '%title' => $node_revision->title))); $form_state['redirect'] = 'node/' . $node_revision->nid; - if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node_revision->nid)) > 1) { + if (db_result(db_query('SELECT COUNT([vid]) FROM [{node_revisions}] WHERE [nid] = %d', $node_revision->nid)) > 1) { $form_state['redirect'] .= '/revisions'; } } Index: modules/node/node.test =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.test,v retrieving revision 1.6 diff -u -p -r1.6 node.test --- modules/node/node.test 17 Sep 2008 05:26:51 -0000 1.6 +++ modules/node/node.test 22 Sep 2008 09:06:49 -0000 @@ -88,7 +88,7 @@ class NodeRevisionsTestCase extends Drup $this->assertRaw(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($nodes[1]->revision_timestamp), '@type' => 'Page', '%title' => $nodes[1]->title)), t('Revision deleted.')); - $this->assertTrue(db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d and vid = %d', $node->nid, $nodes[1]->vid)) == 0, t('Revision not found.')); + $this->assertTrue(db_result(db_query('SELECT COUNT([vid]) FROM [{node_revisions}] WHERE [nid] = %d AND [vid] = %d', $node->nid, $nodes[1]->vid)) == 0, t('Revision not found.')); } } Index: modules/path/path.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.admin.inc,v retrieving revision 1.10 diff -u -p -r1.10 path.admin.inc --- modules/path/path.admin.inc 21 Aug 2008 19:36:37 -0000 1.10 +++ modules/path/path.admin.inc 22 Sep 2008 09:06:49 -0000 @@ -15,17 +15,17 @@ function path_admin_overview($keys = NUL // Add the filter form above the overview table. $output = drupal_get_form('path_admin_filter_form', $keys); // Enable language column if locale is enabled or if we have any alias with language - $count = db_result(db_query("SELECT COUNT(*) FROM {url_alias} WHERE language != ''")); + $count = db_result(db_query("SELECT COUNT(*) FROM [{url_alias}] WHERE [language] <> %s", '')); $multilanguage = (module_exists('locale') || $count); if ($keys) { // Replace wildcards with PDO wildcards. $keys = preg_replace('!\*+!', '%', $keys); - $sql = "SELECT * FROM {url_alias} WHERE dst LIKE :keys"; - $args = array(':keys' => '%'. $keys .'%'); + $sql = "SELECT * FROM [{url_alias}] WHERE [dst] LIKE :keys"; + $args = array(':keys' => '%' . $keys . '%'); } else { - $sql = 'SELECT * FROM {url_alias}'; + $sql = 'SELECT * FROM [{url_alias}]'; $args = array(); } $header = array( @@ -137,7 +137,7 @@ function path_admin_form_validate($form, // Language is only set if locale module is enabled, otherwise save for all languages. $language = isset($form_state['values']['language']) ? $form_state['values']['language'] : ''; - if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE pid != %d AND dst = '%s' AND language = '%s'", $pid, $dst, $language))) { + if (db_result(db_query("SELECT COUNT([dst]) FROM [{url_alias}] WHERE [pid] <> %d AND [dst] = %s AND [language] = %s", $pid, $dst, $language))) { form_set_error('dst', t('The alias %alias is already in use in this language.', array('%alias' => $dst))); } $item = menu_get_item($src); Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.145 diff -u -p -r1.145 path.module --- modules/path/path.module 17 Sep 2008 20:37:32 -0000 1.145 +++ modules/path/path.module 22 Sep 2008 09:06:49 -0000 @@ -71,7 +71,7 @@ function path_menu() { * Post-confirmation; delete an URL alias. */ function path_admin_delete($pid = 0) { - db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid); + db_query('DELETE FROM [{url_alias}] WHERE [pid] = %d', $pid); drupal_set_message(t('The alias has been deleted.')); } @@ -86,11 +86,11 @@ function path_set_alias($path = NULL, $a // An existing alias. if (!$path || !$alias) { // Delete the alias based on pid. - db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid); + db_query('DELETE FROM [{url_alias}] WHERE [pid] = %d', $pid); } else { // Update the existing alias. - db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE pid = %d", $path, $alias, $language, $pid); + db_query("UPDATE [{url_alias}] SET [src] = %s, [dst] = %s, [language] = %s WHERE [pid] = %d", $path, $alias, $language, $pid); } } else if ($path && $alias) { @@ -98,20 +98,20 @@ function path_set_alias($path = NULL, $a if ($alias == drupal_get_path_alias($path, $language)) { // There is already such an alias, neutral or in this language. // Update the alias based on alias; setting the language if not yet done. - db_query("UPDATE {url_alias} SET src = '%s', dst = '%s', language = '%s' WHERE dst = '%s'", $path, $alias, $language, $alias); + db_query("UPDATE [{url_alias}] SET [src] = %s, [dst] = %s, [language] = %s WHERE [dst] = %s", $path, $alias, $language, $alias); } else { // A new alias. Add it to the database. - db_query("INSERT INTO {url_alias} (src, dst, language) VALUES ('%s', '%s', '%s')", $path, $alias, $language); + db_query("INSERT INTO [{url_alias}] ([src], [dst], [language]) VALUES (%s, %s, %s)", $path, $alias, $language); } } else { // Delete the alias. if ($alias) { - db_query("DELETE FROM {url_alias} WHERE dst = '%s'", $alias); + db_query("DELETE FROM [{url_alias}] WHERE [dst] = %s", $alias); } else { - db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path); + db_query("DELETE FROM [{url_alias}] WHERE [src] = %s", $path); } } drupal_clear_path_cache(); @@ -132,7 +132,7 @@ function path_nodeapi(&$node, $op, $arg) case 'validate': if (isset($node->path)) { $node->path = trim($node->path); - if (db_result(db_query("SELECT COUNT(dst) FROM {url_alias} WHERE dst = '%s' AND src != '%s' AND language = '%s'", $node->path, "node/$node->nid", $language))) { + if (db_result(db_query("SELECT COUNT([dst]) FROM [{url_alias}] WHERE [dst] = %s AND [src] <> %s AND [language] = %s", $node->path, "node/$node->nid", $language))) { form_set_error('path', t('The path is already in use.')); } } @@ -193,7 +193,7 @@ function path_form_alter(&$form, $form_s if ($path) { $form['path']['pid'] = array( '#type' => 'value', - '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s' AND language = '%s'", $path, $form['#node']->language)) + '#value' => db_result(db_query("SELECT [pid] FROM [{url_alias}] WHERE [dst] = %s AND [language] = %s", $path, $form['#node']->language)) ); } } @@ -213,5 +213,5 @@ function path_perm() { * Fetch a specific URL alias from the database. */ function path_load($pid) { - return db_fetch_array(db_query('SELECT * FROM {url_alias} WHERE pid = %d', $pid)); + return db_fetch_array(db_query('SELECT * FROM [{url_alias}] WHERE [pid] = %d', $pid)); } Index: modules/path/path.test =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.test,v retrieving revision 1.3 diff -u -p -r1.3 path.test --- modules/path/path.test 21 Aug 2008 19:36:37 -0000 1.3 +++ modules/path/path.test 22 Sep 2008 09:06:49 -0000 @@ -121,7 +121,7 @@ class PathTestCase extends DrupalWebTest } function getPID($dst) { - return db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $dst)); + return db_result(db_query("SELECT [pid] FROM [{url_alias}] WHERE [dst] = %s", $dst)); } function createNode() { Index: modules/search/search.module =================================================================== RCS file: /cvs/drupal/drupal/modules/search/search.module,v retrieving revision 1.266 diff -u -p -r1.266 search.module --- modules/search/search.module 17 Sep 2008 20:37:32 -0000 1.266 +++ modules/search/search.module 22 Sep 2008 09:06:49 -0000 @@ -570,8 +570,8 @@ function search_index($sid, $type, $text // Insert results into search index foreach ($results[0] as $word => $score) { - // If a word already exists in the database, its score gets increased - // appropriately. If not, we create a new record with the appropriate + // If a word already exists in the database, its score gets increased + // appropriately. If not, we create a new record with the appropriate // starting score. db_merge('search_index')->key(array( 'word' => $word, Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.45 diff -u -p -r1.45 drupal_web_test_case.php --- modules/simpletest/drupal_web_test_case.php 20 Sep 2008 20:22:24 -0000 1.45 +++ modules/simpletest/drupal_web_test_case.php 22 Sep 2008 09:06:49 -0000 @@ -398,7 +398,7 @@ class DrupalWebTestCase { node_save($node); // small hack to link revisions to our test user - db_query('UPDATE {node_revisions} SET uid = %d WHERE vid = %d', $node->uid, $node->vid); + db_query('UPDATE [{node_revisions}] SET [uid] = %d WHERE [vid] = %d', $node->uid, $node->vid); return $node; } @@ -572,15 +572,15 @@ class DrupalWebTestCase { // Create new role. $role_name = $this->randomName(); - db_query("INSERT INTO {role} (name) VALUES ('%s')", $role_name); - $role = db_fetch_object(db_query("SELECT * FROM {role} WHERE name = '%s'", $role_name)); + db_query("INSERT INTO [{role}] ([name]) VALUES (%s)", $role_name); + $role = db_fetch_object(db_query("SELECT * FROM [{role}] WHERE [name] = %s", $role_name)); $this->assertTrue($role, t('Created role of name: @role_name, id: @rid', array('@role_name' => $role_name, '@rid' => (isset($role->rid) ? $role->rid : t('-n/a-')))), t('Role')); if ($role && !empty($role->rid)) { // Assign permissions to role and mark it for clean-up. foreach ($permissions as $permission_string) { - db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", $role->rid, $permission_string); + db_query("INSERT INTO [{role_permission}] ([rid], [permission]) VALUES (%d, %s)", $role->rid, $permission_string); } - $count = db_result(db_query("SELECT COUNT(*) FROM {role_permission} WHERE rid = %d", $role->rid)); + $count = db_result(db_query("SELECT COUNT(*) FROM [{role_permission}] WHERE [rid] = %d", $role->rid)); $this->assertTrue($count == count($permissions), t('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), t('Role')); return $role->rid; } Index: modules/simpletest/simpletest.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v retrieving revision 1.15 diff -u -p -r1.15 simpletest.module --- modules/simpletest/simpletest.module 20 Sep 2008 20:22:24 -0000 1.15 +++ modules/simpletest/simpletest.module 22 Sep 2008 09:06:49 -0000 @@ -66,7 +66,7 @@ function simpletest_test_form() { $tests = simpletest_categorize_tests($uncategorized_tests); if (isset($_SESSION['test_id'])) { // Select all results using the active test ID used to group them. - $results = db_query("SELECT * FROM {simpletest} WHERE test_id = %d ORDER BY test_class, message_id", $_SESSION['test_id']); + $results = db_query("SELECT * FROM [{simpletest}] WHERE [test_id] = %d ORDER BY [test_class], [message_id]", $_SESSION['test_id']); $summary = array( '#theme' => 'simpletest_result_summary', @@ -120,8 +120,8 @@ function simpletest_test_form() { // Clear test results. if (variable_get('simpletest_clear_results', TRUE)) { - db_query('DELETE FROM {simpletest} WHERE test_id = %d', $_SESSION['test_id']); - db_query('DELETE FROM {simpletest_test_id} WHERE test_id = %d', $_SESSION['test_id']); + db_query('DELETE FROM [{simpletest}] WHERE [test_id] = %d', $_SESSION['test_id']); + db_query('DELETE FROM [{simpletest_test_id}] WHERE [test_id] = %d', $_SESSION['test_id']); } unset($_SESSION['test_id']); @@ -191,7 +191,7 @@ function simpletest_test_form() { '#value' => t('Clean environment'), '#submit' => array('simpletest_clean_environment'), ); - + return $form; } @@ -516,8 +516,8 @@ function simpletest_get_like_tables($bas global $db_prefix, $database; $connection_info = Database::getConnectionInfo(); $database_name = $connection_info['default']['database']; - $select = $count ? 'COUNT(table_name)' : 'table_name'; - $result = db_query("SELECT $select FROM information_schema.tables WHERE table_schema = :database AND table_name LIKE :table_name", array( + $select = $count ? 'COUNT([table_name])' : '[table_name]'; + $result = db_query("SELECT $select FROM [information_schema].[tables] WHERE [table_schema] = :database AND [table_name] LIKE :table_name", array( ':database' => $database_name, ':table_name' => $db_prefix . $base_table . '%', )); @@ -583,11 +583,11 @@ function simpletest_clean_temporary_dire */ function simpletest_clean_results_table() { if (variable_get('simpletest_clear_results', TRUE)) { - $count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}')); + $count = db_result(db_query('SELECT COUNT([test_id]) FROM [{simpletest_test_id}]')); // Clear test results. - db_query('DELETE FROM {simpletest}'); - db_query('DELETE FROM {simpletest_test_id}'); + db_query('DELETE FROM [{simpletest}]'); + db_query('DELETE FROM [{simpletest_test_id}]'); drupal_set_message(t('Removed @count test results.', array('@count' => $count))); } Index: modules/simpletest/tests/actions.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/actions.test,v retrieving revision 1.1 diff -u -p -r1.1 actions.test --- modules/simpletest/tests/actions.test 14 Aug 2008 09:18:28 -0000 1.1 +++ modules/simpletest/tests/actions.test 22 Sep 2008 09:06:49 -0000 @@ -60,7 +60,7 @@ class ActionsConfigurationTestCase exten $this->assertRaw(t('Action %action was deleted', array('%action' => $new_action_description)), t('Make sure that we get a delete confirmation message.')); $this->drupalGet('admin/settings/actions/manage'); $this->assertNoText($new_action_description, t("Make sure the action description does not appear on the overview page after we've deleted the action.")); - $exists = db_result(db_query("SELECT aid FROM {actions} WHERE callback = 'drupal_goto_action'")); + $exists = db_result(db_query("SELECT [aid] FROM [{actions}] WHERE [callback] = 'drupal_goto_action'")); $this->assertFalse($exists, t('Make sure the action is gone from the database after being deleted.')); } } Index: modules/simpletest/tests/database_test.install =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/database_test.install,v retrieving revision 1.2 diff -u -p -r1.2 database_test.install --- modules/simpletest/tests/database_test.install 15 Sep 2008 20:48:09 -0000 1.2 +++ modules/simpletest/tests/database_test.install 22 Sep 2008 09:06:49 -0000 @@ -14,9 +14,9 @@ function database_test_schema() { 'description' => 'Basic test table for the database unit tests.', 'fields' => array( 'id' => array( - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE, ), 'name' => array( 'description' => "A person's name", @@ -28,7 +28,7 @@ function database_test_schema() { 'age' => array( 'description' => "The person's age", 'type' => 'int', - 'unsigned' => TRUE, + 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0), 'job' => array( Index: modules/simpletest/tests/database_test.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/database_test.module,v retrieving revision 1.2 diff -u -p -r1.2 database_test.module --- modules/simpletest/tests/database_test.module 15 Sep 2008 20:48:09 -0000 1.2 +++ modules/simpletest/tests/database_test.module 22 Sep 2008 09:06:49 -0000 @@ -15,9 +15,9 @@ function database_test_query_alter(Selec } if ($query->hasTag('database_test_alter_add_join')) { - $people_alias = $query->join('test', 'people', "test_task.pid=people.id"); + $people_alias = $query->join('test', 'people', "[test_task].[pid] = [people].[id]"); $name_field = $query->addField('people', 'name', 'name'); - $query->condition($people_alias . '.id', 2); + $query->condition("[$people_alias].[id]", 2); } if ($query->hasTag('database_test_alter_change_conditional')) { @@ -32,6 +32,6 @@ function database_test_query_alter(Selec if ($query->hasTag('database_test_alter_change_expressions')) { $expressions =& $query->getExpressions(); - $expressions['double_age']['expression'] = 'age*3'; + $expressions['double_age']['expression'] = '[age]*3'; } } Index: modules/simpletest/tests/database_test.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/database_test.test,v retrieving revision 1.5 diff -u -p -r1.5 database_test.test --- modules/simpletest/tests/database_test.test 21 Sep 2008 15:27:20 -0000 1.5 +++ modules/simpletest/tests/database_test.test 22 Sep 2008 09:06:49 -0000 @@ -57,48 +57,48 @@ class DatabaseTestCase extends DrupalWeb * INSERT operations here, just populate. */ function addSampleData() { - db_query("INSERT INTO {test} (name, age, job) VALUES ('John', 25, 'Singer')"); + db_query("INSERT INTO [{test}] ([name], [age], [job]) VALUES ('John', 25, 'Singer')"); $john = db_last_insert_id('test', 'id'); - db_query("INSERT INTO {test} (name, age, job) VALUES ('George', 27, 'Singer')"); + db_query("INSERT INTO [{test}] ([name], [age], [job]) VALUES ('George', 27, 'Singer')"); $george = db_last_insert_id('test', 'id'); - db_query("INSERT INTO {test} (name, age, job) VALUES ('Ringo', 28, 'Drummer')"); + db_query("INSERT INTO [{test}] ([name], [age], [job]) VALUES ('Ringo', 28, 'Drummer')"); $ringo = db_last_insert_id('test', 'id'); - db_query("INSERT INTO {test} (name, age, job) VALUES ('Paul', 26, 'Songwriter')"); + db_query("INSERT INTO [{test}] ([name], [age], [job]) VALUES ('Paul', 26, 'Songwriter')"); $paul = db_last_insert_id('test', 'id'); - db_query("INSERT INTO {test_people} (name, age, job) VALUES ('Meredith', 30, 'Speaker')"); + db_query("INSERT INTO [{test_people}] ([name], [age], [job]) VALUES ('Meredith', 30, 'Speaker')"); - db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array( + db_query("INSERT INTO [{test_task}] ([pid], [task], [priority]) VALUES (:pid, :task, :priority)", array( ':pid' => $john, ':task' => 'eat', ':priority' => 3, )); - db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array( + db_query("INSERT INTO [{test_task}] ([pid], [task], [priority]) VALUES (:pid, :task, :priority)", array( ':pid' => $john, ':task' => 'sleep', ':priority' => 4, )); - db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array( + db_query("INSERT INTO [{test_task}] ([pid], [task], [priority]) VALUES (:pid, :task, :priority)", array( ':pid' => $john, ':task' => 'code', ':priority' => 1, )); - db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array( + db_query("INSERT INTO [{test_task}] ([pid], [task], [priority]) VALUES (:pid, :task, :priority)", array( ':pid' => $george, ':task' => 'sing', ':priority' => 2, )); - db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array( + db_query("INSERT INTO [{test_task}] ([pid], [task], [priority]) VALUES (:pid, :task, :priority)", array( ':pid' => $george, ':task' => 'sleep', ':priority' => 2, )); - db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array( + db_query("INSERT INTO [{test_task}] ([pid], [task], [priority]) VALUES (:pid, :task, :priority)", array( ':pid' => $paul, ':task' => 'found new band', ':priority' => 1, )); - db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array( + db_query("INSERT INTO [{test_task}] ([pid], [task], [priority]) VALUES (:pid, :task, :priority)", array( ':pid' => $paul, ':task' => 'perform at superbowl', ':priority' => 3, @@ -128,7 +128,7 @@ class DatabaseFetchTestCase extends Data function testQueryFetchDefault() { $records = array(); - $result = db_query("SELECT name FROM {test} WHERE age = :age", array(':age' => 25)); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] = :age", array(':age' => 25)); $this->assertTrue($result instanceof DatabaseStatement, t('Result set is a Drupal statement object.')); foreach ($result as $record) { $records[] = $record; @@ -144,7 +144,7 @@ class DatabaseFetchTestCase extends Data */ function testQueryFetchObject() { $records = array(); - $result = db_query("SELECT name FROM {test} WHERE age = :age", array(':age' => 25), array('fetch' => PDO::FETCH_OBJ)); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] = :age", array(':age' => 25), array('fetch' => PDO::FETCH_OBJ)); foreach ($result as $record) { $records[] = $record; $this->assertTrue(is_object($record), t('Record is an object.')); @@ -159,7 +159,7 @@ class DatabaseFetchTestCase extends Data */ function testQueryFetchArray() { $records = array(); - $result = db_query("SELECT name FROM {test} WHERE age = :age", array(':age' => 25), array('fetch' => PDO::FETCH_ASSOC)); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] = :age", array(':age' => 25), array('fetch' => PDO::FETCH_ASSOC)); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), t('Record is an array.'))) { @@ -177,7 +177,7 @@ class DatabaseFetchTestCase extends Data */ function testQueryFetchClass() { $records = array(); - $result = db_query("SELECT name FROM {test} WHERE age = :age", array(':age' => 25), array('fetch' => 'FakeRecord')); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] = :age", array(':age' => 25), array('fetch' => 'FakeRecord')); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue($record instanceof FakeRecord, t('Record is an object of class FakeRecord.'))) { @@ -211,7 +211,7 @@ class DatabaseFetch2TestCase extends Dat // Confirm that we can fetch a record into an indexed array explicitly. function testQueryFetchNum() { $records = array(); - $result = db_query("SELECT name FROM {test} WHERE age = :age", array(':age' => 25), array('fetch' => PDO::FETCH_NUM)); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] = :age", array(':age' => 25), array('fetch' => PDO::FETCH_NUM)); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), t('Record is an array.'))) { @@ -227,7 +227,7 @@ class DatabaseFetch2TestCase extends Dat */ function testQueryFetchBoth() { $records = array(); - $result = db_query("SELECT name FROM {test} WHERE age = :age", array(':age' => 25), array('fetch' => PDO::FETCH_BOTH)); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] = :age", array(':age' => 25), array('fetch' => PDO::FETCH_BOTH)); foreach ($result as $record) { $records[] = $record; if ($this->assertTrue(is_array($record), t('Record is an array.'))) { @@ -244,12 +244,12 @@ class DatabaseFetch2TestCase extends Dat */ function testQueryFetchCol() { $records = array(); - $result = db_query("SELECT name FROM {test} WHERE age > :age", array(':age' => 25)); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] > :age", array(':age' => 25)); $column = $result->fetchCol(); $this->assertIdentical(count($column), 3, t('fetchCol() returns the right number of records.')); - $result = db_query("SELECT name FROM {test} WHERE age > :age", array(':age' => 25)); + $result = db_query("SELECT [name] FROM [{test}] WHERE [age] > :age", array(':age' => 25)); $i = 0; foreach ($result as $record) { $this->assertIdentical($record->name, $column[$i++], t('Column matches direct accesss.')); @@ -275,7 +275,7 @@ class DatabaseInsertTestCase extends Dat */ function testSimpleInsert() { try { - $num_records_before = db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $query = db_insert('test'); $query->fields(array( @@ -284,10 +284,10 @@ class DatabaseInsertTestCase extends Dat )); $query->execute(); - $num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $this->assertIdentical($num_records_before + 1, (int)$num_records_after, t('Record inserts correctly.')); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Yoko'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Yoko'))->fetchField(); $this->assertIdentical($saved_age, '29', t('Can retrieve after inserting.')); } catch (Exception $e) { @@ -299,8 +299,8 @@ class DatabaseInsertTestCase extends Dat * Test that we can insert multiple records in one query object. */ function testMultiInsert() { - try { - $num_records_before = (int) db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + try { + $num_records_before = (int) db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $query = db_insert('test'); $query->fields(array( @@ -319,15 +319,15 @@ class DatabaseInsertTestCase extends Dat $query->values(array('Moe', '32')); $query->execute(); - $num_records_after = (int) db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $num_records_after = (int) db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $this->assertIdentical($num_records_before + 3, $num_records_after, t('Record inserts correctly.')); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Larry'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Larry'))->fetchField(); $this->assertIdentical($saved_age, '30', t('Can retrieve by name.')); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Curly'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Curly'))->fetchField(); $this->assertIdentical($saved_age, '31', t('Can retrieve by name.')); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Moe'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Moe'))->fetchField(); $this->assertIdentical($saved_age, '32', t('Can retrieve by name.')); - } + } catch (Exception $e) { $this->assertTrue(FALSE, $e->getMessage()); } @@ -338,7 +338,7 @@ class DatabaseInsertTestCase extends Dat */ function testRepeatedInsert() { try { - $num_records_before = db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $query = db_insert('test'); @@ -359,15 +359,15 @@ class DatabaseInsertTestCase extends Dat $query->values(array('Moe', '32')); $query->execute(); - $num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $this->assertIdentical((int) $num_records_before + 3, (int) $num_records_after, t('Record inserts correctly.')); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Larry'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Larry'))->fetchField(); $this->assertIdentical($saved_age, '30', t('Can retrieve by name.')); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Curly'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Curly'))->fetchField(); $this->assertIdentical($saved_age, '31', t('Can retrieve by name.')); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Moe'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Moe'))->fetchField(); $this->assertIdentical($saved_age, '32', t('Can retrieve by name.')); - } + } catch (Exception $e) { $this->assertTrue(FALSE, $e->getMessage()); } @@ -385,7 +385,7 @@ class DatabaseInsertTestCase extends Dat ->values(array('Curly', '31')) ->values(array('Moe', '32')) ->execute(); - $saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Larry'))->fetchField(); + $saved_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = :name", array(':name' => 'Larry'))->fetchField(); $this->assertIdentical($saved_age, '30', t('Can retrieve after inserting.')); } @@ -401,7 +401,7 @@ class DatabaseInsertTestCase extends Dat ->execute(); $this->assertIdentical($id, '5', t('Auto-increment ID returned successfully.')); - } + } catch (Exception $e) { $this->assertTrue(FALSE, $e->getMessage()); } @@ -428,7 +428,7 @@ class DatabaseInsertLOBTestCase extends $data = "This is\000a test."; $this->assertTrue(strlen($data) === 15, t('Test data contains a NULL.')); $id = db_insert('test_one_blob')->fields(array('blob1' => $data))->execute(); - $res = db_query('SELECT * FROM {test_one_blob} WHERE id = :id', array(':id' => $id)); + $res = db_query('SELECT * FROM [{test_one_blob}] WHERE [id] = :id', array(':id' => $id)); $r = db_fetch_array($res); $this->assertTrue($r['blob1'] === $data, t('Can insert a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r)))); } @@ -442,7 +442,7 @@ class DatabaseInsertLOBTestCase extends 'blob2' => 'a test', )) ->execute(); - $res = db_query('SELECT * FROM {test_two_blobs} WHERE id = %d', $id); + $res = db_query('SELECT * FROM [{test_two_blobs}] WHERE [id] = %d', $id); $r = db_fetch_array($res); $this->assertTrue($r['blob1'] === 'This is' && $r['blob2'] === 'a test', t('Can insert multiple blobs per row.')); } @@ -471,7 +471,7 @@ class DatabaseInsertDefaultsTestCase ext $schema = drupal_get_schema('test'); - $job = db_query("SELECT job FROM {test} WHERE id = :id", array(':id' => $id))->fetchField(); + $job = db_query("SELECT [job] FROM [{test}] WHERE [id] = :id", array(':id' => $id))->fetchField(); $this->assertEqual($job, $schema['fields']['job']['default'], t('Default field value is set.')); } catch (Exception $e) { @@ -489,7 +489,7 @@ class DatabaseInsertDefaultsTestCase ext $schema = drupal_get_schema('test'); - $job = db_query("SELECT job FROM {test} WHERE id = :id", array(':id' => $id))->fetchField(); + $job = db_query("SELECT [job] FROM [{test}] WHERE [id] = :id", array(':id' => $id))->fetchField(); $this->assertEqual($job, $schema['fields']['job']['default'], t('Default field value is set.')); } catch (Exception $e) { @@ -518,7 +518,7 @@ class DatabaseUpdateTestCase extends Dat $num_updated = db_update('test')->fields(array('name' => 'Tiffany'))->condition('id', 1)->execute(); $this->assertIdentical($num_updated, 1, t('Updated 1 record.')); - $saved_name = db_query("SELECT name FROM {test} WHERE id = :id", array(':id' => 1))->fetchField(); + $saved_name = db_query("SELECT [name] FROM [{test}] WHERE [id] = :id", array(':id' => 1))->fetchField(); $this->assertIdentical($saved_name, 'Tiffany', t('Updated name successfully.')); } @@ -529,7 +529,7 @@ class DatabaseUpdateTestCase extends Dat $num_updated = db_update('test')->fields(array('job' => 'Musician'))->condition('job', 'Singer')->execute(); $this->assertIdentical($num_updated, 2, t('Updated 2 records.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '2', t('Updated fields successfully.')); } @@ -540,7 +540,7 @@ class DatabaseUpdateTestCase extends Dat $num_updated = db_update('test')->fields(array('job' => 'Musician'))->condition('age', 26, '>')->execute(); $this->assertIdentical($num_updated, 2, t('Updated 2 records.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '2', t('Updated fields successfully.')); } @@ -551,7 +551,7 @@ class DatabaseUpdateTestCase extends Dat $num_updated = db_update('test')->fields(array('job' => 'Musician'))->where('age > :age', array(':age' => 26))->execute(); $this->assertIdentical($num_updated, 2, t('Updated 2 records.')); - $num_matches = db_query("SELECT COUNT(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '2', t('Updated fields successfully.')); } @@ -563,7 +563,7 @@ class DatabaseUpdateTestCase extends Dat $num_updated = $update->execute(); $this->assertIdentical($num_updated, 1, t('Updated 1 record.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '1', t('Updated fields successfully.')); } } @@ -594,7 +594,7 @@ class DatabaseUpdateComplexTestCase exte $num_updated = $update->execute(); $this->assertIdentical($num_updated, 2, t('Updated 2 records.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '2', t('Updated fields successfully.')); } @@ -607,7 +607,7 @@ class DatabaseUpdateComplexTestCase exte ->execute(); $this->assertIdentical($num_updated, 2, t('Updated 2 records.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '2', t('Updated fields successfully.')); } @@ -620,7 +620,7 @@ class DatabaseUpdateComplexTestCase exte ->execute(); $this->assertIdentical($num_updated, 1, t('Updated 1 record.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '1', t('Updated fields successfully.')); } @@ -634,7 +634,7 @@ class DatabaseUpdateComplexTestCase exte ->execute(); $this->assertIdentical($num_updated, 2, t('Updated 2 records.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '2', t('Updated fields successfully.')); } catch (Exception $e) { @@ -651,7 +651,7 @@ class DatabaseUpdateComplexTestCase exte ->execute(); $this->assertIdentical($num_updated, 1, t('Updated 1 record.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '1', t('Updated fields successfully.')); } @@ -660,7 +660,7 @@ class DatabaseUpdateComplexTestCase exte */ function testUpdateExpression() { try { - $before_age = db_query("SELECT age FROM {test} WHERE name = 'Ringo'")->fetchField(); + $before_age = db_query("SELECT [age] FROM [{test}] WHERE [name] = 'Ringo'")->fetchField(); $GLOBALS['larry_test'] = 1; $num_updated = db_update('test') ->condition('name', 'Ringo') @@ -669,10 +669,10 @@ class DatabaseUpdateComplexTestCase exte ->execute(); $this->assertIdentical($num_updated, 1, t('Updated 1 record.')); - $num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField(); + $num_matches = db_query("SELECT COUNT(*) FROM [{test}] WHERE [job] = :job", array(':job' => 'Musician'))->fetchField(); $this->assertIdentical($num_matches, '1', t('Updated fields successfully.')); - $person = db_query("SELECT * FROM {test} WHERE name = :name", array(':name' => 'Ringo'))->fetch(); + $person = db_query("SELECT * FROM [{test}] WHERE [name] = :name", array(':name' => 'Ringo'))->fetch(); $this->assertEqual($person->name, 'Ringo', t('Name set correctly.')); $this->assertEqual($person->age, $before_age + 4, t('Age set correctly.')); $this->assertEqual($person->job, 'Musician', t('Job set correctly.')); @@ -708,7 +708,7 @@ class DatabaseUpdateLOBTestCase extends $data .= $data; db_update('test_one_blob')->condition('id', $id)->fields(array('blob1' => $data))->execute(); - $res = db_query('SELECT * FROM {test_one_blob} WHERE id = %d', $id); + $res = db_query('SELECT * FROM [{test_one_blob}] WHERE [id] = %d', $id); $r = db_fetch_array($res); $this->assertTrue($r['blob1'] === $data, t('Can update a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r)))); } @@ -725,7 +725,7 @@ class DatabaseUpdateLOBTestCase extends db_update('test_two_blobs')->condition('id', $id)->fields(array('blob1' => 'and so', 'blob2' => 'is this'))->execute(); - $res = db_query('SELECT * FROM {test_two_blobs} WHERE id = %d', $id); + $res = db_query('SELECT * FROM [{test_two_blobs}] WHERE [id] = %d', $id); $r = db_fetch_array($res); $this->assertTrue($r['blob1'] === 'and so' && $r['blob2'] === 'is this', t('Can update multiple blobs per row.')); } @@ -753,12 +753,12 @@ class DatabaseDeleteTestCase extends Dat * Confirm that we can delete a single record successfully. */ function testSimpleDelete() { - $num_records_before = db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $num_deleted = db_delete('test')->condition('id', 1)->execute(); $this->assertIdentical($num_deleted, 1, t('Deleted 1 record.')); - $num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test}]")->fetchField(); $this->assertEqual($num_records_before, $num_records_after + $num_deleted, t('Deletion adds up.')); } } @@ -781,7 +781,7 @@ class DatabaseMergeTestCase extends Data */ function testMergeInsert() { try{ - $num_records_before = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); db_merge('test_people') ->key(array('job' => 'Presenter')) @@ -791,10 +791,10 @@ class DatabaseMergeTestCase extends Data )) ->execute(); - $num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); $this->assertEqual($num_records_before + 1, $num_records_after, t('Merge inserted properly.')); - $person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Presenter'))->fetch(); + $person = db_query("SELECT * FROM [{test_people}] WHERE [job] = :job", array(':job' => 'Presenter'))->fetch(); $this->assertEqual($person->name, 'Tiffany', t('Name set correctly.')); $this->assertEqual($person->age, 31, t('Age set correctly.')); $this->assertEqual($person->job, 'Presenter', t('Job set correctly.')); @@ -808,14 +808,14 @@ class DatabaseMergeTestCase extends Data * Confirm that we can merge-update a record successfully. */ function testMergeUpdate() { - $num_records_before = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); db_merge('test_people')->key(array('job' => 'Speaker'))->fields(array('age' => 31, 'name' => 'Tiffany'))->execute(); - $num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); $this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.')); - $person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch(); + $person = db_query("SELECT * FROM [{test_people}] WHERE [job] = :job", array(':job' => 'Speaker'))->fetch(); $this->assertEqual($person->name, 'Tiffany', t('Name set correctly.')); $this->assertEqual($person->age, 31, t('Age set correctly.')); $this->assertEqual($person->job, 'Speaker', t('Job set correctly.')); @@ -825,14 +825,14 @@ class DatabaseMergeTestCase extends Data * Confirm that we can merge-update a record successfully, with exclusion. */ function testMergeUpdateExcept() { - $num_records_before = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); db_merge('test_people')->key(array('job' => 'Speaker'))->fields(array('age' => 31, 'name' => 'Tiffany'))->updateExcept('age')->execute(); - $num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); $this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.')); - $person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch(); + $person = db_query("SELECT * FROM [{test_people}] WHERE [job] = :job", array(':job' => 'Speaker'))->fetch(); $this->assertEqual($person->name, 'Tiffany', t('Name set correctly.')); $this->assertEqual($person->age, 30, t('Age skipped correctly.')); $this->assertEqual($person->job, 'Speaker', t('Job set correctly.')); @@ -842,14 +842,14 @@ class DatabaseMergeTestCase extends Data * Confirm that we can merge-update a record successfully, with alternate replacement. */ function testMergeUpdateExplicit() { - $num_records_before = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); db_merge('test_people')->key(array('job' => 'Speaker'))->fields(array('age' => 31, 'name' => 'Tiffany'))->update(array('name' => 'Joe'))->execute(); - $num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); $this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.')); - $person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch(); + $person = db_query("SELECT * FROM [{test_people}] WHERE [job] = :job", array(':job' => 'Speaker'))->fetch(); $this->assertEqual($person->name, 'Joe', t('Name set correctly.')); $this->assertEqual($person->age, 30, t('Age skipped correctly.')); $this->assertEqual($person->job, 'Speaker', t('Job set correctly.')); @@ -859,9 +859,9 @@ class DatabaseMergeTestCase extends Data * Confirm that we can merge-update a record successfully, with expressions. */ function testMergeUpdateExpression() { - $num_records_before = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_before = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); - $age_before = db_query("SELECT age FROM {test_people} WHERE job = 'Speaker'")->fetchField(); + $age_before = db_query("SELECT [age] FROM [{test_people}] WHERE [job] = 'Speaker'")->fetchField(); // This is a very contrived example, as I have no idea why you'd want to // change age this way, but that's beside the point. @@ -874,10 +874,10 @@ class DatabaseMergeTestCase extends Data ->expression('age', 'age + :age', array(':age' => 4)) ->execute(); - $num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField(); + $num_records_after = db_query("SELECT COUNT(*) FROM [{test_people}]")->fetchField(); $this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.')); - $person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch(); + $person = db_query("SELECT * FROM [{test_people}] WHERE [job] = :job", array(':job' => 'Speaker'))->fetch(); $this->assertEqual($person->name, 'Tiffany', t('Name set correctly.')); $this->assertEqual($person->age, $age_before + 4, t('Age updated correctly.')); $this->assertEqual($person->job, 'Speaker', t('Job set correctly.')); @@ -946,7 +946,7 @@ class DatabaseSelectTestCase extends Dat function testSimpleSelectExpression() { $query = db_select('test'); $name_field = $query->addField('test', 'name'); - $age_field = $query->addExpression("age*2", 'double_age'); + $age_field = $query->addExpression("[age]*2", 'double_age'); $query->condition('age', 27); $result = $query->execute(); @@ -1083,7 +1083,7 @@ class DatabaseSelectComplexTestCase exte function testDefaultJoin() { try { $query = db_select('test_task', 't'); - $people_alias = $query->join('test', 'p', 't.pid = p.id'); + $people_alias = $query->join('test', 'p', 't.[pid] = p.[id]'); $name_field = $query->addField($people_alias, 'name', 'name'); $task_field = $query->addField('t', 'task', 'task'); $priority_field = $query->addField('t', 'priority', 'priority'); @@ -1113,7 +1113,7 @@ class DatabaseSelectComplexTestCase exte function testLeftOuterJoin() { try { $query = db_select('test', 'p'); - $people_alias = $query->leftJoin('test_task', 't', 't.pid = p.id'); + $people_alias = $query->leftJoin('test_task', 't', 't.[pid] = p.[id]'); $name_field = $query->addField('p', 'name', 'name'); $task_field = $query->addField($people_alias, 'task', 'task'); $priority_field = $query->addField($people_alias, 'priority', 'priority'); @@ -1143,7 +1143,7 @@ class DatabaseSelectComplexTestCase exte function testGroupBy() { try { $query = db_select('test_task', 't'); - $count_field = $query->addExpression('COUNT(task)', 'num'); + $count_field = $query->addExpression('COUNT([task])', 'num'); $task_field = $query->addField('t', 'task'); $query->orderBy($count_field); $query->groupBy($task_field); @@ -1184,7 +1184,7 @@ class DatabaseSelectComplexTestCase exte function testGroupByAndHaving() { try { $query = db_select('test_task', 't'); - $count_field = $query->addExpression('COUNT(task)', 'num'); + $count_field = $query->addExpression('COUNT([task])', 'num'); $task_field = $query->addField('t', 'task'); $query->orderBy($count_field); $query->groupBy($task_field); @@ -1469,7 +1469,7 @@ class DatabaseAlterTestCase extends Data $tid_field = $query->addField('test_task', 'tid'); $pid_field = $query->addField('test_task', 'pid'); $task_field = $query->addField('test_task', 'task'); - $people_alias = $query->join('test', 'people', "test_task.pid = people.id"); + $people_alias = $query->join('test', 'people', "[test_task].[pid] = [people].[id]"); $name_field = $query->addField($people_alias, 'name', 'name'); $query->condition('test_task.tid', '1'); $query->orderBy($tid_field); @@ -1533,7 +1533,7 @@ class DatabaseAlter2TestCase extends Dat try { $query = db_select('test'); $name_field = $query->addField('test', 'name'); - $age_field = $query->addExpression("age*2", 'double_age'); + $age_field = $query->addExpression("[age]*2", 'double_age'); $query->condition('age', 27); $query->addTag('database_test_alter_change_expressions'); $result = $query->execute(); @@ -1599,7 +1599,7 @@ class DatabaseRegressionTestCase extends 'job' => 'Dancer', ))->execute(); - $from_database = db_query("SELECT name FROM {test} WHERE name = :name", array(':name' => $name))->fetchField(); + $from_database = db_query("SELECT [name] FROM [{test}] WHERE [name] = :name", array(':name' => $name))->fetchField(); $this->assertIdentical($name, $from_database, t("The database handles UTF-8 characters cleanly.")); } } Index: modules/simpletest/tests/file.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/file.test,v retrieving revision 1.5 diff -u -p -r1.5 file.test --- modules/simpletest/tests/file.test 20 Sep 2008 07:35:53 -0000 1.5 +++ modules/simpletest/tests/file.test 22 Sep 2008 09:06:49 -0000 @@ -334,7 +334,7 @@ class FileSaveUploadTest extends FileTes * Test the file_save_upload() function. */ function testFileSaveUpload() { - $max_fid_before = db_result(db_query('SELECT MAX(fid) AS fid FROM {files}')); + $max_fid_before = db_result(db_query('SELECT MAX([fid]) AS [fid] FROM [{files}]')); $upload_user = $this->drupalCreateUser(array('access content')); $this->drupalLogin($upload_user); @@ -345,11 +345,11 @@ class FileSaveUploadTest extends FileTes $this->drupalPost('file-test/upload', $edit, t('Submit')); $this->assertResponse(200, t('Received a 200 response for posted test file.')); - $max_fid_after = db_result(db_query('SELECT MAX(fid) AS fid FROM {files}')); + $max_fid_after = db_result(db_query('SELECT MAX([fid]) AS [fid] FROM [{files}]')); $this->assertTrue($max_fid_after > $max_fid_before, t('A new file was created.')); // FIXME: Replace with file_load() once the hook_file patch gets committed. - $file = db_fetch_object(db_query('SELECT f.* FROM {files} f WHERE f.fid = %d', array($max_fid_after))); + $file = db_fetch_object(db_query('SELECT f.* FROM [{files}] f WHERE f.[fid] = %d', array($max_fid_after))); $this->assertTrue($file, t('Loaded the file.')); } } Index: modules/simpletest/tests/menu.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/menu.test,v retrieving revision 1.2 diff -u -p -r1.2 menu.test --- modules/simpletest/tests/menu.test 15 Sep 2008 20:48:09 -0000 1.2 +++ modules/simpletest/tests/menu.test 22 Sep 2008 09:06:49 -0000 @@ -33,14 +33,14 @@ class MenuIncTestCase extends DrupalWebT $admin_user = $this->drupalCreateUser(array('administer site configuration')); $this->drupalLogin($admin_user); - $sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'"; + $sql = "SELECT [menu_name] FROM [{menu_links}] WHERE [router_path] = 'menu_name_test'"; $name = db_result(db_query($sql)); $this->assertEqual($name, 'original', t('Menu name is "original".')); // Force a menu rebuild by going to the modules page. $this->drupalGet('admin/build/modules', array('query' => array("hook_menu_name" => 'changed'))); - $sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'"; + $sql = "SELECT [menu_name] FROM [{menu_links}] WHERE [router_path] = 'menu_name_test'"; $name = db_result(db_query($sql)); $this->assertEqual($name, 'changed', t('Menu name was successfully changed after rebuild.')); } Index: modules/simpletest/tests/registry.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/registry.test,v retrieving revision 1.2 diff -u -p -r1.2 registry.test --- modules/simpletest/tests/registry.test 20 Sep 2008 20:22:24 -0000 1.2 +++ modules/simpletest/tests/registry.test 22 Sep 2008 09:06:49 -0000 @@ -31,7 +31,7 @@ class RegistryParseFileTestCase extends function testRegistryParseFile() { _registry_parse_file($this->fileName, $this->getFileContents()); foreach (array('functionName', 'className', 'interfaceName') as $resource) { - $foundName = db_result(db_query("SELECT name FROM {registry} WHERE name = '%s'", $this->$resource)); + $foundName = db_result(db_query("SELECT [name] FROM [{registry}] WHERE [name] = %s", $this->$resource)); $this->assertTrue($this->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$resource))); } } @@ -89,11 +89,11 @@ class RegistryParseFilesTestCase extends if ($fileType == 'existing_changed') { // Insert a record with a dodgy md5. $this->$fileType->fakeMD5 = md5($this->$fileType->contents . rand()); - db_query("INSERT INTO {registry_file} (md5, filename) VALUES ('%s', '%s')", $this->$fileType->fakeMD5, $this->$fileType->fileName); + db_query("INSERT INTO [{registry_file}] ([md5], [filename]) VALUES (%s, %s)", $this->$fileType->fakeMD5, $this->$fileType->fileName); // Insert some fake resource records. foreach (array('function', 'class', 'interface') as $type) { - db_query("INSERT INTO {registry} (name, type, filename) VALUES ('%s', '%s', '%s')", $type . md5(rand()), $type, $this->$fileType->fileName); + db_query("INSERT INTO [{registry}] ([name], [type], [filename]) VALUES (%s, %s, %s)", $type . md5(rand()), $type, $this->$fileType->fileName); } } } @@ -107,11 +107,11 @@ class RegistryParseFilesTestCase extends foreach ($this->fileTypes as $fileType) { // Test that we have all the right resources. foreach (array('functionName', 'className', 'interfaceName') as $resource) { - $foundName = db_result(db_query("SELECT name FROM {registry} WHERE name = '%s'", $this->$fileType->$resource)); + $foundName = db_result(db_query("SELECT [name] FROM [{registry}] WHERE [name] = %s", $this->$fileType->$resource)); $this->assertTrue($this->$fileType->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$fileType->$resource))); } // Test that we have the right md5. - $md5 = db_result(db_query("SELECT md5 FROM {registry_file} WHERE filename = '%s'", $this->$fileType->fileName)); + $md5 = db_result(db_query("SELECT [md5] FROM [{registry_file}] WHERE [filename] = %s", $this->$fileType->fileName)); $this->assertTrue(md5($this->$fileType->contents) == $md5, t('MD5 for "@filename" matched.' . $fileType . $md5, array('@filename' => $this->$fileType->fileName))); } } Index: modules/statistics/statistics.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.admin.inc,v retrieving revision 1.11 diff -u -p -r1.11 statistics.admin.inc --- modules/statistics/statistics.admin.inc 17 Sep 2008 07:11:58 -0000 1.11 +++ modules/statistics/statistics.admin.inc 22 Sep 2008 09:06:49 -0000 @@ -11,13 +11,13 @@ */ function statistics_recent_hits() { $header = array( - array('data' => t('Timestamp'), 'field' => 'a.timestamp', 'sort' => 'desc'), - array('data' => t('Page'), 'field' => 'a.path'), - array('data' => t('User'), 'field' => 'u.name'), + array('data' => t('Timestamp'), 'field' => 'a.[timestamp]', 'sort' => 'desc'), + array('data' => t('Page'), 'field' => 'a.[path]'), + array('data' => t('User'), 'field' => 'u.[name]'), array('data' => t('Operations')) ); - $sql = 'SELECT a.aid, a.path, a.title, a.uid, u.name, a.timestamp FROM {accesslog} a LEFT JOIN {users} u ON u.uid = a.uid' . tablesort_sql($header); + $sql = 'SELECT a.[aid], a.[path], a.[title], a.[uid], u.[name], a.[timestamp] FROM [{accesslog}] a LEFT JOIN [{users}] u ON u.[uid] = a.[uid]' . tablesort_sql($header); $result = pager_query($sql, 30); $rows = array(); @@ -43,8 +43,8 @@ function statistics_recent_hits() { */ function statistics_top_pages() { // MAX(title) avoids having empty node titles which otherwise causes duplicates in the top pages list - $sql = "SELECT COUNT(path) AS hits, path, MAX(title) AS title, AVG(timer) AS average_time, SUM(timer) AS total_time FROM {accesslog} GROUP BY path"; - $sql_cnt = "SELECT COUNT(DISTINCT(path)) FROM {accesslog}"; + $sql = "SELECT COUNT([path]) AS [hits], [path], MAX([title]) AS [title], AVG([timer]) AS [average_time], SUM([timer]) AS [total_time] FROM [{accesslog}] GROUP BY [path]"; + $sql_cnt = "SELECT COUNT(DISTINCT([path])) FROM [{accesslog}]"; $header = array( array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), @@ -77,13 +77,13 @@ function statistics_top_visitors() { $header = array( array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'), - array('data' => t('Visitor'), 'field' => 'u.name'), + array('data' => t('Visitor'), 'field' => 'u.[name]'), array('data' => t('Total page generation time'), 'field' => 'total'), array('data' => user_access('block IP addresses') ? t('Operations') : '', 'colspan' => 2), ); - $sql = "SELECT COUNT(a.uid) AS hits, a.uid, u.name, a.hostname, SUM(a.timer) AS total, bl.iid FROM {accesslog} a LEFT JOIN {blocked_ips} bl ON a.hostname = bl.ip LEFT JOIN {users} u ON a.uid = u.uid GROUP BY a.hostname, a.uid, u.name, bl.iid" . tablesort_sql($header); - $sql_cnt = "SELECT COUNT(DISTINCT(CONCAT(uid, hostname))) FROM {accesslog}"; + $sql = "SELECT COUNT(a.[uid]) AS [hits], a.[uid], u.[name], a.[hostname], SUM(a.[timer]) AS [total], bl.[iid] FROM [{accesslog}] a LEFT JOIN [{blocked_ips}] bl ON a.[hostname] = bl.[ip] LEFT JOIN [{users}] u ON a.[uid] = u.[uid] GROUP BY a.[hostname], a.[uid], u.[name], bl.[iid]" . tablesort_sql($header); + $sql_cnt = "SELECT COUNT(DISTINCT(" . db_strcat('[uid]', '[hostname]') . ")) FROM [{accesslog}]"; $result = pager_query($sql, 30, 0, $sql_cnt); $rows = array(); @@ -107,8 +107,8 @@ function statistics_top_visitors() { * Menu callback; presents the "referrer" page. */ function statistics_top_referrers() { - $query = "SELECT url, COUNT(url) AS hits, MAX(timestamp) AS last FROM {accesslog} WHERE url NOT LIKE :host AND url <> '' GROUP BY url"; - $query_cnt = "SELECT COUNT(DISTINCT(url)) FROM {accesslog} WHERE url <> '' AND url NOT LIKE :host"; + $query = "SELECT [url], COUNT([url]) AS [hits], MAX([timestamp]) AS [last] FROM [{accesslog}] WHERE [url] NOT LIKE :host AND [url] <> :null GROUP BY [url]"; + $query_cnt = "SELECT COUNT(DISTINCT([url])) FROM [{accesslog}] WHERE [url] <> :null AND [url] NOT LIKE :host"; drupal_set_title(t('Top referrers in the past %interval', array('%interval' => format_interval(variable_get('statistics_flush_accesslog_timer', 259200))))); $header = array( @@ -118,7 +118,7 @@ function statistics_top_referrers() { ); $query .= tablesort_sql($header); - $result = pager_query($query, 30, 0, $query_cnt, array(':host' => '%'. $_SERVER['HTTP_HOST'] .'%')); + $result = pager_query($query, 30, 0, $query_cnt, array(':host' => '%' . $_SERVER['HTTP_HOST'] . '%', ':null' => '')); $rows = array(); while ($referrer = db_fetch_object($result)) { @@ -138,7 +138,7 @@ function statistics_top_referrers() { * Menu callback; Displays recent page accesses. */ function statistics_access_log($aid) { - $result = db_query('SELECT a.*, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE aid = %d', $aid); + $result = db_query('SELECT a.*, u.[name] FROM [{accesslog}] a LEFT JOIN [{users}] u ON a.[uid] = u.[uid] WHERE [aid] = %d', $aid); if ($access = db_fetch_object($result)) { $rows[] = array( array('data' => t('URL'), 'header' => TRUE), Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.90 diff -u -p -r1.90 system.admin.inc --- modules/system/system.admin.inc 20 Sep 2008 20:22:24 -0000 1.90 +++ modules/system/system.admin.inc 22 Sep 2008 09:06:49 -0000 @@ -22,12 +22,12 @@ function system_main_admin_page($arg = N drupal_set_message(t('One or more problems were detected with your Drupal installation. Check the status report for more information.', array('@status' => url('admin/reports/status'))), 'error'); } $blocks = array(); - if ($admin = db_fetch_array(db_query("SELECT menu_name, mlid FROM {menu_links} WHERE link_path = 'admin' AND module = 'system'"))) { + if ($admin = db_fetch_array(db_query("SELECT [menu_name], [mlid] FROM [{menu_links}] WHERE [link_path] = 'admin' AND [module] = 'system'"))) { $result = db_query(" SELECT m.*, ml.* - FROM {menu_links} ml - INNER JOIN {menu_router} m ON ml.router_path = m.path - WHERE ml.link_path != 'admin/help' AND menu_name = '%s' AND ml.plid = %d AND hidden = 0", $admin); + FROM [{menu_links}] ml + INNER JOIN [{menu_router}] m ON ml.[router_path] = m.[path] + WHERE ml.[link_path] <> 'admin/help' AND [menu_name] = %s AND ml.[plid] = %d AND [hidden] = 0", $admin); while ($item = db_fetch_array($result)) { _menu_link_translate($item); if (!$item['access']) { @@ -259,7 +259,7 @@ function system_themes_form_submit($form $old_theme_list[] = $theme->name; } } - db_query("UPDATE {system} SET status = 0 WHERE type = 'theme'"); + db_query("UPDATE [{system}] SET [status] = 0 WHERE [type] = 'theme'"); if ($form_state['values']['op'] == t('Save configuration')) { if (is_array($form_state['values']['status'])) { @@ -268,7 +268,7 @@ function system_themes_form_submit($form if ($choice || $form_state['values']['theme_default'] == $key) { system_initialize_theme_blocks($key); $new_theme_list[] = $key; - db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' and name = '%s'", $key); + db_query("UPDATE [{system}] SET [status] = 1 WHERE [type] = 'theme' and [name] = %s", $key); } } } @@ -284,7 +284,7 @@ function system_themes_form_submit($form else { // Revert to defaults: only Garland is enabled. variable_del('theme_default'); - db_query("UPDATE {system} SET status = 1 WHERE type = 'theme' AND name = 'garland'"); + db_query("UPDATE [{system}] SET [status] = 1 WHERE [type] = 'theme' AND [name] = 'garland'"); $new_theme_list = array('garland'); } @@ -996,7 +996,7 @@ function system_modules_uninstall($form_ $form = array(); // Pull all disabled modules from the system table. - $disabled_modules = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 0 AND schema_version > %d ORDER BY name", SCHEMA_UNINSTALLED); + $disabled_modules = db_query("SELECT [name], [filename], [info] FROM [{system}] WHERE [type] = 'module' AND [status] = 0 AND [schema_version] > %d ORDER BY [name]", SCHEMA_UNINSTALLED); while ($module = db_fetch_object($disabled_modules)) { // Grab the module info @@ -1111,7 +1111,7 @@ function system_ip_blocking() { $output = ''; $rows = array(); $header = array(t('IP address'), t('Operations')); - $result = db_query('SELECT * FROM {blocked_ips}'); + $result = db_query('SELECT * FROM [{blocked_ips}]'); while ($ip = db_fetch_object($result)) { $rows[] = array( $ip->ip, @@ -1153,7 +1153,7 @@ function system_ip_blocking_form($form_s function system_ip_blocking_form_validate($form, &$form_state) { $ip = trim($form_state['values']['ip']); - if (db_result(db_query("SELECT * FROM {blocked_ips} WHERE ip = '%s'", $ip))) { + if (db_result(db_query("SELECT * FROM [{blocked_ips}] WHERE [ip] = %s", $ip))) { form_set_error('ip', t('This IP address is already blocked.')); } else if ($ip == ip_address()) { @@ -1166,7 +1166,7 @@ function system_ip_blocking_form_validat function system_ip_blocking_form_submit($form, &$form_state) { $ip = trim($form_state['values']['ip']); - db_query("INSERT INTO {blocked_ips} (ip) VALUES ('%s')", $ip); + db_query("INSERT INTO [{blocked_ips}] ([ip]) VALUES (%s)", $ip); drupal_set_message(t('The IP address %ip has been blocked.', array('%ip' => $ip))); $form_state['redirect'] = 'admin/settings/ip-blocking'; return; @@ -1190,7 +1190,7 @@ function system_ip_blocking_delete(&$for */ function system_ip_blocking_delete_submit($form, &$form_state) { $blocked_ip = $form_state['values']['blocked_ip']; - db_query("DELETE FROM {blocked_ips} WHERE iid = %d", $blocked_ip['iid']); + db_query("DELETE FROM [{blocked_ips}] WHERE [iid] = %d", $blocked_ip['iid']); watchdog('user', 'Deleted %ip', array('%ip' => $blocked_ip['ip'])); drupal_set_message(t('The IP address %ip was deleted.', array('%ip' => $blocked_ip['ip']))); $form_state['redirect'] = 'admin/settings/ip-blocking'; @@ -1781,7 +1781,7 @@ function system_status($check = FALSE) { } // MySQL import might have set the uid of the anonymous user to autoincrement // value. Let's try fixing it. See http://drupal.org/node/204411 - db_query("UPDATE {users} SET uid = uid - uid WHERE name = '' AND pass = '' AND status = 0"); + db_query("UPDATE [{users}] SET [uid] = [uid] - [uid] WHERE [name] = %s AND [pass] = %s AND [status] = %d", '', '', 0); return theme('status_report', $requirements); } Index: modules/system/system.install =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.install,v retrieving revision 1.268 diff -u -p -r1.268 system.install --- modules/system/system.install 20 Sep 2008 20:22:24 -0000 1.268 +++ modules/system/system.install 22 Sep 2008 09:06:49 -0000 @@ -303,56 +303,6 @@ function system_requirements($phase) { * Implementation of hook_install(). */ function system_install() { - if (db_driver() == 'pgsql') { - // We create some custom types and functions using global names instead of - // prefixing them like we do with table names. If this function is ever - // called again (for example, by the test framework when creating prefixed - // test databases), the global names will already exist. We therefore avoid - // trying to create them again in that case. - - // Create unsigned types. - if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'int_unsigned_check'"))) { - db_query("CREATE DOMAIN int_unsigned integer CHECK (VALUE >= 0)"); - } - if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'smallint_unsigned_check'"))) { - db_query("CREATE DOMAIN smallint_unsigned smallint CHECK (VALUE >= 0)"); - } - if (!db_result(db_query("SELECT COUNT(*) FROM pg_constraint WHERE conname = 'bigint_unsigned_check'"))) { - db_query("CREATE DOMAIN bigint_unsigned bigint CHECK (VALUE >= 0)"); - } - - // Create functions. - db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric) RETURNS numeric AS - \'SELECT CASE WHEN (($1 > $2) OR ($2 IS NULL)) THEN $1 ELSE $2 END;\' - LANGUAGE \'sql\'' - ); - db_query('CREATE OR REPLACE FUNCTION "greatest"(numeric, numeric, numeric) RETURNS numeric AS - \'SELECT greatest($1, greatest($2, $3));\' - LANGUAGE \'sql\'' - ); - if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'rand'"))) { - db_query('CREATE OR REPLACE FUNCTION "rand"() RETURNS float AS - \'SELECT random();\' - LANGUAGE \'sql\'' - ); - } - - if (!db_result(db_query("SELECT COUNT(*) FROM pg_proc WHERE proname = 'concat'"))) { - db_query('CREATE OR REPLACE FUNCTION "concat"(text, text) RETURNS text AS - \'SELECT $1 || $2;\' - LANGUAGE \'sql\'' - ); - } - db_query('CREATE OR REPLACE FUNCTION "if"(boolean, text, text) RETURNS text AS - \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\' - LANGUAGE \'sql\'' - ); - db_query('CREATE OR REPLACE FUNCTION "if"(boolean, integer, integer) RETURNS integer AS - \'SELECT CASE WHEN $1 THEN $2 ELSE $3 END;\' - LANGUAGE \'sql\'' - ); - } - // Create tables. $modules = array('system', 'filter', 'block', 'user', 'node', 'comment', 'taxonomy'); foreach ($modules as $module) { @@ -366,70 +316,70 @@ function system_install() { // uid 2 which is not what we want. So we insert the first user here, the // anonymous user. uid is 1 here for now, but very soon it will be changed // to 0. - db_query("INSERT INTO {users} (name, mail) VALUES('%s', '%s')", '', ''); + db_query("INSERT INTO [{users}] ([name], [mail]) VALUES(%s, %s)", '', ''); // We need some placeholders here as name and mail are uniques and data is // presumed to be a serialized array. Install will change uid 1 immediately // anyways. So we insert the superuser here, the uid is 2 here for now, but // very soon it will be changed to 1. - db_query("INSERT INTO {users} (name, mail, created, data) VALUES('%s', '%s', %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, serialize(array())); + db_query("INSERT INTO [{users}] ([name], [mail], [created], [data]) VALUES(%s, %s, %d, %s)", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, serialize(array())); // This sets the above two users uid 0 (anonymous). We avoid an explicit 0 // otherwise MySQL might insert the next auto_increment value. - db_query("UPDATE {users} SET uid = uid - uid WHERE name = '%s'", ''); + db_query("UPDATE [{users}] SET [uid] = [uid] - [uid] WHERE [name] = %s", ''); // This sets uid 1 (superuser). We skip uid 2 but that's not a big problem. - db_query("UPDATE {users} SET uid = 1 WHERE name = '%s'", 'placeholder-for-uid-1'); + db_query("UPDATE [{users}] SET [uid] = 1 WHERE [name] = %s", 'placeholder-for-uid-1'); // Built-in roles. - db_query("INSERT INTO {role} (name) VALUES ('%s')", 'anonymous user'); - db_query("INSERT INTO {role} (name) VALUES ('%s')", 'authenticated user'); + db_query("INSERT INTO [{role}] ([name]) VALUES (%s)", 'anonymous user'); + db_query("INSERT INTO [{role}] ([name]) VALUES (%s)", 'authenticated user'); // Anonymous role permissions. - db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", 1, 'access content'); + db_query("INSERT INTO [{role_permission}] ([rid], [permission]) VALUES (%d, %s)", 1, 'access content'); // Authenticated role permissions. - db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", 2, 'access comments'); - db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", 2, 'access content'); - db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", 2, 'post comments'); - db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", 2, 'post comments without approval'); - - db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'theme_default', 's:7:"garland";'); - db_query("UPDATE {system} SET status = %d WHERE type = '%s' AND name = '%s'", 1, 'theme', 'garland'); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'user', 'navigation', 'garland', 1, 0, 'left', '', -1); - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, pages, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', '%s', %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', '', -1); + db_query("INSERT INTO [{role_permission}] ([rid], [permission]) VALUES (%d, %s)", 2, 'access comments'); + db_query("INSERT INTO [{role_permission}] ([rid], [permission]) VALUES (%d, %s)", 2, 'access content'); + db_query("INSERT INTO [{role_permission}] ([rid], [permission]) VALUES (%d, %s)", 2, 'post comments'); + db_query("INSERT INTO [{role_permission}] ([rid], [permission]) VALUES (%d, %s)", 2, 'post comments without approval'); + + db_query("INSERT INTO [{variable}] ([name], [value]) VALUES (%s, %s)", 'theme_default', 's:7:"garland";'); + db_query("UPDATE [{system}] SET [status] = %d WHERE [type] = %s AND [name] = %s", 1, 'theme', 'garland'); + db_query("INSERT INTO [{blocks}] ([module], [delta], [theme], [status], [weight], [region], [pages], [cache]) VALUES (%s, %s, %s, %d, %d, %s, %s, %d)", 'user', 'login', 'garland', 1, 0, 'left', '', -1); + db_query("INSERT INTO [{blocks}] ([module], [delta], [theme], [status], [weight], [region], [pages], [cache]) VALUES (%s, %s, %s, %d, %d, %s, %s, %d)", 'user', 'navigation', 'garland', 1, 0, 'left', '', -1); + db_query("INSERT INTO [{blocks}] ([module], [delta], [theme], [status], [weight], [region], [pages], [cache]) VALUES (%s, %s, %s, %d, %d, %s, %s, %d)", 'system', 'powered-by', 'garland', 1, 10, 'footer', '', -1); - db_query("INSERT INTO {node_access} (nid, gid, realm, grant_view, grant_update, grant_delete) VALUES (%d, %d, '%s', %d, %d, %d)", 0, 0, 'all', 1, 0, 0); + db_query("INSERT INTO [{node_access}] ([nid], [gid], [realm], [grant_view], [grant_update], [grant_delete]) VALUES (%d, %d, %s, %d, %d, %d)", 0, 0, 'all', 1, 0, 0); // Add input formats. - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Filtered HTML', ',1,2,', 1); - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('%s', '%s', %d)", 'Full HTML', '', 1); + db_query("INSERT INTO [{filter_formats}] ([name], [roles], [cache]) VALUES (%s, %s, %d)", 'Filtered HTML', ',1,2,', 1); + db_query("INSERT INTO [{filter_formats}] ([name], [roles], [cache]) VALUES (%s, %s, %d)", 'Full HTML', '', 1); // Enable filters for each input format. // Filtered HTML: // URL filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 2, 0); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", 1, 'filter', 2, 0); // HTML filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 0, 1); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", 1, 'filter', 0, 1); // Line break filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 1, 2); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", 1, 'filter', 1, 2); // HTML corrector filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 1, 'filter', 3, 10); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", 1, 'filter', 3, 10); // Full HTML: // URL filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 2, 0); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", 2, 'filter', 2, 0); // Line break filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 1, 1); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", 2, 'filter', 1, 1); // HTML corrector filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", 2, 'filter', 3, 10); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", 2, 'filter', 3, 10); - db_query("INSERT INTO {variable} (name, value) VALUES ('%s','%s')", 'filter_html_1', 'i:1;'); + db_query("INSERT INTO [{variable}] ([name], [value]) VALUES (%s, %s)", 'filter_html_1', 'i:1;'); - db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'node_options_forum', 'a:1:{i:0;s:6:"status";}'); + db_query("INSERT INTO [{variable}] ([name], [value]) VALUES (%s, %s)", 'node_options_forum', 'a:1:{i:0;s:6:"status";}'); $cron_key = serialize(md5(mt_rand())); - db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", 'cron_key', $cron_key); + db_query("INSERT INTO [{variable}] ([name], [value]) VALUES (%s, %s)", 'cron_key', $cron_key); } /** Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.623 diff -u -p -r1.623 system.module --- modules/system/system.module 20 Sep 2008 03:49:24 -0000 1.623 +++ modules/system/system.module 22 Sep 2008 09:06:49 -0000 @@ -666,7 +666,7 @@ function system_menu() { * The blocked IP address from the database as an array. */ function blocked_ip_load($iid) { - $blocked_ip = db_fetch_array(db_query("SELECT * FROM {blocked_ips} WHERE iid = %d", $iid)); + $blocked_ip = db_fetch_array(db_query("SELECT * FROM [{blocked_ips}] WHERE [iid] = %d", $iid)); return $blocked_ip; } @@ -791,13 +791,13 @@ function system_block($op = 'list', $del function system_admin_menu_block($item) { $content = array(); if (!isset($item['mlid'])) { - $item += db_fetch_array(db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = '%s' AND module = 'system'", $item['path'])); + $item += db_fetch_array(db_query("SELECT [mlid], [menu_name] FROM [{menu_links}] ml WHERE ml.[router_path] = %s AND [module] = 'system'", $item['path'])); } $result = db_query(" - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.* - FROM {menu_links} ml - LEFT JOIN {menu_router} m ON ml.router_path = m.path - WHERE ml.plid = %d AND ml.menu_name = '%s' AND hidden = 0", $item['mlid'], $item['menu_name']); + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], m.[description], ml.* + FROM [{menu_links}] ml + LEFT JOIN [{menu_router}] m ON ml.[router_path] = m.[path] + WHERE ml.[plid] = %d AND ml.[menu_name] = %s AND [hidden] = 0", $item['mlid'], $item['menu_name']); while ($item = db_fetch_array($result)) { _menu_link_translate($item); if (!$item['access']) { @@ -822,7 +822,7 @@ function system_admin_menu_block($item) function system_admin_theme_submit($form, &$form_state) { // If we're changing themes, make sure the theme has its blocks initialized. if ($form_state['values']['admin_theme'] && $form_state['values']['admin_theme'] != variable_get('admin_theme', '0')) { - $result = db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $form_state['values']['admin_theme'])); + $result = db_result(db_query("SELECT COUNT(*) FROM [{blocks}] WHERE [theme] = '%s'", $form_state['values']['admin_theme'])); if (!$result) { system_initialize_theme_blocks($form_state['values']['admin_theme']); } @@ -916,7 +916,7 @@ function system_check_directory($form_el */ function system_get_files_database(&$files, $type) { // Extract current files from database. - $result = db_query("SELECT filename, name, type, status, schema_version FROM {system} WHERE type = '%s'", $type); + $result = db_query("SELECT [filename], [name], [type], [status], [schema_version] FROM [{system}] WHERE [type] = %s", $type); while ($file = db_fetch_object($result)) { if (isset($files[$file->name]) && is_object($files[$file->name])) { $file->old_filename = $file->filename; @@ -979,14 +979,14 @@ function system_theme_data() { // Extract current files from database. system_get_files_database($themes, 'theme'); - db_query("DELETE FROM {system} WHERE type = 'theme'"); + db_query("DELETE FROM [{system}] WHERE [type] = 'theme'"); foreach ($themes as $theme) { if (!isset($theme->owner)) { $theme->owner = ''; } - db_query("INSERT INTO {system} (name, owner, info, type, filename, status, bootstrap) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0); + db_query("INSERT INTO [{system}] ([name], [owner], [info], [type], [filename], [status], [bootstrap]) VALUES (%s, %s, %s, %s, %s, %d, %d)", $theme->name, $theme->owner, serialize($theme->info), 'theme', $theme->filename, isset($theme->status) ? $theme->status : 0, 0); } return $themes; @@ -1130,7 +1130,7 @@ function system_region_list($theme_key) static $list = array(); if (!array_key_exists($theme_key, $list)) { - $info = unserialize(db_result(db_query("SELECT info FROM {system} WHERE type = :type AND name = :name", array(':type' => 'theme', ':name' => $theme_key)))); + $info = unserialize(db_result(db_query("SELECT [info] FROM [{system}] WHERE [type] = :type AND [name] = :name", array(':type' => 'theme', ':name' => $theme_key)))); $list[$theme_key] = array_map('t', $info['regions']); } @@ -1163,16 +1163,16 @@ function system_default_region($theme) { */ function system_initialize_theme_blocks($theme) { // Initialize theme's blocks if none already registered. - if (!(db_result(db_query("SELECT COUNT(*) FROM {blocks} WHERE theme = '%s'", $theme)))) { + if (!(db_result(db_query("SELECT COUNT(*) FROM [{blocks}] WHERE [theme] = %s", $theme)))) { $default_theme = variable_get('theme_default', 'garland'); $regions = system_region_list($theme); - $result = db_query("SELECT * FROM {blocks} WHERE theme = '%s'", $default_theme); + $result = db_query("SELECT * FROM [{blocks}] WHERE [theme] = %s", $default_theme); while ($block = db_fetch_array($result)) { // If the region isn't supported by the theme, assign the block to the theme's default region. if (!array_key_exists($block['region'], $regions)) { $block['region'] = system_default_region($theme); } - db_query("INSERT INTO {blocks} (module, delta, theme, status, weight, region, visibility, pages, custom, cache) VALUES ('%s', '%s', '%s', %d, %d, '%s', %d, '%s', %d, %d)", + db_query("INSERT INTO [{blocks}] ([module], [delta], [theme], [status], [weight], [region], [visibility], [pages], [custom], [cache]) VALUES (%s, %s, %s, %d, %d, %s, %d, %s, %d, %d)", $block['module'], $block['delta'], $theme, $block['status'], $block['weight'], $block['region'], $block['visibility'], $block['pages'], $block['custom'], $block['cache']); } } @@ -1359,8 +1359,8 @@ function system_get_module_admin_tasks($ if (!isset($items)) { $result = db_query(" - SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, ml.* - FROM {menu_links} ml INNER JOIN {menu_router} m ON ml.router_path = m.path WHERE ml.link_path LIKE 'admin/%' AND hidden >= 0 AND module = 'system' AND m.number_parts > 2"); + SELECT m.[load_functions], m.[to_arg_functions], m.[access_callback], m.[access_arguments], m.[page_callback], m.[page_arguments], m.[title], m.[title_callback], m.[title_arguments], m.[type], ml.* + FROM [{menu_links}] ml INNER JOIN [{menu_router}] m ON ml.[router_path] = m.[path] WHERE ml.[link_path] LIKE 'admin/%' AND [hidden] >= 0 AND [module] = 'system' AND m.[number_parts] > 2"); $items = array(); while ($item = db_fetch_array($result)) { _menu_link_translate($item); @@ -1397,12 +1397,12 @@ function system_get_module_admin_tasks($ */ function system_cron() { // Cleanup the flood. - db_query('DELETE FROM {flood} WHERE timestamp < %d', REQUEST_TIME - 3600); + db_query('DELETE FROM [{flood}] WHERE [timestamp] < %d', REQUEST_TIME - 3600); // Cleanup the batch table. - db_query('DELETE FROM {batch} WHERE timestamp < %d', REQUEST_TIME - 864000); + db_query('DELETE FROM [{batch}] WHERE [timestamp] < %d', REQUEST_TIME - 864000); // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. - $result = db_query('SELECT * FROM {files} WHERE status = %d and timestamp < %d', FILE_STATUS_TEMPORARY, REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE); + $result = db_query('SELECT * FROM [{files}] WHERE [status] = %d AND [timestamp] < %d', FILE_STATUS_TEMPORARY, REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE); while ($file = db_fetch_object($result)) { if (file_exists($file->filepath)) { // If files that exist cannot be deleted, continue so the database remains @@ -1412,7 +1412,7 @@ function system_cron() { continue; } } - db_query('DELETE FROM {files} WHERE fid = %d', $file->fid); + db_query('DELETE FROM [{files}] WHERE [fid] = %d', $file->fid); } } @@ -1498,13 +1498,13 @@ function system_actions_manage() { } $row = array(); - $instances_present = db_fetch_object(db_query("SELECT aid FROM {actions} WHERE parameters <> ''")); + $instances_present = db_fetch_object(db_query("SELECT [aid] FROM [{actions}] WHERE [parameters] <> %s", '')); $header = array( array('data' => t('Action type'), 'field' => 'type'), array('data' => t('Description'), 'field' => 'description'), array('data' => $instances_present ? t('Operations') : '', 'colspan' => '2') ); - $sql = 'SELECT * FROM {actions}'; + $sql = 'SELECT * FROM [{actions}]'; $result = pager_query($sql . tablesort_sql($header), 50); while ($action = db_fetch_object($result)) { $row[] = array( @@ -1602,7 +1602,7 @@ function system_actions_configure($form_ if (is_numeric($action)) { $aid = $action; // Load stored parameter values from database. - $data = db_fetch_object(db_query("SELECT * FROM {actions} WHERE aid = '%s'", $aid)); + $data = db_fetch_object(db_query("SELECT * FROM [{actions}] WHERE [aid] = %s", $aid)); $edit['actions_description'] = $data->description; $edit['actions_type'] = $data->type; $function = $data->callback; @@ -2025,7 +2025,7 @@ function system_goto_action($object, $co */ function system_block_ip_action() { $ip = ip_address(); - db_query("INSERT INTO {blocked_ips} (ip) VALUES ('%s')", $ip);; + db_query("INSERT INTO [{blocked_ips}] ([ip]) VALUES (%s)", $ip);; watchdog('action', 'Banned IP address %ip', array('%ip' => $ip)); } Index: modules/system/system.test =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.test,v retrieving revision 1.12 diff -u -p -r1.12 system.test --- modules/system/system.test 15 Sep 2008 20:48:09 -0000 1.12 +++ modules/system/system.test 22 Sep 2008 09:06:49 -0000 @@ -159,7 +159,7 @@ class IPAddressBlockingTestCase extends $edit = array(); $edit['ip'] = '192.168.1.1'; $this->drupalPost('admin/settings/ip-blocking', $edit, t('Save')); - $ip = db_result(db_query("SELECT iid from {blocked_ips} WHERE ip = '%s'", $edit['ip'])); + $ip = db_result(db_query("SELECT [iid] FROM [{blocked_ips}] WHERE [ip] = %s", $edit['ip'])); $this->assertNotNull($ip, t('IP address found in database')); $this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $edit['ip'])), t('IP address was blocked.')); Index: modules/taxonomy/taxonomy.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.admin.inc,v retrieving revision 1.29 diff -u -p -r1.29 taxonomy.admin.inc --- modules/taxonomy/taxonomy.admin.inc 19 Sep 2008 20:25:03 -0000 1.29 +++ modules/taxonomy/taxonomy.admin.inc 22 Sep 2008 09:06:49 -0000 @@ -270,8 +270,8 @@ function taxonomy_overview_terms(&$form_ if ($vocabulary->tags) { // We are not calling taxonomy_get_tree because that might fail with a big // number of tags in the freetagging vocabulary. - $results = pager_query(db_rewrite_sql('SELECT t.*, h.parent FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $page_increment, 0, NULL, $vocabulary->vid); - $total_entries = db_query(db_rewrite_sql('SELECT count(*) FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = :vid'), array(':vid' => $vocabulary->vid)); + $results = pager_query(db_rewrite_sql('SELECT t.*, h.[parent] FROM [{term_data}] t INNER JOIN [{term_hierarchy}] h ON t.[tid] = h.[tid] WHERE t.[vid] = %d ORDER BY [weight], [name]', 't', 'tid'), $page_increment, 0, NULL, $vocabulary->vid); + $total_entries = db_query(db_rewrite_sql('SELECT COUNT(*) FROM [{term_data}] t INNER JOIN [{term_hierarchy}] h ON t.[tid] = h.[tid] WHERE t.[vid] = :vid'), array(':vid' => $vocabulary->vid)); while ($term = db_fetch_object($results)) { $key = 'tid:' . $term->tid . ':0'; $current_page[$key] = $term; @@ -905,7 +905,7 @@ function taxonomy_vocabulary_confirm_res * @see taxonomy_vocabulary_confirm_reset_alphabetical() */ function taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_state) { - db_query('UPDATE {term_data} t SET weight = 0 WHERE vid = :vid', array(':vid' => $form_state['values']['vid'])); + db_query('UPDATE [{term_data}] t SET [weight] = 0 WHERE [vid] = :vid', array(':vid' => $form_state['values']['vid'])); drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']))); watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE); $form_state['redirect'] = 'admin/content/taxonomy/' . $form_state['values']['vid']; Index: modules/taxonomy/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v retrieving revision 1.427 diff -u -p -r1.427 taxonomy.module --- modules/taxonomy/taxonomy.module 19 Sep 2008 20:25:03 -0000 1.427 +++ modules/taxonomy/taxonomy.module 22 Sep 2008 09:06:49 -0000 @@ -217,9 +217,9 @@ function taxonomy_save_vocabulary(&$edit if (!empty($edit['vid']) && !empty($edit['name'])) { drupal_write_record('vocabulary', $edit, 'vid'); - db_query("DELETE FROM {vocabulary_node_types} WHERE vid = %d", $edit['vid']); + db_query("DELETE FROM [{vocabulary_node_types}] WHERE [vid] = %d", $edit['vid']); foreach ($edit['nodes'] as $type => $selected) { - db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type); + db_query("INSERT INTO [{vocabulary_node_types}] ([vid], [type]) VALUES (%d, %s)", $edit['vid'], $type); } module_invoke_all('taxonomy', 'update', 'vocabulary', $edit); $status = SAVED_UPDATED; @@ -230,7 +230,7 @@ function taxonomy_save_vocabulary(&$edit else { drupal_write_record('vocabulary', $edit); foreach ($edit['nodes'] as $type => $selected) { - db_query("INSERT INTO {vocabulary_node_types} (vid, type) VALUES (%d, '%s')", $edit['vid'], $type); + db_query("INSERT INTO [{vocabulary_node_types}] ([vid], [type]) VALUES (%d, %s)", $edit['vid'], $type); } module_invoke_all('taxonomy', 'insert', 'vocabulary', $edit); $status = SAVED_NEW; @@ -252,9 +252,9 @@ function taxonomy_save_vocabulary(&$edit function taxonomy_del_vocabulary($vid) { $vocabulary = (array) taxonomy_vocabulary_load($vid); - db_query('DELETE FROM {vocabulary} WHERE vid = %d', $vid); - db_query('DELETE FROM {vocabulary_node_types} WHERE vid = %d', $vid); - $result = db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid); + db_query('DELETE FROM [{vocabulary}] WHERE [vid] = %d', $vid); + db_query('DELETE FROM [{vocabulary_node_types}] WHERE [vid] = %d', $vid); + $result = db_query('SELECT [tid] FROM [{term_data}] WHERE [vid] = %d', $vid); while ($term = db_fetch_object($result)) { taxonomy_del_term($term->tid); } @@ -334,16 +334,16 @@ function taxonomy_save_term(&$form_value $status = SAVED_NEW; } - db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $form_values['tid'], $form_values['tid']); + db_query('DELETE FROM [{term_relation}] WHERE [tid1] = %d OR [tid2] = %d', $form_values['tid'], $form_values['tid']); if (!empty($form_values['relations'])) { foreach ($form_values['relations'] as $related_id) { if ($related_id != 0) { - db_query('INSERT INTO {term_relation} (tid1, tid2) VALUES (%d, %d)', $form_values['tid'], $related_id); + db_query('INSERT INTO [{term_relation}] ([tid1], [tid2]) VALUES (%d, %d)', $form_values['tid'], $related_id); } } } - db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $form_values['tid']); + db_query('DELETE FROM [{term_hierarchy}] WHERE [tid] = %d', $form_values['tid']); if (!isset($form_values['parent']) || empty($form_values['parent'])) { $form_values['parent'] = array(0); } @@ -351,23 +351,23 @@ function taxonomy_save_term(&$form_value foreach ($form_values['parent'] as $parent) { if (is_array($parent)) { foreach ($parent as $tid) { - db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $form_values['tid'], $tid); + db_query('INSERT INTO [{term_hierarchy}] ([tid], [parent]) VALUES (%d, %d)', $form_values['tid'], $tid); } } else { - db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $form_values['tid'], $parent); + db_query('INSERT INTO [{term_hierarchy}] ([tid], [parent]) VALUES (%d, %d)', $form_values['tid'], $parent); } } } else { - db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $form_values['tid'], $form_values['parent']); + db_query('INSERT INTO [{term_hierarchy}] ([tid], [parent]) VALUES (%d, %d)', $form_values['tid'], $form_values['parent']); } - db_query('DELETE FROM {term_synonym} WHERE tid = %d', $form_values['tid']); + db_query('DELETE FROM [{term_synonym}] WHERE [tid] = %d', $form_values['tid']); if (!empty($form_values['synonyms'])) { foreach (explode ("\n", str_replace("\r", '', $form_values['synonyms'])) as $synonym) { if ($synonym) { - db_query("INSERT INTO {term_synonym} (tid, name) VALUES (%d, '%s')", $form_values['tid'], chop($synonym)); + db_query("INSERT INTO [{term_synonym}] ([tid], [name]) VALUES (%d, %s)", $form_values['tid'], chop($synonym)); } } } @@ -407,11 +407,11 @@ function taxonomy_del_term($tid) { $term = (array) taxonomy_term_load($tid); - db_query('DELETE FROM {term_data} WHERE tid = %d', $tid); - db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $tid); - db_query('DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d', $tid, $tid); - db_query('DELETE FROM {term_synonym} WHERE tid = %d', $tid); - db_query('DELETE FROM {term_node} WHERE tid = %d', $tid); + db_query('DELETE FROM [{term_data}] WHERE [tid] = %d', $tid); + db_query('DELETE FROM [{term_hierarchy}] WHERE [tid] = %d', $tid); + db_query('DELETE FROM [{term_relation}] WHERE [tid1] = %d OR [tid2] = %d', $tid, $tid); + db_query('DELETE FROM [{term_synonym}] WHERE [tid] = %d', $tid); + db_query('DELETE FROM [{term_node}] WHERE [tid] = %d', $tid); module_invoke_all('taxonomy', 'delete', 'term', $term); } @@ -470,10 +470,10 @@ function taxonomy_form_all($free_tags = */ function taxonomy_get_vocabularies($type = NULL) { if ($type) { - $result = db_query(db_rewrite_sql("SELECT v.vid, v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $type); + $result = db_query(db_rewrite_sql("SELECT v.[vid], v.*, n.[type] FROM [{vocabulary}] v LEFT JOIN [{vocabulary_node_types}] n ON v.[vid] = n.[vid] WHERE n.[type] = %s ORDER BY v.[weight], v.[name]", 'v', 'vid'), $type); } else { - $result = db_query(db_rewrite_sql('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid ORDER BY v.weight, v.name', 'v', 'vid')); + $result = db_query(db_rewrite_sql('SELECT v.*, n.[type] FROM [{vocabulary}] v LEFT JOIN [{vocabulary_node_types}] n ON v.[vid] = n.[vid] ORDER BY v.[weight], v.[name]', 'v', 'vid')); } $vocabularies = array(); @@ -517,7 +517,7 @@ function taxonomy_form_alter(&$form, $fo $terms = $node->taxonomy; } - $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type); + $c = db_query(db_rewrite_sql("SELECT v.* FROM [{vocabulary}] v INNER JOIN [{vocabulary_node_types}] n ON v.[vid] = n.[vid] WHERE n.[type] = %s ORDER BY v.[weight], v.[name]", 'v', 'vid'), $node->type); while ($vocabulary = db_fetch_object($c)) { if ($vocabulary->tags) { @@ -615,7 +615,7 @@ function taxonomy_preview_terms($node) { * Find all terms associated with the given node, within one vocabulary. */ function taxonomy_node_get_terms_by_vocabulary($node, $vid, $key = 'tid') { - $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_node} r ON r.tid = t.tid WHERE t.vid = %d AND r.vid = %d ORDER BY weight', 't', 'tid'), $vid, $node->vid); + $result = db_query(db_rewrite_sql('SELECT t.[tid], t.* FROM [{term_data}] t INNER JOIN [{term_node}] r ON r.[tid] = t.[tid] WHERE t.[vid] = %d AND r.[vid] = %d ORDER BY [weight]', 't', 'tid'), $vid, $node->vid); $terms = array(); while ($term = db_fetch_object($result)) { $terms[$term->$key] = $term; @@ -630,7 +630,7 @@ function taxonomy_node_get_terms($node, static $terms; if (!isset($terms[$node->vid][$key])) { - $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_node} r INNER JOIN {term_data} t ON r.tid = t.tid INNER JOIN {vocabulary} v ON t.vid = v.vid WHERE r.vid = %d ORDER BY v.weight, t.weight, t.name', 't', 'tid'), $node->vid); + $result = db_query(db_rewrite_sql('SELECT t.* FROM [{term_node}] r INNER JOIN [{term_data}] t ON r.[tid] = t.[tid] INNER JOIN [{vocabulary}] v ON t.[vid] = v.[vid] WHERE r.[vid] = %d ORDER BY v.[weight], t.[weight], t.[name]', 't', 'tid'), $node->vid); $terms[$node->vid][$key] = array(); while ($term = db_fetch_object($result)) { $terms[$node->vid][$key][$term->$key] = $term; @@ -694,7 +694,7 @@ function taxonomy_node_save($node, $term // Defend against duplicate, differently cased tags if (!isset($inserted[$typed_term_tid])) { - db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $typed_term_tid); + db_query('INSERT INTO [{term_node}] ([nid], [vid], [tid]) VALUES (%d, %d, %d)', $node->nid, $node->vid, $typed_term_tid); $inserted[$typed_term_tid] = TRUE; } } @@ -706,15 +706,15 @@ function taxonomy_node_save($node, $term if (is_array($term)) { foreach ($term as $tid) { if ($tid) { - db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $tid); + db_query('INSERT INTO [{term_node}] ([nid], [vid], [tid]) VALUES (%d, %d, %d)', $node->nid, $node->vid, $tid); } } } else if (is_object($term)) { - db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term->tid); + db_query('INSERT INTO [{term_node}] ([nid], [vid], [tid]) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term->tid); } else if ($term) { - db_query('INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term); + db_query('INSERT INTO [{term_node}] ([nid], [vid], [tid]) VALUES (%d, %d, %d)', $node->nid, $node->vid, $term); } } } @@ -724,14 +724,14 @@ function taxonomy_node_save($node, $term * Remove associations of a node to its terms. */ function taxonomy_node_delete($node) { - db_query('DELETE FROM {term_node} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{term_node}] WHERE [nid] = %d', $node->nid); } /** * Remove associations of a node to its terms. */ function taxonomy_node_delete_revision($node) { - db_query('DELETE FROM {term_node} WHERE vid = %d', $node->vid); + db_query('DELETE FROM [{term_node}] WHERE [vid] = %d', $node->vid); } /** @@ -739,10 +739,10 @@ function taxonomy_node_delete_revision($ */ function taxonomy_node_type($op, $info) { if ($op == 'update' && !empty($info->old_type) && $info->type != $info->old_type) { - db_query("UPDATE {vocabulary_node_types} SET type = '%s' WHERE type = '%s'", $info->type, $info->old_type); + db_query("UPDATE [{vocabulary_node_types}] SET [type] = %s WHERE [type] = %s", $info->type, $info->old_type); } elseif ($op == 'delete') { - db_query("DELETE FROM {vocabulary_node_types} WHERE type = '%s'", $info->type); + db_query("DELETE FROM [{vocabulary_node_types}] WHERE [type] = %s", $info->type); } } @@ -751,7 +751,7 @@ function taxonomy_node_type($op, $info) */ function taxonomy_get_related($tid, $key = 'tid') { if ($tid) { - $result = db_query('SELECT t.*, tid1, tid2 FROM {term_relation}, {term_data} t WHERE (t.tid = tid1 OR t.tid = tid2) AND (tid1 = %d OR tid2 = %d) AND t.tid != %d ORDER BY weight, name', $tid, $tid, $tid); + $result = db_query('SELECT t.*, [tid1], [tid2] FROM [{term_relation}], [{term_data}] t WHERE (t.[tid] = [tid1] OR t.[tid] = [tid2]) AND ([tid1] = %d OR [tid2] = %d) AND t.[tid] <> %d ORDER BY [weight], [name]', $tid, $tid, $tid); $related = array(); while ($term = db_fetch_object($result)) { $related[$term->$key] = $term; @@ -768,7 +768,7 @@ function taxonomy_get_related($tid, $key */ function taxonomy_get_parents($tid, $key = 'tid') { if ($tid) { - $result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid); + $result = db_query(db_rewrite_sql('SELECT t.[tid], t.* FROM [{term_data}] t INNER JOIN [{term_hierarchy}] h ON h.[parent] = t.[tid] WHERE h.[tid] = %d ORDER BY [weight], [name]', 't', 'tid'), $tid); $parents = array(); while ($parent = db_fetch_object($result)) { $parents[$parent->$key] = $parent; @@ -801,10 +801,10 @@ function taxonomy_get_parents_all($tid) */ function taxonomy_get_children($tid, $vid = 0, $key = 'tid') { if ($vid) { - $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE t.vid = %d AND h.parent = %d ORDER BY weight, name', 't', 'tid'), $vid, $tid); + $result = db_query(db_rewrite_sql('SELECT t.* FROM [{term_data}] t INNER JOIN [{term_hierarchy}] h ON h.[tid] = t.[tid] WHERE t.[vid] = %d AND h.[parent] = %d ORDER BY [weight], [name]', 't', 'tid'), $vid, $tid); } else { - $result = db_query(db_rewrite_sql('SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.tid = t.tid WHERE parent = %d ORDER BY weight, name', 't', 'tid'), $tid); + $result = db_query(db_rewrite_sql('SELECT t.* FROM [{term_data}] t INNER JOIN [{term_hierarchy}] h ON h.[tid] = t.[tid] WHERE [parent] = %d ORDER BY [weight], [name]', 't', 'tid'), $tid); } $children = array(); while ($term = db_fetch_object($result)) { @@ -844,7 +844,7 @@ function taxonomy_get_tree($vid, $parent if (!isset($children[$vid])) { $children[$vid] = array(); - $result = db_query(db_rewrite_sql('SELECT t.tid, t.*, parent FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE t.vid = %d ORDER BY weight, name', 't', 'tid'), $vid); + $result = db_query(db_rewrite_sql('SELECT t.[tid], t.*, [parent] FROM [{term_data}] t INNER JOIN [{term_hierarchy}] h ON t.[tid] = h.[tid] WHERE t.[vid] = %d ORDER BY [weight], [name]', 't', 'tid'), $vid); while ($term = db_fetch_object($result)) { $children[$vid][$term->parent][] = $term->tid; $parents[$vid][$term->tid][] = $term->parent; @@ -880,7 +880,7 @@ function taxonomy_get_tree($vid, $parent function taxonomy_get_synonyms($tid) { if ($tid) { $synonyms = array(); - $result = db_query('SELECT name FROM {term_synonym} WHERE tid = %d', $tid); + $result = db_query('SELECT [name] FROM [{term_synonym}] WHERE [tid] = %d', $tid); while ($synonym = db_fetch_array($result)) { $synonyms[] = $synonym['name']; } @@ -895,7 +895,7 @@ function taxonomy_get_synonyms($tid) { * Return the term object that has the given string as a synonym. */ function taxonomy_get_synonym_root($synonym) { - return db_fetch_object(db_query("SELECT * FROM {term_synonym} s, {term_data} t WHERE t.tid = s.tid AND s.name = '%s'", $synonym)); + return db_fetch_object(db_query("SELECT * FROM [{term_synonym}] s, [{term_data}] t WHERE t.[tid] = s.[tid] AND s.[name] = %s", $synonym)); } /** @@ -918,10 +918,10 @@ function taxonomy_term_count_nodes($tid, if (!isset($count[$type])) { // $type == 0 always evaluates TRUE if $type is a string if (is_numeric($type)) { - $result = db_query(db_rewrite_sql('SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 GROUP BY t.tid')); + $result = db_query(db_rewrite_sql('SELECT t.[tid], COUNT(n.[nid]) AS c FROM [{term_node}] t INNER JOIN [{node}] n ON t.[vid] = n.[vid] WHERE n.[status] = 1 GROUP BY t.[tid]')); } else { - $result = db_query(db_rewrite_sql("SELECT t.tid, COUNT(n.nid) AS c FROM {term_node} t INNER JOIN {node} n ON t.vid = n.vid WHERE n.status = 1 AND n.type = '%s' GROUP BY t.tid"), $type); + $result = db_query(db_rewrite_sql("SELECT t.[tid], COUNT(n.[nid]) AS c FROM [{term_node}] t INNER JOIN [{node}] n ON t.[vid] = n.[vid] WHERE n.[status] = 1 AND n.[type] = %s GROUP BY t.[tid]"), $type); } $count[$type] = array(); while ($term = db_fetch_object($result)) { @@ -951,7 +951,7 @@ function _taxonomy_term_children($tid) { static $children; if (!isset($children)) { - $result = db_query('SELECT tid, parent FROM {term_hierarchy}'); + $result = db_query('SELECT [tid], [parent] FROM [{term_hierarchy}]'); while ($term = db_fetch_object($result)) { $children[$term->parent][] = $term->tid; } @@ -972,7 +972,7 @@ function _taxonomy_term_children($tid) { * An array of matching term objects. */ function taxonomy_get_term_by_name($name) { - $db_result = db_query(db_rewrite_sql("SELECT t.tid, t.* FROM {term_data} t WHERE LOWER(t.name) = LOWER('%s')", 't', 'tid'), trim($name)); + $db_result = db_query(db_rewrite_sql("SELECT t.[tid], t.* FROM [{term_data}] t WHERE LOWER(t.[name]) = LOWER(%s)", 't', 'tid'), trim($name)); $result = array(); while ($term = db_fetch_object($db_result)) { $result[] = $term; @@ -999,7 +999,7 @@ function taxonomy_vocabulary_load($vid) // that cached, and we will not try to load this later. $vocabularies[$vid] = FALSE; // Try to load the data and fill up the object. - $result = db_query('SELECT v.*, n.type FROM {vocabulary} v LEFT JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE v.vid = %d', $vid); + $result = db_query('SELECT v.*, n.[type] FROM [{vocabulary}] v LEFT JOIN [{vocabulary_node_types}] n ON v.[vid] = n.[vid] WHERE v.[vid] = %d', $vid); $node_types = array(); while ($voc = db_fetch_object($result)) { if (!empty($voc->type)) { @@ -1041,7 +1041,7 @@ function taxonomy_term_load($tid, $reset } static $terms = array(); if (!isset($terms[$tid]) || $reset) { - $terms[$tid] = db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid)); + $terms[$tid] = db_fetch_object(db_query('SELECT * FROM [{term_data}] WHERE [tid] = %d', $tid)); } return $terms[$tid]; } @@ -1103,7 +1103,7 @@ function theme_taxonomy_term_select($ele * @return * A resource identifier pointing to the query results. */ -function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.sticky DESC, n.created DESC') { +function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE, $order = 'n.[sticky] DESC, n.[created] DESC') { if (count($tids) > 0) { // For each term ID, generate an array of descendant term IDs to the right depth. $descendant_tids = array(); @@ -1119,20 +1119,20 @@ function taxonomy_select_nodes($tids = a if ($operator == 'or') { $args = call_user_func_array('array_merge', $descendant_tids); $placeholders = db_placeholders($args, 'int'); - $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN (' . $placeholders . ') AND n.status = 1 ORDER BY ' . $order; - $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {term_node} tn ON n.vid = tn.vid WHERE tn.tid IN (' . $placeholders . ') AND n.status = 1'; + $sql = 'SELECT DISTINCT(n.[nid]), n.[sticky], n.[title], n.[created] FROM [{node}] n INNER JOIN [{term_node}] tn ON n.[vid] = tn.[vid] WHERE tn.[tid] IN (' . $placeholders . ') AND n.[status] = 1 ORDER BY ' . $order; + $sql_count = 'SELECT COUNT(DISTINCT(n.[nid])) FROM [{node}] n INNER JOIN [{term_node}] tn ON n.[vid] = tn.[vid] WHERE tn.[tid] IN (' . $placeholders . ') AND n.[status] = 1'; } else { $joins = ''; $wheres = ''; $args = array(); foreach ($descendant_tids as $index => $tids) { - $joins .= ' INNER JOIN {term_node} tn' . $index . ' ON n.vid = tn' . $index . '.vid'; - $wheres .= ' AND tn' . $index . '.tid IN (' . db_placeholders($tids, 'int') . ')'; + $joins .= ' INNER JOIN [{term_node}] tn' . $index . ' ON n.[vid] = tn' . $index . '.[vid]'; + $wheres .= ' AND tn' . $index . '.[tid] IN (' . db_placeholders($tids, 'int') . ')'; $args = array_merge($args, $tids); } - $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n ' . $joins . ' WHERE n.status = 1 ' . $wheres . ' ORDER BY ' . $order; - $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n ' . $joins . ' WHERE n.status = 1 ' . $wheres; + $sql = 'SELECT DISTINCT(n.[nid]), n.[sticky], n.[title], n.[created] FROM [{node}] n ' . $joins . ' WHERE n.[status] = 1 ' . $wheres . ' ORDER BY ' . $order; + $sql_count = 'SELECT COUNT(DISTINCT(n.[nid])) FROM [{node}] n ' . $joins . ' WHERE n.[status] = 1 ' . $wheres; } $sql = db_rewrite_sql($sql); $sql_count = db_rewrite_sql($sql_count); Index: modules/taxonomy/taxonomy.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v retrieving revision 1.15 diff -u -p -r1.15 taxonomy.pages.inc --- modules/taxonomy/taxonomy.pages.inc 19 Sep 2008 20:25:03 -0000 1.15 +++ modules/taxonomy/taxonomy.pages.inc 22 Sep 2008 09:06:49 -0000 @@ -16,7 +16,7 @@ function taxonomy_term_page($terms, $dep $str_tids = $terms['str_tids']; if ($terms['tids']) { - $result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (' . db_placeholders($terms['tids']) . ')', 't', 'tid'), $terms['tids']); + $result = db_query(db_rewrite_sql('SELECT t.[tid], t.[name] FROM [{term_data}] t WHERE t.[tid] IN (' . db_placeholders($terms['tids']) . ')', 't', 'tid'), $terms['tids']); $tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to. $names = array(); while ($term = db_fetch_object($result)) { @@ -129,9 +129,9 @@ function taxonomy_autocomplete($vid, $st $last_string = trim(array_pop($array)); $matches = array(); if ($last_string != '') { - $result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.vid = :vid AND LOWER(t.name) LIKE LOWER(:last_string)", 't', 'tid'), array( + $result = db_query_range(db_rewrite_sql("SELECT t.[tid], t.[name] FROM [{term_data}] t WHERE t.[vid] = :vid AND LOWER(t.[name]) LIKE LOWER(:last_string)", 't', 'tid'), array( ':vid' => $vid, - ':last_string' => '%'. $last_string .'%', + ':last_string' => '%' . $last_string . '%', ), 0, 10); $prefix = count($array) ? implode(', ', $array) . ', ' : ''; Index: modules/taxonomy/taxonomy.test =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.test,v retrieving revision 1.6 diff -u -p -r1.6 taxonomy.test --- modules/taxonomy/taxonomy.test 19 Sep 2008 20:25:03 -0000 1.6 +++ modules/taxonomy/taxonomy.test 22 Sep 2008 09:06:49 -0000 @@ -398,7 +398,7 @@ class TaxonomyTestNodeApiTestCase extend } // Checking database fields. - $result = db_query('SELECT tid FROM {term_node} WHERE nid = %d', $node->nid); + $result = db_query('SELECT [tid] FROM [{term_node}] WHERE [nid] = %d', $node->nid); while ($nodeRow = db_fetch_array($result)) { $this->assertTrue(in_array($nodeRow['tid'], $parent), 'Checking database record'); } @@ -434,7 +434,7 @@ class TaxonomyTestNodeApiTestCase extend // Checking database fields. $node = node_load(array('title' => $title)); - $result = db_query('SELECT tid FROM {term_node} WHERE vid = %d', $node->vid); + $result = db_query('SELECT [tid] FROM [{term_node}] WHERE [vid] = %d', $node->vid); while ($nodeRow = db_fetch_array($result)) { $this->assertTrue(in_array($nodeRow['tid'], $parent), t('Checking database field.')); } @@ -445,7 +445,7 @@ class TaxonomyTestNodeApiTestCase extend $this->drupalGet("node/" . $node->nid); $this->assertNoText($termname, t('Checking if node exists')); // Checking database fields. - $num_rows = db_result(db_query('SELECT COUNT(*) FROM {term_node} WHERE nid = %d', $node->nid)); + $num_rows = db_result(db_query('SELECT COUNT(*) FROM [{term_node}] WHERE [nid] = %d', $node->nid)); $this->assertEqual($num_rows, 0, t('Checking database field after deletion')); // Delete vocabulary to avoid exception messages create array with empty fields. Index: modules/user/user.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.admin.inc,v retrieving revision 1.27 diff -u -p -r1.27 user.admin.inc --- modules/user/user.admin.inc 17 Sep 2008 20:37:32 -0000 1.27 +++ modules/user/user.admin.inc 22 Sep 2008 09:06:49 -0000 @@ -131,17 +131,17 @@ function user_admin_account() { $header = array( array(), - array('data' => t('Username'), 'field' => 'u.name'), - array('data' => t('Status'), 'field' => 'u.status'), + array('data' => t('Username'), 'field' => 'u.[name]'), + array('data' => t('Status'), 'field' => 'u.[status]'), t('Roles'), - array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'), - array('data' => t('Last access'), 'field' => 'u.access'), + array('data' => t('Member for'), 'field' => 'u.[created]', 'sort' => 'desc'), + array('data' => t('Last access'), 'field' => 'u.[access]'), t('Operations') ); - $sql = 'SELECT DISTINCT u.uid, u.name, u.status, u.created, u.access FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where']; + $sql = 'SELECT DISTINCT u.[uid], u.[name], u.[status], u.[created], u.[access] FROM [{users}] u LEFT JOIN [{users_roles}] ur ON u.[uid] = ur.[uid] ' . $filter['join'] . ' WHERE u.[uid] <> 0 ' . $filter['where']; $sql .= tablesort_sql($header); - $query_count = 'SELECT COUNT(DISTINCT u.uid) FROM {users} u LEFT JOIN {users_roles} ur ON u.uid = ur.uid ' . $filter['join'] . ' WHERE u.uid != 0 ' . $filter['where']; + $query_count = 'SELECT COUNT(DISTINCT u.[uid]) FROM [{users}] u LEFT JOIN [{users_roles}] ur ON u.[uid] = ur.[uid] ' . $filter['join'] . ' WHERE u.[uid] <> 0 ' . $filter['where']; $result = pager_query($sql, 50, 0, $query_count, $filter['args']); $form['options'] = array( @@ -174,7 +174,7 @@ function user_admin_account() { $form['name'][$account->uid] = array('#markup' => theme('username', $account)); $form['status'][$account->uid] = array('#markup' => $status[$account->status]); $users_roles = array(); - $roles_result = db_query('SELECT rid FROM {users_roles} WHERE uid = %d', $account->uid); + $roles_result = db_query('SELECT [rid] FROM [{users_roles}] WHERE [uid] = %d', $account->uid); while ($user_role = db_fetch_object($roles_result)) { $users_roles[] = $roles[$user_role->rid]; } @@ -556,9 +556,9 @@ function user_admin_perm_submit($form, & foreach ($form_state['values']['role_names'] as $rid => $name) { $checked = array_filter($form_state['values'][$rid]); // Delete existing permissions for the role. This handles "unchecking" checkboxes. - db_query("DELETE FROM {role_permission} WHERE rid = %d", $rid); + db_query("DELETE FROM [{role_permission}] WHERE [rid] = %d", $rid); foreach ($checked as $permission) { - db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", $rid, $permission); + db_query("INSERT INTO [{role_permission}] ([rid], [permission]) VALUES (%d, %s)", $rid, $permission); } } @@ -625,7 +625,7 @@ function user_admin_role() { drupal_goto('admin/user/roles'); } // Display the edit role form. - $role = db_fetch_object(db_query('SELECT * FROM {role} WHERE rid = %d', $rid)); + $role = db_fetch_object(db_query('SELECT * FROM [{role}] WHERE [rid] = %d', $rid)); $form['name'] = array( '#type' => 'textfield', '#title' => t('Role name'), @@ -667,12 +667,12 @@ function user_admin_role() { function user_admin_role_validate($form, &$form_state) { if ($form_state['values']['name']) { if ($form_state['values']['op'] == t('Save role')) { - if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s' AND rid != %d", $form_state['values']['name'], $form_state['values']['rid']))) { + if (db_result(db_query("SELECT COUNT(*) FROM [{role}] WHERE [name] = %s AND [rid] <> %d", $form_state['values']['name'], $form_state['values']['rid']))) { form_set_error('name', t('The role name %name already exists. Please choose another role name.', array('%name' => $form_state['values']['name']))); } } else if ($form_state['values']['op'] == t('Add role')) { - if (db_result(db_query("SELECT COUNT(*) FROM {role} WHERE name = '%s'", $form_state['values']['name']))) { + if (db_result(db_query("SELECT COUNT(*) FROM [{role}] WHERE [name] = %s", $form_state['values']['name']))) { form_set_error('name', t('The role name %name already exists. Please choose another role name.', array('%name' => $form_state['values']['name']))); } } @@ -684,19 +684,19 @@ function user_admin_role_validate($form, function user_admin_role_submit($form, &$form_state) { if ($form_state['values']['op'] == t('Save role')) { - db_query("UPDATE {role} SET name = '%s' WHERE rid = %d", $form_state['values']['name'], $form_state['values']['rid']); + db_query("UPDATE [{role}] SET [name] = %s WHERE [rid] = %d", $form_state['values']['name'], $form_state['values']['rid']); drupal_set_message(t('The role has been renamed.')); } else if ($form_state['values']['op'] == t('Delete role')) { - db_query('DELETE FROM {role} WHERE rid = %d', $form_state['values']['rid']); - db_query('DELETE FROM {role_permission} WHERE rid = %d', $form_state['values']['rid']); + db_query('DELETE FROM [{role}] WHERE [rid] = %d', $form_state['values']['rid']); + db_query('DELETE FROM [{role_permission}] WHERE [rid] = %d', $form_state['values']['rid']); // Update the users who have this role set: - db_query('DELETE FROM {users_roles} WHERE rid = %d', $form_state['values']['rid']); + db_query('DELETE FROM [{users_roles}] WHERE [rid] = %d', $form_state['values']['rid']); drupal_set_message(t('The role has been deleted.')); } else if ($form_state['values']['op'] == t('Add role')) { - db_query("INSERT INTO {role} (name) VALUES ('%s')", $form_state['values']['name']); + db_query("INSERT INTO [{role}] ([name]) VALUES (%s)", $form_state['values']['name']); drupal_set_message(t('The role has been added.')); } $form_state['redirect'] = 'admin/user/roles'; @@ -712,11 +712,11 @@ function theme_user_admin_account($form) // Overview table: $header = array( theme('table_select_header_cell'), - array('data' => t('Username'), 'field' => 'u.name'), - array('data' => t('Status'), 'field' => 'u.status'), + array('data' => t('Username'), 'field' => 'u.[name]'), + array('data' => t('Status'), 'field' => 'u.[status]'), t('Roles'), - array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'), - array('data' => t('Last access'), 'field' => 'u.access'), + array('data' => t('Member for'), 'field' => 'u.[created]', 'sort' => 'desc'), + array('data' => t('Last access'), 'field' => 'u.[access]'), t('Operations') ); Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.924 diff -u -p -r1.924 user.module --- modules/user/user.module 21 Sep 2008 15:08:39 -0000 1.924 +++ modules/user/user.module 22 Sep 2008 09:06:49 -0000 @@ -85,7 +85,7 @@ function user_theme() { } function user_external_load($authname) { - $result = db_query("SELECT uid FROM {authmap} WHERE authname = '%s'", $authname); + $result = db_query("SELECT [uid] FROM [{authmap}] WHERE [authname] = %s", $authname); if ($user = db_fetch_array($result)) { return user_load($user); @@ -159,19 +159,19 @@ function user_load($array = array()) { foreach ($array as $key => $value) { if ($key == 'uid' || $key == 'status') { - $query[] = "$key = %d"; + $query[] = "[$key] = %d"; $params[] = $value; } else if ($key == 'pass') { - $query[] = "pass = '%s'"; + $query[] = "[pass] = %s"; $params[] = $value; } else { - $query[]= "LOWER($key) = LOWER('%s')"; + $query[]= "LOWER([$key]) = LOWER(%s)"; $params[] = $value; } } - $result = db_query('SELECT * FROM {users} u WHERE ' . implode(' AND ', $query), $params); + $result = db_query('SELECT * FROM [{users}] u WHERE ' . implode(' AND ', $query), $params); if ($user = db_fetch_object($result)) { $user = drupal_unpack($user); @@ -183,7 +183,7 @@ function user_load($array = array()) { else { $user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user'; } - $result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid); + $result = db_query('SELECT r.[rid], r.[name] FROM [{role}] r INNER JOIN [{users_roles}] ur ON ur.[rid] = r.[rid] WHERE ur.[uid] = %d', $user->uid); while ($role = db_fetch_object($result)) { $user->roles[$role->rid] = $role->name; } @@ -236,7 +236,7 @@ function user_save($account, $edit = arr if (is_object($account) && $account->uid) { user_module_invoke('update', $edit, $account, $category); - $data = unserialize(db_result(db_query('SELECT data FROM {users} WHERE uid = %d', $account->uid))); + $data = unserialize(db_result(db_query('SELECT [data] FROM [{users}] WHERE [uid] = %d', $account->uid))); // Consider users edited by an administrator as logged in, if they haven't // already, so anonymous users can view the profile (if allowed). if (empty($edit['access']) && empty($account->access) && user_access('administer users')) { @@ -266,11 +266,11 @@ function user_save($account, $edit = arr // Reload user roles if provided. if (isset($edit['roles']) && is_array($edit['roles'])) { - db_query('DELETE FROM {users_roles} WHERE uid = %d', $account->uid); + db_query('DELETE FROM [{users_roles}] WHERE [uid] = %d', $account->uid); foreach (array_keys($edit['roles']) as $rid) { if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { - db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $account->uid, $rid); + db_query('INSERT INTO [{users_roles}] ([uid], [rid]) VALUES (%d, %d)', $account->uid, $rid); } } } @@ -337,10 +337,10 @@ function user_save($account, $edit = arr // Save user roles (delete just to be safe). if (isset($edit['roles']) && is_array($edit['roles'])) { - db_query('DELETE FROM {users_roles} WHERE uid = %d', $edit['uid']); + db_query('DELETE FROM [{users_roles}] WHERE [uid] = %d', $edit['uid']); foreach (array_keys($edit['roles']) as $rid) { if (!in_array($rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID))) { - db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)', $edit['uid'], $rid); + db_query('INSERT INTO [{users_roles}] ([uid], [rid]) VALUES (%d, %d)', $edit['uid'], $rid); } } } @@ -489,7 +489,7 @@ function user_role_permissions($roles = if ($fetch) { // Get from the database permissions that were not in the static variable. // Only role IDs with at least one permission assigned will return rows. - $result = db_query("SELECT r.rid, p.permission FROM {role} r INNER JOIN {role_permission} p ON p.rid = r.rid WHERE r.rid IN (" . db_placeholders($fetch) . ")", $fetch); + $result = db_query("SELECT r.[rid], p.[permission] FROM [{role}] r INNER JOIN [{role_permission}] p ON p.[rid] = r.[rid] WHERE r.[rid] IN (" . db_placeholders($fetch) . ")", $fetch); while ($row = db_fetch_array($result)) { $stored_permissions[$row['rid']][$row['permission']] = TRUE; @@ -561,7 +561,7 @@ function user_access($string, $account = * @return boolean TRUE for blocked users, FALSE for active. */ function user_is_blocked($name) { - $deny = db_fetch_object(db_query("SELECT name FROM {users} WHERE status = 0 AND name = LOWER('%s')", $name)); + $deny = db_fetch_object(db_query("SELECT [name] FROM [{users}] WHERE [status] = 0 AND [name] = LOWER(%s)", $name)); return $deny; } @@ -606,13 +606,13 @@ function user_search($op = 'search', $ke $keys = preg_replace('!\*+!', '%', $keys); if (user_access('administer users')) { // Administrators can also search in the otherwise private email field. - $result = pager_query("SELECT name, uid, mail FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%') OR LOWER(mail) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys, $keys); + $result = pager_query("SELECT [name], [uid], [mail] FROM [{users}] WHERE LOWER([name]) LIKE LOWER(?) OR LOWER(mail) LIKE LOWER(?)", 15, 0, NULL, '%' . $keys . '%', '%' . $keys . '%'); while ($account = db_fetch_object($result)) { $find[] = array('title' => $account->name . ' (' . $account->mail . ')', 'link' => url('user/' . $account->uid, array('absolute' => TRUE))); } } else { - $result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys); + $result = pager_query("SELECT [name], [uid] FROM [{users}] WHERE LOWER([name]) LIKE LOWER(?)", 15, 0, NULL, '%' . $keys . '%'); while ($account = db_fetch_object($result)) { $find[] = array('title' => $account->name, 'link' => url('user/' . $account->uid, array('absolute' => TRUE))); } @@ -774,7 +774,7 @@ function user_block($op = 'list', $delta case 'new': if (user_access('access content')) { // Retrieve a list of new users who have subsequently accessed the site successfully. - $result = db_query_range('SELECT uid, name FROM {users} WHERE status != 0 AND access != 0 ORDER BY created DESC', 0, variable_get('user_block_whois_new_count', 5)); + $result = db_query_range('SELECT [uid], [name] FROM [{users}] WHERE [status] <> 0 AND [access] <> 0 ORDER BY [created] DESC', 0, variable_get('user_block_whois_new_count', 5)); while ($account = db_fetch_object($result)) { $items[] = $account; } @@ -793,7 +793,7 @@ function user_block($op = 'list', $delta // Perform database queries to gather online user lists. We use s.timestamp // rather than u.access because it is much faster. $anonymous_count = drupal_session_count($interval); - $authenticated_users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval); + $authenticated_users = db_query('SELECT DISTINCT u.[uid], u.[name], s.[timestamp] FROM [{users}] u INNER JOIN [{sessions}] s ON u.[uid] = s.[uid] WHERE s.[timestamp] >= %d AND s.[uid] > 0 ORDER BY s.[timestamp] DESC', $interval); $authenticated_count = 0; $max_users = variable_get('user_block_max_list_count', 10); $items = array(); @@ -1166,7 +1166,7 @@ function user_page_title($account) { * An associative array with module as key and username as value. */ function user_get_authmaps($authname = NULL) { - $result = db_query("SELECT authname, module FROM {authmap} WHERE authname = '%s'", $authname); + $result = db_query("SELECT [authname], [module] FROM [{authmap}] WHERE [authname] = %s", $authname); $authmaps = array(); $has_rows = FALSE; while ($authmap = db_fetch_object($result)) { @@ -1310,7 +1310,7 @@ function user_authenticate($form_values $password = trim($form_values['pass']); // Name and pass keys are required. if (!empty($form_values['name']) && !empty($password)) { - $account = db_fetch_object(db_query("SELECT * FROM {users} WHERE name = '%s' AND status = 1", $form_values['name'])); + $account = db_fetch_object(db_query("SELECT * FROM [{users}] WHERE [name] = %s AND [status] = 1", $form_values['name'])); if ($account) { // Allow alternate password hashing schemes. require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc'); @@ -1318,7 +1318,7 @@ function user_authenticate($form_values if (user_needs_new_hash($account)) { $new_hash = user_hash_password($password); if ($new_hash) { - db_query("UPDATE {users} SET pass = '%s' WHERE uid = %d", $new_hash, $account->uid); + db_query("UPDATE [{users}] SET [pass] = %s WHERE [uid] = %d", $new_hash, $account->uid); } } $account = user_load(array('uid' => $account->uid, 'status' => 1)); @@ -1345,7 +1345,7 @@ function user_authenticate_finalize(&$ed // Update the user table timestamp noting user has logged in. // This is also used to invalidate one-time login links. $user->login = REQUEST_TIME; - db_query("UPDATE {users} SET login = %d WHERE uid = %d", $user->login, $user->uid); + db_query("UPDATE [{users}] SET [login] = %d WHERE [uid] = %d", $user->login, $user->uid); user_module_invoke('login', $edit, $user); drupal_session_regenerate(); } @@ -1522,7 +1522,7 @@ function _user_edit_validate($uid, &$edi if ($error = user_validate_name($edit['name'])) { form_set_error('name', $error); } - else if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE uid != %d AND LOWER(name) = LOWER('%s')", $uid, $edit['name'])) > 0) { + else if (db_result(db_query("SELECT COUNT(*) FROM [{users}] WHERE [uid] <> %d AND LOWER([name]) = LOWER(%s)", $uid, $edit['name'])) > 0) { form_set_error('name', t('The name %name is already taken.', array('%name' => $edit['name']))); } } @@ -1531,7 +1531,7 @@ function _user_edit_validate($uid, &$edi if ($error = user_validate_mail($edit['mail'])) { form_set_error('mail', $error); } - else if (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE uid != %d AND LOWER(mail) = LOWER('%s')", $uid, $edit['mail'])) > 0) { + else if (db_result(db_query("SELECT COUNT(*) FROM [{users}] WHERE [uid] <> %d AND LOWER([mail]) = LOWER(%s)", $uid, $edit['mail'])) > 0) { form_set_error('mail', t('The e-mail address %email is already registered. Have you forgotten your password?', array('%email' => $edit['mail'], '@password' => url('user/password')))); } } @@ -1561,9 +1561,9 @@ function user_delete($edit, $uid) { drupal_session_destroy_uid($uid); _user_mail_notify('status_deleted', $account); module_invoke_all('user', 'delete', $edit, $account); - db_query('DELETE FROM {users} WHERE uid = %d', $uid); - db_query('DELETE FROM {users_roles} WHERE uid = %d', $uid); - db_query('DELETE FROM {authmap} WHERE uid = %d', $uid); + db_query('DELETE FROM [{users}] WHERE [uid] = %d', $uid); + db_query('DELETE FROM [{users_roles}] WHERE [uid] = %d', $uid); + db_query('DELETE FROM [{authmap}] WHERE [uid] = %d', $uid); $variables = array('%name' => $account->name, '%email' => '<' . $account->mail . '>'); watchdog('user', 'Deleted user: %name %email.', $variables, WATCHDOG_NOTICE); } @@ -1669,10 +1669,10 @@ function user_roles($membersonly = FALSE ); if (!empty($permission)) { - $result = db_query("SELECT r.* FROM {role} r INNER JOIN {role_permission} p ON r.rid = p.rid WHERE p.permission = '%s' ORDER BY r.name", $permission); + $result = db_query("SELECT r.* FROM [{role}] r INNER JOIN [{role_permission}] p ON r.[rid] = p.[rid] WHERE p.[permission] = %s ORDER BY r.[name]", $permission); } else { - $result = db_query('SELECT * FROM {role} ORDER BY name'); + $result = db_query('SELECT * FROM [{role}] ORDER BY [name]'); } while ($role = db_fetch_object($result)) { @@ -1796,7 +1796,7 @@ function user_user_operations_block($acc function user_multiple_role_edit($accounts, $operation, $rid) { // The role name is not necessary as user_save() will reload the user // object, but some modules' hook_user() may look at this first. - $role_name = db_result(db_query('SELECT name FROM {role} WHERE rid = %d', $rid)); + $role_name = db_result(db_query('SELECT [name] FROM [{role}] WHERE [rid] = %d', $rid)); switch ($operation) { case 'add_role': @@ -1828,7 +1828,7 @@ function user_multiple_delete_confirm(&$ $form['accounts'] = array('#prefix' => '', '#tree' => TRUE); // array_filter() returns only elements with TRUE values. foreach (array_filter($edit['accounts']) as $uid => $value) { - $user = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid)); + $user = db_result(db_query('SELECT [name] FROM [{users}] WHERE [uid] = %d', $uid)); $form['accounts'][$uid] = array('#type' => 'hidden', '#value' => $uid, '#prefix' => '
  • ', '#suffix' => check_plain($user) . "
  • \n"); } $form['operation'] = array('#type' => 'hidden', '#value' => 'delete'); @@ -1915,7 +1915,7 @@ function user_filters() { if (count($roles)) { $filters['role'] = array( 'title' => t('role'), - 'where' => "ur.rid = %d", + 'where' => "ur.[rid] = %d", 'options' => $roles, 'join' => '', ); @@ -1933,14 +1933,14 @@ function user_filters() { ksort($options); $filters['permission'] = array( 'title' => t('permission'), - 'join' => 'LEFT JOIN {role_permission} p ON ur.rid = p.rid', - 'where' => " (p.permission = '%s' OR u.uid = 1) ", + 'join' => 'LEFT JOIN [{role_permission}] p ON ur.[rid] = p.[rid]', + 'where' => " (p.[permission] = %s OR u.[uid] = 1) ", 'options' => $options, ); $filters['status'] = array( 'title' => t('status'), - 'where' => 'u.status = %d', + 'where' => 'u.[status] = %d', 'join' => '', 'options' => array(1 => t('active'), 0 => t('blocked')), ); @@ -2212,7 +2212,7 @@ function user_block_user_action(&$object global $user; $uid = $user->uid; } - db_query("UPDATE {users} SET status = 0 WHERE uid = %d", $uid); + db_query("UPDATE [{users}] SET [status] = 0 WHERE [uid] = %d", $uid); drupal_session_destroy_uid($uid); watchdog('action', 'Blocked user %name.', array('%name' => check_plain($user->name))); } Index: modules/user/user.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.pages.inc,v retrieving revision 1.17 diff -u -p -r1.17 user.pages.inc --- modules/user/user.pages.inc 17 Sep 2008 07:11:59 -0000 1.17 +++ modules/user/user.pages.inc 22 Sep 2008 09:06:49 -0000 @@ -12,7 +12,7 @@ function user_autocomplete($string = '') { $matches = array(); if ($string) { - $result = db_query_range("SELECT name FROM {users} WHERE LOWER(name) LIKE LOWER(:name)", array(':name' => $string .'%'), 0, 10); + $result = db_query_range("SELECT [name] FROM [{users}] WHERE LOWER([name]) LIKE LOWER(:name)", array(':name' => $string . '%'), 0, 10); while ($user = db_fetch_object($result)) { $matches[$user->name] = check_plain($user->name); } Index: scripts/run-tests.sh =================================================================== RCS file: /cvs/drupal/drupal/scripts/run-tests.sh,v retrieving revision 1.9 diff -u -p -r1.9 run-tests.sh --- scripts/run-tests.sh 20 Sep 2008 20:22:25 -0000 1.9 +++ scripts/run-tests.sh 22 Sep 2008 09:06:49 -0000 @@ -115,13 +115,13 @@ All arguments are long options. --concurrency [num] Run tests in parallel, up to [num] tests at a time. This requires - the Process Control Extension (PCNTL) to be compiled in PHP, not + the Process Control Extension (PCNTL) to be compiled in PHP, not supported under Windows. --all Run all available tests. --class Run tests identified by specific class names, instead of group names. - + --file Run tests identifiled by specific file names, instead of group names. Specify the path and the extension (i.e. 'modules/user/user.test'). @@ -371,7 +371,7 @@ function simpletest_script_get_test_list foreach ($args['test_names'] as $file) { $files[realpath($file)] = 1; } - + // Check for valid class names. foreach ($all_tests as $class_name => $instance) { $refclass = new ReflectionClass($class_name); Index: sites/default/default.settings.php =================================================================== RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v retrieving revision 1.14 diff -u -p -r1.14 default.settings.php --- sites/default/default.settings.php 21 Aug 2008 19:36:39 -0000 1.14 +++ sites/default/default.settings.php 22 Sep 2008 09:06:49 -0000 @@ -46,7 +46,7 @@ /** * Database settings: * - * The $databases array specifies the database connection or + * The $databases array specifies the database connection or * connections that Drupal may use. Drupal is able to connect * to multiple databases, including multiple types of databases, * during the same request. @@ -62,7 +62,7 @@ * 'host' => 'localhost', * ); * - * The "driver" property indicates what Drupal database driver the + * The "driver" property indicates what Drupal database driver the * connection should use. This is usually the same as the name of the * database type, such as mysql or sqlite, but not always. The other * properties will vary depending on the driver. For SQLite, you must @@ -79,7 +79,7 @@ * A target database allows Drupal to try to send certain queries to a * different database if it can but fall back to the default connection if not. * That is useful for master/slave replication, as Drupal may try to connect - * to a slave server when appropriate and if one is not available will simply + * to a slave server when appropriate and if one is not available will simply * fall back to the single master server. * * The general format for the $databases array is as follows: