? sites/default/files
? sites/default/modules
? sites/default/settings.php
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 28 Sep 2008 16:44:05 -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: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.260
diff -u -p -r1.260 update.php
--- update.php 20 Sep 2008 20:22:23 -0000 1.260
+++ update.php 28 Sep 2008 16:44:05 -0000
@@ -60,26 +60,26 @@ function db_add_column(&$ret, $table, $c
if (array_key_exists('default', $attributes)) {
if (is_null($attributes['default'])) {
$default_val = 'NULL';
- $default = 'default NULL';
+ $default = 'DEFAULT NULL';
}
elseif ($attributes['default'] === FALSE) {
$default = '';
}
else {
$default_val = "$attributes[default]";
- $default = "default $attributes[default]";
+ $default = "DEFAULT $attributes[default]";
}
}
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column $type");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ADD [$column] $type");
if (!empty($default)) {
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET $default");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column] SET $default");
}
if (!empty($not_null)) {
if (!empty($default)) {
- $ret[] = update_sql("UPDATE {" . $table . "} SET $column = $default_val");
+ $ret[] = update_sql("UPDATE [{" . $table . "}] SET [$column] = $default_val");
}
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column SET NOT NULL");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column] SET NOT NULL");
}
}
@@ -116,27 +116,27 @@ function db_change_column(&$ret, $table,
if (array_key_exists('default', $attributes)) {
if (is_null($attributes['default'])) {
$default_val = 'NULL';
- $default = 'default NULL';
+ $default = 'DEFAULT NULL';
}
elseif ($attributes['default'] === FALSE) {
$default = '';
}
else {
$default_val = "$attributes[default]";
- $default = "default $attributes[default]";
+ $default = "DEFAULT $attributes[default]";
}
}
- $ret[] = update_sql("ALTER TABLE {" . $table . "} RENAME $column TO " . $column . "_old");
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ADD $column_new $type");
- $ret[] = update_sql("UPDATE {" . $table . "} SET $column_new = " . $column . "_old");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] RENAME [$column] TO [" . $column . "_old]");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ADD [$column_new] $type");
+ $ret[] = update_sql("UPDATE [{" . $table . "}] SET [$column_new] = [" . $column . "_old]");
if ($default) {
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET $default");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column_new] SET $default");
}
if ($not_null) {
- $ret[] = update_sql("ALTER TABLE {" . $table . "} ALTER $column_new SET NOT NULL");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] ALTER [$column_new] SET NOT NULL");
}
- $ret[] = update_sql("ALTER TABLE {" . $table . "} DROP " . $column . "_old");
+ $ret[] = update_sql("ALTER TABLE [{" . $table . "}] DROP [" . $column . "_old]");
}
/**
@@ -477,14 +477,14 @@ function update_create_batch_table() {
function update_fix_compatibility() {
$ret = array();
$incompatible = array();
- $query = db_query("SELECT name, type, status FROM {system} WHERE status = 1 AND type IN ('module','theme')");
+ $query = db_query("SELECT [name], [type], [status] FROM [{system}] WHERE [status] = 1 AND [type] IN ('module', 'theme')");
while ($result = db_fetch_object($query)) {
if (update_check_incompatibility($result->name, $result->type)) {
$incompatible[] = $result->name;
}
}
if (!empty($incompatible)) {
- $ret[] = update_sql("UPDATE {system} SET status = 0 WHERE name IN ('" . implode("','", $incompatible) . "')");
+ $ret[] = update_sql("UPDATE [{system}] SET [status] = 0 WHERE [name] IN ('" . implode("', '", $incompatible) . "')");
}
return $ret;
}
Index: includes/actions.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/actions.inc,v
retrieving revision 1.18
diff -u -p -r1.18 actions.inc
--- includes/actions.inc 26 Sep 2008 16:13:37 -0000 1.18
+++ includes/actions.inc 28 Sep 2008 16:44:05 -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'])));
}
}
@@ -280,7 +280,7 @@ function actions_synchronize($actions_in
$orphaned = array_keys($actions_in_db);
if ($delete_orphans) {
- $results = db_query("SELECT a.aid, a.description FROM {actions} a WHERE callback IN (" . db_placeholders($orphaned, 'varchar') . ")", $orphaned);
+ $results = db_query("SELECT a.[aid], a.[description] FROM [{actions}] a WHERE [callback] IN (" . db_placeholders($orphaned, 'varchar') . ")", $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)));
@@ -315,15 +315,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));
}
@@ -340,7 +340,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));
}
/**
@@ -350,6 +350,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.22
diff -u -p -r1.22 batch.inc
--- includes/batch.inc 26 Sep 2008 23:30:20 -0000 1.22
+++ includes/batch.inc 28 Sep 2008 16:44:05 -0000
@@ -16,7 +16,7 @@ function _batch_page() {
}
// Retrieve the current state of batch from db.
- $batch = db_query("SELECT batch FROM {batch} WHERE bid = :bid AND token = :token", array(
+ $batch = db_query("SELECT [batch] FROM [{batch}] WHERE [bid] = :bid AND [token] = :token", array(
':bid' => $_REQUEST['id'],
':token' => drupal_get_token($_REQUEST['id']))
)->fetchField();
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 28 Sep 2008 16:44:05 -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 28 Sep 2008 16:44:05 -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 28 Sep 2008 16:44:06 -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 28 Sep 2008 16:44:06 -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.289
diff -u -p -r1.289 form.inc
--- includes/form.inc 27 Sep 2008 19:47:42 -0000 1.289
+++ includes/form.inc 28 Sep 2008 16:44:06 -0000
@@ -2568,7 +2568,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
@@ -2577,7 +2577,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.71
diff -u -p -r1.71 install.inc
--- includes/install.inc 27 Sep 2008 20:03:35 -0000 1.71
+++ includes/install.inc 28 Sep 2008 16:44:06 -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.
- Are you sure the configured username has the necessary %name permissions to create tables in the database?
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)) {
@@ -795,7 +795,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.
*
@@ -894,7 +894,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.187
diff -u -p -r1.187 locale.inc
--- includes/locale.inc 27 Sep 2008 20:23:30 -0000 1.187
+++ includes/locale.inc 28 Sep 2008 16:44:06 -0000
@@ -125,7 +125,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.'));
@@ -204,7 +204,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(
@@ -296,7 +296,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)));
}
@@ -347,13 +347,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)));
}
}
@@ -362,7 +362,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');
@@ -420,13 +420,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);
@@ -498,7 +498,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;
@@ -514,7 +514,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%)";
@@ -777,7 +777,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');
@@ -824,7 +824,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;
}
@@ -840,19 +840,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.
@@ -881,7 +881,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 {
@@ -901,8 +901,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);
@@ -954,7 +954,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) {
@@ -999,7 +999,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;
}
@@ -1243,10 +1243,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;
}
@@ -1308,35 +1308,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]++;
}
@@ -1672,7 +1672,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);
}
}
}
@@ -1712,10 +1712,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)) {
@@ -1943,40 +1943,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'];
@@ -1988,7 +1988,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'];
@@ -2098,12 +2098,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)) {
@@ -2178,14 +2178,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);
}
}
@@ -2475,9 +2475,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)) {
@@ -2510,7 +2510,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.292
diff -u -p -r1.292 menu.inc
--- includes/menu.inc 22 Sep 2008 03:19:43 -0000 1.292
+++ includes/menu.inc 28 Sep 2008 16:44:06 -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']);
}
}
@@ -2344,7 +2344,7 @@ function _menu_router_build($callbacks)
return array();
}
// 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) {
$item = &$menu[$path];
@@ -2411,17 +2411,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'],
@@ -2498,7 +2498,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.127
diff -u -p -r1.127 module.inc
--- includes/module.inc 27 Sep 2008 19:03:30 -0000 1.127
+++ includes/module.inc 28 Sep 2008 16:44:06 -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)) {
@@ -124,12 +124,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);
@@ -271,10 +271,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;
}
@@ -316,7 +316,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 28 Sep 2008 16:44:06 -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 28 Sep 2008 16:44:06 -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.60
diff -u -p -r1.60 session.inc
--- includes/session.inc 27 Sep 2008 20:37:00 -0000 1.60
+++ includes/session.inc 28 Sep 2008 16:44:06 -0000
@@ -83,7 +83,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) {
@@ -93,7 +93,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;
}
@@ -136,7 +136,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
@@ -144,18 +144,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);
}
}
}
@@ -169,7 +169,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);
}
/**
@@ -189,8 +189,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));
}
/**
@@ -202,7 +202,7 @@ function drupal_session_count($timestamp
* 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);
}
/**
@@ -212,7 +212,7 @@ function _sess_destroy_sid($sid) {
* 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);
}
/**
@@ -230,7 +230,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 28 Sep 2008 16:44:06 -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/aggregator/aggregator.admin.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.admin.inc,v
retrieving revision 1.16
diff -u -p -r1.16 aggregator.admin.inc
--- modules/aggregator/aggregator.admin.inc 17 Sep 2008 07:11:56 -0000 1.16
+++ modules/aggregator/aggregator.admin.inc 28 Sep 2008 16:44:06 -0000
@@ -20,7 +20,7 @@ function aggregator_admin_overview() {
* The page HTML.
*/
function aggregator_view() {
- $result = db_query('SELECT f.*, COUNT(i.iid) AS items FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.checked, f.link, f.description, f.hash, f.etag, f.modified, f.image, f.block ORDER BY f.title');
+ $result = db_query('SELECT f.*, COUNT(i.[iid]) AS [items] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_item}] i ON f.[fid] = i.[fid] GROUP BY f.[fid], f.[title], f.[url], f.[refresh], f.[checked], f.[link], f.[description], f.[hash], f.[etag], f.[modified], f.[image], f.[block] ORDER BY f.[title]');
$output = '' . t('Feed overview') . '
';
@@ -31,7 +31,7 @@ function aggregator_view() {
}
$output .= theme('table', $header, $rows);
- $result = db_query('SELECT c.cid, c.title, count(ci.iid) as items FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid GROUP BY c.cid, c.title ORDER BY title');
+ $result = db_query('SELECT c.[cid], c.[title], COUNT(ci.[iid]) AS [items] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_item}] ci ON c.[cid] = ci.[cid] GROUP BY c.[cid], c.[title] ORDER BY [title]');
$output .= '' . t('Category overview') . '
';
@@ -89,7 +89,7 @@ function aggregator_form_feed(&$form_sta
// Handling of categories.
$options = array();
$values = array();
- $categories = db_query('SELECT c.cid, c.title, f.fid FROM {aggregator_category} c LEFT JOIN {aggregator_category_feed} f ON c.cid = f.cid AND f.fid = %d ORDER BY title', $edit['fid']);
+ $categories = db_query('SELECT c.[cid], c.[title], f.[fid] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_feed}] f ON c.[cid] = f.[cid] AND f.[fid] = %d ORDER BY [title]', $edit['fid']);
while ($category = db_fetch_object($categories)) {
$options[$category->cid] = check_plain($category->title);
if ($category->fid) $values[] = $category->cid;
@@ -133,10 +133,10 @@ function aggregator_form_feed_validate($
}
// Check for duplicate titles.
if (isset($form_state['values']['fid'])) {
- $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE (title = '%s' OR url = '%s') AND fid <> %d", $form_state['values']['title'], $form_state['values']['url'], $form_state['values']['fid']);
+ $result = db_query("SELECT [title], [url] FROM [{aggregator_feed}] WHERE ([title] = %s OR [url] = %s) AND [fid] <> %d", $form_state['values']['title'], $form_state['values']['url'], $form_state['values']['fid']);
}
else {
- $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url = '%s'", $form_state['values']['title'], $form_state['values']['url']);
+ $result = db_query("SELECT [title], [url] FROM [{aggregator_feed}] WHERE [title] = %s OR [url] = %s", $form_state['values']['title'], $form_state['values']['url']);
}
while ($feed = db_fetch_object($result)) {
if (strcasecmp($feed->title, $form_state['values']['title']) == 0) {
@@ -257,7 +257,7 @@ function aggregator_form_opml(&$form_sta
// Handling of categories.
$options = array();
- $categories = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
+ $categories = db_query('SELECT [cid], [title] FROM [{aggregator_category}] ORDER BY [title]');
while ($category = db_fetch_object($categories)) {
$options[$category->cid] = check_plain($category->title);
}
@@ -323,7 +323,7 @@ function aggregator_form_opml_submit($fo
}
// Check for duplicate titles or URLs.
- $result = db_query("SELECT title, url FROM {aggregator_feed} WHERE title = '%s' OR url = '%s'", $feed['title'], $feed['url']);
+ $result = db_query("SELECT [title], [url] FROM [{aggregator_feed}] WHERE [title] = %s OR [url] = %s", $feed['title'], $feed['url']);
while ($old = db_fetch_object($result)) {
if (strcasecmp($old->title, $feed['title']) == 0) {
drupal_set_message(t('A feed named %title already exists.', array('%title' => $old->title)), 'warning');
@@ -458,10 +458,10 @@ function aggregator_form_category_valida
if ($form_state['values']['op'] == t('Save')) {
// Check for duplicate titles
if (isset($form_state['values']['cid'])) {
- $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s' AND cid <> %d", $form_state['values']['title'], $form_state['values']['cid']));
+ $category = db_fetch_object(db_query("SELECT [cid] FROM [{aggregator_category}] WHERE [title] = %s AND [cid] <> %d", $form_state['values']['title'], $form_state['values']['cid']));
}
else {
- $category = db_fetch_object(db_query("SELECT cid FROM {aggregator_category} WHERE title = '%s'", $form_state['values']['title']));
+ $category = db_fetch_object(db_query("SELECT [cid] FROM [{aggregator_category}] WHERE [title] = %s", $form_state['values']['title']));
}
if ($category) {
form_set_error('title', t('A category named %category already exists. Please enter a unique title.', array('%category' => $form_state['values']['title'])));
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.392
diff -u -p -r1.392 aggregator.module
--- modules/aggregator/aggregator.module 17 Sep 2008 07:11:56 -0000 1.392
+++ modules/aggregator/aggregator.module 28 Sep 2008 16:44:06 -0000
@@ -262,7 +262,7 @@ function aggregator_init() {
* TRUE if there is at least one category and the user has access to them, FALSE otherwise.
*/
function _aggregator_has_categories() {
- return user_access('access news feeds') && db_result(db_query('SELECT COUNT(*) FROM {aggregator_category}'));
+ return user_access('access news feeds') && db_result(db_query('SELECT COUNT(*) FROM [{aggregator_category}]'));
}
/**
@@ -281,7 +281,7 @@ function aggregator_perm() {
* Checks news feeds for updates once their refresh interval has elapsed.
*/
function aggregator_cron() {
- $result = db_query('SELECT * FROM {aggregator_feed} WHERE checked + refresh < %d', REQUEST_TIME);
+ $result = db_query('SELECT * FROM [{aggregator_feed}] WHERE [checked] + [refresh] < %d', REQUEST_TIME);
while ($feed = db_fetch_array($result)) {
aggregator_refresh($feed);
}
@@ -295,11 +295,11 @@ function aggregator_cron() {
function aggregator_block($op = 'list', $delta = '', $edit = array()) {
if (user_access('access news feeds')) {
if ($op == 'list') {
- $result = db_query('SELECT cid, title FROM {aggregator_category} ORDER BY title');
+ $result = db_query('SELECT [cid], [title] FROM [{aggregator_category}] ORDER BY [title]');
while ($category = db_fetch_object($result)) {
$block['category-' . $category->cid]['info'] = t('!title category latest items', array('!title' => $category->title));
}
- $result = db_query('SELECT fid, title FROM {aggregator_feed} WHERE block <> 0 ORDER BY fid');
+ $result = db_query('SELECT [fid], [title] FROM [{aggregator_feed}] WHERE [block] <> 0 ORDER BY [fid]');
while ($feed = db_fetch_object($result)) {
$block['feed-' . $feed->fid]['info'] = t('!title feed latest items', array('!title' => $feed->title));
}
@@ -307,7 +307,7 @@ function aggregator_block($op = 'list',
elseif ($op == 'configure') {
list($type, $id) = explode('-', $delta);
if ($type == 'category') {
- $value = db_result(db_query('SELECT block FROM {aggregator_category} WHERE cid = %d', $id));
+ $value = db_result(db_query('SELECT [block] FROM [{aggregator_category}] WHERE [cid] = %d', $id));
$form['block'] = array(
'#type' => 'select',
'#title' => t('Number of news items in block'),
@@ -320,24 +320,24 @@ function aggregator_block($op = 'list',
elseif ($op == 'save') {
list($type, $id) = explode('-', $delta);
if ($type == 'category') {
- $value = db_query('UPDATE {aggregator_category} SET block = %d WHERE cid = %d', $edit['block'], $id);
+ $value = db_query('UPDATE [{aggregator_category}] SET [block] = %d WHERE [cid] = %d', $edit['block'], $id);
}
}
elseif ($op == 'view') {
list($type, $id) = explode('-', $delta);
switch ($type) {
case 'feed':
- if ($feed = db_fetch_object(db_query('SELECT fid, title, block FROM {aggregator_feed} WHERE block <> 0 AND fid = %d', $id))) {
+ if ($feed = db_fetch_object(db_query('SELECT [fid], [title], [block] FROM [{aggregator_feed}] WHERE [block] <> 0 AND [fid] = %d', $id))) {
$block['subject'] = check_plain($feed->title);
- $result = db_query_range('SELECT * FROM {aggregator_item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC', $feed->fid, 0, $feed->block);
+ $result = db_query_range('SELECT * FROM [{aggregator_item}] WHERE [fid] = %d ORDER BY [timestamp] DESC, [iid] DESC', $feed->fid, 0, $feed->block);
$read_more = theme('more_link', url('aggregator/sources/' . $feed->fid), t("View this feed's recent news."));
}
break;
case 'category':
- if ($category = db_fetch_object(db_query('SELECT cid, title, block FROM {aggregator_category} WHERE cid = %d', $id))) {
+ if ($category = db_fetch_object(db_query('SELECT [cid], [title], [block] FROM [{aggregator_category}] WHERE [cid] = %d', $id))) {
$block['subject'] = check_plain($category->title);
- $result = db_query_range('SELECT i.* FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON ci.iid = i.iid WHERE ci.cid = %d ORDER BY i.timestamp DESC, i.iid DESC', $category->cid, 0, $category->block);
+ $result = db_query_range('SELECT i.* FROM [{aggregator_category_item}] ci LEFT JOIN [{aggregator_item}] i ON ci.[iid] = i.[iid] WHERE ci.[cid] = %d ORDER BY i.[timestamp] DESC, i.[iid] DESC', $category->cid, 0, $category->block);
$read_more = theme('more_link', url('aggregator/categories/' . $category->cid), t("View this category's recent news."));
}
break;
@@ -369,20 +369,20 @@ function aggregator_save_category($edit)
if (!empty($edit['cid'])) {
$link_path .= $edit['cid'];
if (!empty($edit['title'])) {
- db_query("UPDATE {aggregator_category} SET title = '%s', description = '%s' WHERE cid = %d", $edit['title'], $edit['description'], $edit['cid']);
+ db_query("UPDATE [{aggregator_category}] SET [title] = %s, [description] = %s WHERE [cid] = %d", $edit['title'], $edit['description'], $edit['cid']);
$op = 'update';
}
else {
- db_query('DELETE FROM {aggregator_category} WHERE cid = %d', $edit['cid']);
+ db_query('DELETE FROM [{aggregator_category}] WHERE [cid] = %d', $edit['cid']);
// Make sure there is no active block for this category.
- db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s'", 'aggregator', 'category-' . $edit['cid']);
+ db_query("DELETE FROM [{blocks}] WHERE [module] = %s AND [delta] = %s", 'aggregator', 'category-' . $edit['cid']);
$edit['title'] = '';
$op = 'delete';
}
}
elseif (!empty($edit['title'])) {
// A single unique id for bundles and feeds, to use in blocks.
- db_query("INSERT INTO {aggregator_category} (title, description, block) VALUES ('%s', '%s', 5)", $edit['title'], $edit['description']);
+ db_query("INSERT INTO [{aggregator_category}] ([title], [description], [block]) VALUES (%s, %s, 5)", $edit['title'], $edit['description']);
$link_path .= db_last_insert_id('aggregator_category', 'cid');
$op = 'insert';
}
@@ -400,27 +400,27 @@ function aggregator_save_category($edit)
function aggregator_save_feed($edit) {
if (!empty($edit['fid'])) {
// An existing feed is being modified, delete the category listings.
- db_query('DELETE FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
+ db_query('DELETE FROM [{aggregator_category_feed}] WHERE [fid] = %d', $edit['fid']);
}
if (!empty($edit['fid']) && !empty($edit['title'])) {
- db_query("UPDATE {aggregator_feed} SET title = '%s', url = '%s', refresh = %d, block = %d WHERE fid = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], $edit['fid']);
+ db_query("UPDATE [{aggregator_feed}] SET [title] = %s, [url] = %s, [refresh] = %d, [block] = %d WHERE [fid] = %d", $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], $edit['fid']);
}
elseif (!empty($edit['fid'])) {
$items = array();
- $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
+ $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d', $edit['fid']);
while ($item = db_fetch_object($result)) {
- $items[] = "iid = $item->iid";
+ $items[] = "[iid] = $item->iid";
}
if (!empty($items)) {
- db_query('DELETE FROM {aggregator_category_item} WHERE ' . implode(' OR ', $items));
+ db_query('DELETE FROM [{aggregator_category_item}] WHERE ' . implode(' OR ', $items));
}
- db_query('DELETE FROM {aggregator_feed} WHERE fid = %d', $edit['fid']);
- db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $edit['fid']);
+ db_query('DELETE FROM [{aggregator_feed}] WHERE [fid] = %d', $edit['fid']);
+ db_query('DELETE FROM [{aggregator_item}] WHERE [fid] = %d', $edit['fid']);
// Make sure there is no active block for this feed.
- db_query("DELETE FROM {blocks} WHERE module = '%s' AND delta = '%s'", 'aggregator', 'feed-' . $edit['fid']);
+ db_query("DELETE FROM [{blocks}] WHERE [module] = %s AND [delta] = %s", 'aggregator', 'feed-' . $edit['fid']);
}
elseif (!empty($edit['title'])) {
- db_query("INSERT INTO {aggregator_feed} (title, url, refresh, block, description, image) VALUES ('%s', '%s', %d, %d, '', '')", $edit['title'], $edit['url'], $edit['refresh'], $edit['block']);
+ db_query("INSERT INTO [{aggregator_feed}] ([title], [url], [refresh], [block], [description], [image]) VALUES (%s, %s, %d, %d, %s, %s)", $edit['title'], $edit['url'], $edit['refresh'], $edit['block'], '', '');
// A single unique ID for bundles and feeds, to use in blocks.
$edit['fid'] = db_last_insert_id('aggregator_feed', 'fid');
}
@@ -429,7 +429,7 @@ function aggregator_save_feed($edit) {
if (!empty($edit['category'])) {
foreach ($edit['category'] as $cid => $value) {
if ($value) {
- db_query('INSERT INTO {aggregator_category_feed} (fid, cid) VALUES (%d, %d)', $edit['fid'], $cid);
+ db_query('INSERT INTO [{aggregator_category_feed}] ([fid], [cid]) VALUES (%d, %d)', $edit['fid'], $cid);
}
}
}
@@ -443,15 +443,15 @@ function aggregator_save_feed($edit) {
* An associative array describing the feed to be cleared.
*/
function aggregator_remove($feed) {
- $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
+ $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d', $feed['fid']);
while ($item = db_fetch_object($result)) {
- $items[] = "iid = $item->iid";
+ $items[] = "[iid] = $item->iid";
}
if (!empty($items)) {
- db_query('DELETE FROM {aggregator_category_item} WHERE ' . implode(' OR ', $items));
+ db_query('DELETE FROM [{aggregator_category_item}] WHERE ' . implode(' OR ', $items));
}
- db_query('DELETE FROM {aggregator_item} WHERE fid = %d', $feed['fid']);
- db_query("UPDATE {aggregator_feed} SET checked = 0, hash = '', etag = '', modified = 0 WHERE fid = %d", $feed['fid']);
+ db_query('DELETE FROM [{aggregator_item}] WHERE [fid] = %d', $feed['fid']);
+ db_query("UPDATE [{aggregator_feed}] SET [checked] = %d, [hash] = %s, [etag] = %s, [modified] = %d WHERE [fid] = %d", 0, '', '', 0, $feed['fid']);
drupal_set_message(t('The news items from %site have been removed.', array('%site' => $feed['title'])));
}
@@ -592,7 +592,7 @@ function aggregator_refresh($feed) {
// Process HTTP response code.
switch ($result->code) {
case 304:
- db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', REQUEST_TIME, $feed['fid']);
+ db_query('UPDATE [{aggregator_feed}] SET [checked] = %d WHERE [fid] = %d', REQUEST_TIME, $feed['fid']);
drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title'])));
break;
case 301:
@@ -606,7 +606,7 @@ function aggregator_refresh($feed) {
// data. If both are equal we say that feed is not updated.
$md5 = md5($result->data);
if ($feed['hash'] == $md5) {
- db_query('UPDATE {aggregator_feed} SET checked = %d WHERE fid = %d', REQUEST_TIME, $feed['fid']);
+ db_query('UPDATE [{aggregator_feed}] SET [checked] = %d WHERE [fid] = %d', REQUEST_TIME, $feed['fid']);
drupal_set_message(t('There is no new syndicated content from %site.', array('%site' => $feed['title'])));
break;
}
@@ -636,7 +636,7 @@ function aggregator_refresh($feed) {
$etag = empty($result->headers['ETag']) ? '' : $result->headers['ETag'];
// Update the feed data.
- db_query("UPDATE {aggregator_feed} SET url = '%s', checked = %d, link = '%s', description = '%s', image = '%s', hash = '%s', etag = '%s', modified = %d WHERE fid = %d", $feed['url'], REQUEST_TIME, $channel['LINK'], $channel['DESCRIPTION'], $image, $md5, $etag, $modified, $feed['fid']);
+ db_query("UPDATE [{aggregator_feed}] SET [url] = %s, [checked] = %d, [link] = %s, [description] = %s, [image] = %s, [hash] = %s, [etag] = %s, [modified] = %d WHERE [fid] = %d", $feed['url'], REQUEST_TIME, $channel['LINK'], $channel['DESCRIPTION'], $image, $md5, $etag, $modified, $feed['fid']);
// Clear the cache.
cache_clear_all();
@@ -793,13 +793,13 @@ function aggregator_parse_feed(&$data, $
// we find a duplicate entry, we resolve it and pass along its ID is such
// that we can update it if needed.
if (!empty($guid)) {
- $entry = db_fetch_object(db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = %d AND guid = '%s'", $feed['fid'], $guid));
+ $entry = db_fetch_object(db_query("SELECT [iid], [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d AND [guid] = %s", $feed['fid'], $guid));
}
else if ($link && $link != $feed['link'] && $link != $feed['url']) {
- $entry = db_fetch_object(db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = %d AND link = '%s'", $feed['fid'], $link));
+ $entry = db_fetch_object(db_query("SELECT [iid], [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d AND [link] = %s", $feed['fid'], $link));
}
else {
- $entry = db_fetch_object(db_query("SELECT iid, timestamp FROM {aggregator_item} WHERE fid = %d AND title = '%s'", $feed['fid'], $title));
+ $entry = db_fetch_object(db_query("SELECT [iid], [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d AND [title] = %s", $feed['fid'], $title));
}
if (!$timestamp) {
@@ -811,7 +811,7 @@ function aggregator_parse_feed(&$data, $
// Remove all items that are older than flush item timer.
$age = REQUEST_TIME - variable_get('aggregator_clear', 9676800);
- $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
+ $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d AND [timestamp] < %d', $feed['fid'], $age);
$items = array();
$num_rows = FALSE;
@@ -820,8 +820,8 @@ function aggregator_parse_feed(&$data, $
$num_rows = TRUE;
}
if ($num_rows) {
- db_query('DELETE FROM {aggregator_category_item} WHERE iid IN (' . implode(', ', $items) . ')');
- db_query('DELETE FROM {aggregator_item} WHERE fid = %d AND timestamp < %d', $feed['fid'], $age);
+ db_query('DELETE FROM [{aggregator_category_item}] WHERE [iid] IN (' . implode(', ', $items) . ')');
+ db_query('DELETE FROM [{aggregator_item}] WHERE [fid] = %d AND [timestamp] < %d', $feed['fid'], $age);
}
return TRUE;
@@ -835,19 +835,19 @@ function aggregator_parse_feed(&$data, $
*/
function aggregator_save_item($edit) {
if ($edit['iid'] && $edit['title']) {
- db_query("UPDATE {aggregator_item} SET title = '%s', link = '%s', author = '%s', description = '%s', guid = '%s', timestamp = %d WHERE iid = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']);
+ db_query("UPDATE [{aggregator_item}] SET [title] = %s, [link] = %s, [author] = %s, [description] = %s, [guid] = %s, [timestamp] = %d WHERE [iid] = %d", $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['guid'], $edit['timestamp'], $edit['iid']);
}
elseif ($edit['iid']) {
- db_query('DELETE FROM {aggregator_item} WHERE iid = %d', $edit['iid']);
- db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $edit['iid']);
+ db_query('DELETE FROM [{aggregator_item}] WHERE [iid] = %d', $edit['iid']);
+ db_query('DELETE FROM [{aggregator_category_item}] WHERE [iid] = %d', $edit['iid']);
}
elseif ($edit['title'] && $edit['link']) {
- db_query("INSERT INTO {aggregator_item} (fid, title, link, author, description, timestamp, guid) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s')", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']);
+ db_query("INSERT INTO [{aggregator_item}] ([fid], [title], [link], [author], [description], [timestamp], [guid]) VALUES (%d, %s, %s, %s, %s, %d, %s)", $edit['fid'], $edit['title'], $edit['link'], $edit['author'], $edit['description'], $edit['timestamp'], $edit['guid']);
$edit['iid'] = db_last_insert_id('aggregator_item', 'iid');
// file the items in the categories indicated by the feed
- $categories = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $edit['fid']);
+ $categories = db_query('SELECT [cid] FROM [{aggregator_category_feed}] WHERE [fid] = %d', $edit['fid']);
while ($category = db_fetch_object($categories)) {
- db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $category->cid, $edit['iid']);
+ db_query('INSERT INTO [{aggregator_category_item}] ([cid], [iid]) VALUES (%d, %d)', $category->cid, $edit['iid']);
}
}
}
@@ -863,7 +863,7 @@ function aggregator_save_item($edit) {
function aggregator_feed_load($fid) {
static $feeds;
if (!isset($feeds[$fid])) {
- $feeds[$fid] = db_fetch_array(db_query('SELECT * FROM {aggregator_feed} WHERE fid = %d', $fid));
+ $feeds[$fid] = db_fetch_array(db_query('SELECT * FROM [{aggregator_feed}] WHERE [fid] = %d', $fid));
}
return $feeds[$fid];
@@ -880,7 +880,7 @@ function aggregator_feed_load($fid) {
function aggregator_category_load($cid) {
static $categories;
if (!isset($categories[$cid])) {
- $categories[$cid] = db_fetch_array(db_query('SELECT * FROM {aggregator_category} WHERE cid = %d', $cid));
+ $categories[$cid] = db_fetch_array(db_query('SELECT * FROM [{aggregator_category}] WHERE [cid] = %d', $cid));
}
return $categories[$cid];
Index: modules/aggregator/aggregator.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.pages.inc,v
retrieving revision 1.18
diff -u -p -r1.18 aggregator.pages.inc
--- modules/aggregator/aggregator.pages.inc 17 Sep 2008 07:11:56 -0000 1.18
+++ modules/aggregator/aggregator.pages.inc 28 Sep 2008 16:44:06 -0000
@@ -15,7 +15,7 @@
function aggregator_page_last() {
drupal_add_feed(url('aggregator/rss'), variable_get('site_name', 'Drupal') . ' ' . t('aggregator'));
- $items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC');
+ $items = aggregator_feed_items_load('SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_item}] i INNER JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] ORDER BY i.[timestamp] DESC, i.[iid] DESC');
return _aggregator_page_list($items, arg(1));
}
@@ -42,7 +42,7 @@ function aggregator_page_source($arg1, $
// It is safe to include the fid in the query because it's loaded from the
// database by aggregator_feed_load.
- $items = aggregator_feed_items_load('SELECT * FROM {aggregator_item} WHERE fid = ' . $feed->fid . ' ORDER BY timestamp DESC, iid DESC');
+ $items = aggregator_feed_items_load('SELECT * FROM [{aggregator_item}] WHERE [fid] = ' . $feed->fid . ' ORDER BY [timestamp] DESC, [iid] DESC');
return _aggregator_page_list($items, arg(3), $feed_source);
}
@@ -68,7 +68,7 @@ function aggregator_page_category($arg1,
// It is safe to include the cid in the query because it's loaded from the
// database by aggregator_category_load.
- $items = aggregator_feed_items_load('SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = ' . $category['cid'] . ' ORDER BY timestamp DESC, i.iid DESC');
+ $items = aggregator_feed_items_load('SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_category_item}] c LEFT JOIN [{aggregator_item}] i ON c.[iid] = i.[iid] LEFT JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] WHERE [cid] = ' . $category['cid'] . ' ORDER BY [timestamp] DESC, i.[iid] DESC');
return _aggregator_page_list($items, arg(3));
}
@@ -86,7 +86,7 @@ function aggregator_feed_items_load($sql
if (isset($sql)) {
$result = pager_query($sql, 20);
while ($item = db_fetch_object($result)) {
- $result_category = db_query('SELECT c.title, c.cid FROM {aggregator_category_item} ci LEFT JOIN {aggregator_category} c ON ci.cid = c.cid WHERE ci.iid = %d ORDER BY c.title', $item->iid);
+ $result_category = db_query('SELECT c.[title], c.[cid] FROM [{aggregator_category_item}] ci LEFT JOIN [{aggregator_category}] c ON ci.[cid] = c.[cid] WHERE ci.[iid] = %d ORDER BY c.[title]', $item->iid);
$item->categories = array();
while ($item_categories = db_fetch_object($result_category)) {
$item->categories[] = $item_categories;
@@ -158,7 +158,7 @@ function aggregator_categorize_items($it
foreach ($items as $item) {
$form['items'][$item->iid] = array('#markup' => theme('aggregator_item', $item));
$form['categories'][$item->iid] = array();
- $categories_result = db_query('SELECT c.cid, c.title, ci.iid FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid AND ci.iid = %d', $item->iid);
+ $categories_result = db_query('SELECT c.[cid], c.[title], ci.[iid] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_item}] ci ON c.[cid] = ci.[cid] AND ci.[iid] = %d', $item->iid);
$selected = array();
while ($category = db_fetch_object($categories_result)) {
if (!$done) {
@@ -197,10 +197,10 @@ function aggregator_categorize_items_val
function aggregator_categorize_items_submit($form, &$form_state) {
if (!empty($form_state['values']['categories'])) {
foreach ($form_state['values']['categories'] as $iid => $selection) {
- db_query('DELETE FROM {aggregator_category_item} WHERE iid = %d', $iid);
+ db_query('DELETE FROM [{aggregator_category_item}] WHERE [iid] = %d', $iid);
foreach ($selection as $cid) {
if ($cid) {
- db_query('INSERT INTO {aggregator_category_item} (cid, iid) VALUES (%d, %d)', $cid, $iid);
+ db_query('INSERT INTO [{aggregator_category_item}] ([cid], [iid]) VALUES (%d, %d)', $cid, $iid);
}
}
}
@@ -281,14 +281,14 @@ function template_preprocess_aggregator_
* Menu callback; displays all the feeds used by the aggregator.
*/
function aggregator_page_sources() {
- $result = db_query('SELECT f.fid, f.title, f.description, f.image, MAX(i.timestamp) AS last FROM {aggregator_feed} f LEFT JOIN {aggregator_item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.description, f.image ORDER BY last DESC, f.title');
+ $result = db_query('SELECT f.[fid], f.[title], f.[description], f.[image], MAX(i.[timestamp]) AS [last] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_item}] i ON f.[fid] = i.[fid] GROUP BY f.[fid], f.[title], f.[description], f.[image] ORDER BY [last] DESC, f.[title]');
$output = '';
while ($feed = db_fetch_object($result)) {
// Most recent items:
$summary_items = array();
if (variable_get('aggregator_summary_items', 3)) {
- $items = db_query_range('SELECT i.title, i.timestamp, i.link FROM {aggregator_item} i WHERE i.fid = %d ORDER BY i.timestamp DESC', $feed->fid, 0, variable_get('aggregator_summary_items', 3));
+ $items = db_query_range('SELECT i.[title], i.[timestamp], i.[link] FROM [{aggregator_item}] i WHERE i.[fid] = %d ORDER BY i.[timestamp] DESC', $feed->fid, 0, variable_get('aggregator_summary_items', 3));
while ($item = db_fetch_object($items)) {
$summary_items[] = theme('aggregator_summary_item', $item);
}
@@ -305,13 +305,13 @@ function aggregator_page_sources() {
* Menu callback; displays all the categories used by the aggregator.
*/
function aggregator_page_categories() {
- $result = db_query('SELECT c.cid, c.title, c.description FROM {aggregator_category} c LEFT JOIN {aggregator_category_item} ci ON c.cid = ci.cid LEFT JOIN {aggregator_item} i ON ci.iid = i.iid GROUP BY c.cid, c.title, c.description');
+ $result = db_query('SELECT c.[cid], c.[title], c.[description] FROM [{aggregator_category}] c LEFT JOIN [{aggregator_category_item}] ci ON c.[cid] = ci.[cid] LEFT JOIN [{aggregator_item}] i ON ci.[iid] = i.[iid] GROUP BY c.[cid], c.[title], c.[description]');
$output = '';
while ($category = db_fetch_object($result)) {
if (variable_get('aggregator_summary_items', 3)) {
$summary_items = array();
- $items = db_query_range('SELECT i.title, i.timestamp, i.link, f.title as feed_title, f.link as feed_link FROM {aggregator_category_item} ci LEFT JOIN {aggregator_item} i ON i.iid = ci.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE ci.cid = %d ORDER BY i.timestamp DESC', $category->cid, 0, variable_get('aggregator_summary_items', 3));
+ $items = db_query_range('SELECT i.[title], i.[timestamp], i.[link], f.[title] AS [feed_title], f.[link] AS [feed_link] FROM [{aggregator_category_item}] ci LEFT JOIN [{aggregator_item}] i ON i.[iid] = ci.[iid] LEFT JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] WHERE ci.[cid] = %d ORDER BY i.[timestamp] DESC', $category->cid, 0, variable_get('aggregator_summary_items', 3));
while ($item = db_fetch_object($items)) {
$summary_items[] = theme('aggregator_summary_item', $item);
}
@@ -330,14 +330,14 @@ function aggregator_page_rss() {
$result = NULL;
// arg(2) is the passed cid, only select for that category.
if (arg(2)) {
- $category = db_fetch_object(db_query('SELECT cid, title FROM {aggregator_category} WHERE cid = %d', arg(2)));
- $sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_category_item} c LEFT JOIN {aggregator_item} i ON c.iid = i.iid LEFT JOIN {aggregator_feed} f ON i.fid = f.fid WHERE cid = %d ORDER BY timestamp DESC, i.iid DESC';
+ $category = db_fetch_object(db_query('SELECT [cid], [title] FROM [{aggregator_category}] WHERE [cid] = %d', arg(2)));
+ $sql = 'SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_category_item}] c LEFT JOIN [{aggregator_item}] i ON c.[iid] = i.[iid] LEFT JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] WHERE [cid] = %d ORDER BY [timestamp] DESC, i.[iid] DESC';
$result = db_query_range($sql, $category->cid, 0, variable_get('feed_default_items', 10));
}
// Or, get the default aggregator items.
else {
$category = NULL;
- $sql = 'SELECT i.*, f.title AS ftitle, f.link AS flink FROM {aggregator_item} i INNER JOIN {aggregator_feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC';
+ $sql = 'SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_item}] i INNER JOIN [{aggregator_feed}] f ON i.[fid] = f.[fid] ORDER BY i.[timestamp] DESC, i.[iid] DESC';
$result = db_query_range($sql, 0, variable_get('feed_default_items', 10));
}
@@ -401,10 +401,10 @@ function theme_aggregator_page_rss($feed
*/
function aggregator_page_opml($cid = NULL) {
if ($cid) {
- $result = db_query('SELECT f.title, f.url FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} c on f.fid = c.fid WHERE c.cid = %d ORDER BY title', $cid);
+ $result = db_query('SELECT f.[title], f.[url] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_category_feed}] c on f.[fid] = c.[fid] WHERE c.[cid] = %d ORDER BY [title]', $cid);
}
else {
- $result = db_query('SELECT * FROM {aggregator_feed} ORDER BY title');
+ $result = db_query('SELECT * FROM [{aggregator_feed}] ORDER BY [title]');
}
$feeds = array();
Index: modules/aggregator/aggregator.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.test,v
retrieving revision 1.8
diff -u -p -r1.8 aggregator.test
--- modules/aggregator/aggregator.test 15 Sep 2008 21:06:06 -0000 1.8
+++ modules/aggregator/aggregator.test 28 Sep 2008 16:44:06 -0000
@@ -23,7 +23,7 @@ class AggregatorTestCase extends DrupalW
$this->drupalPost('admin/content/aggregator/add/feed', $edit, t('Save'));
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), t('The feed !name has been added.', array('!name' => $edit['title'])));
- $feed = db_fetch_object(db_query("SELECT * FROM {aggregator_feed} WHERE title = '%s' AND url='%s'", $edit['title'], $edit['url']));
+ $feed = db_fetch_object(db_query("SELECT * FROM [{aggregator_feed}] WHERE [title] = %s AND [url] = %s", $edit['title'], $edit['url']));
$this->assertTrue(!empty($feed), t('The feed found in database.'));
return $feed;
}
@@ -65,14 +65,14 @@ class AggregatorTestCase extends DrupalW
$this->assertResponse(200, t('rss.xml is reachable.'));
// Our tests are based off of rss.xml, so let's find out how many elements should be related.
- $feed_count = db_result(db_query_range(db_rewrite_sql('SELECT COUNT(*) FROM {node} n WHERE n.promote = 1 AND n.status = 1'), 0, variable_get('feed_default_items', 10)));
+ $feed_count = db_result(db_query_range(db_rewrite_sql('SELECT COUNT(*) FROM [{node}] n WHERE n.[promote] = 1 AND n.[status] = 1'), 0, variable_get('feed_default_items', 10)));
$feed_count = $feed_count > 10 ? 10 : $feed_count;
// Refresh the feed (simulated link click).
$this->drupalGet('admin/content/aggregator/update/' . $feed->fid);
// Ensure we have the right number of items.
- $result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = %d', $feed->fid);
+ $result = db_query('SELECT [iid] FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid);
$items = array();
$feed->items = array();
while ($item = db_fetch_object($result)) {
@@ -99,7 +99,7 @@ class AggregatorTestCase extends DrupalW
*/
function getFeedCategories($feed) {
// add the categories to the feed so we can use them
- $result = db_query('SELECT cid FROM {aggregator_category_feed} WHERE fid = %d', $feed->fid);
+ $result = db_query('SELECT [cid] FROM [{aggregator_category_feed}] WHERE [fid] = %d', $feed->fid);
while ($category = db_fetch_object($result)) {
$feed->categories[] = $category->cid;
}
@@ -113,7 +113,7 @@ class AggregatorTestCase extends DrupalW
* @return boolean Feed is unique.
*/
function uniqueFeed($feed_name, $feed_url) {
- $result = db_result(db_query("SELECT count(*) FROM {aggregator_feed} WHERE title = '%s' AND url='%s'", $feed_name, $feed_url));
+ $result = db_result(db_query("SELECT COUNT(*) FROM [{aggregator_feed}] WHERE [title] = %s AND [url] = %s", $feed_name, $feed_url));
return (1 == $result);
}
@@ -324,7 +324,7 @@ class RemoveFeedTestCase extends Aggrega
$this->assertResponse(404, t('Deleted feed source does not exists.'));
// Check database for feed.
- $result = db_result(db_query("SELECT count(*) FROM {aggregator_feed} WHERE title = '%s' AND url='%s'", $feed->title, $feed->url));
+ $result = db_result(db_query("SELECT COUNT(*) FROM [{aggregator_feed}] WHERE [title] = %s AND [url] = %s", $feed->title, $feed->url));
$this->assertFalse($result, t('Feed not found in database'));
}
}
@@ -366,17 +366,17 @@ class UpdateFeedItemTestCase extends Agg
$this->drupalPost('admin/content/aggregator/add/feed', $edit, t('Save'));
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title'])), t('The feed !name has been added.', array('!name' => $edit['title'])));
- $feed = db_fetch_object(db_query("SELECT * FROM {aggregator_feed} WHERE url = '%s'", $edit['url']));
+ $feed = db_fetch_object(db_query("SELECT * FROM [{aggregator_feed}] WHERE [url] = %s", $edit['url']));
$this->drupalGet('admin/content/aggregator/update/' . $feed->fid);
- $before = db_result(db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = %d', $feed->fid));
+ $before = db_result(db_query('SELECT [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid));
// Sleep for 3 second.
sleep(3);
- db_query("UPDATE {aggregator_feed} SET checked = 0, hash = '', etag = '', modified = 0 WHERE fid = %d", $feed->fid);
+ db_query("UPDATE [{aggregator_feed}] SET [checked] = %d, [hash] = %s, [etag] = %s, [modified] = %d WHERE [fid] = %d", 0, '', '', 0, $feed->fid);
$this->drupalGet('admin/content/aggregator/update/' . $feed->fid);
- $after = db_result(db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = %d', $feed->fid));
+ $after = db_result(db_query('SELECT [timestamp] FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid));
$this->assertTrue($before === $after, t('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after)));
}
@@ -403,7 +403,7 @@ class RemoveFeedItemTestCase extends Agg
// Add and remove feed items and ensure that the count is zero.
$this->updateFeedItems($feed);
$this->removeFeedItems($feed);
- $count = db_result(db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = %d', $feed->fid));
+ $count = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_item}] WHERE [fid] = %d', $feed->fid));
$this->assertTrue($count == 0);
// Delete feed.
@@ -434,11 +434,11 @@ class CategorizeFeedItemTestCase extends
$this->drupalPost('admin/content/aggregator/add/category', $edit, t('Save'));
$this->assertRaw(t('The category %title has been added.', array('%title' => $edit['title'])), t('The category %title has been added.', array('%title' => $edit['title'])));
- $category = db_fetch_object(db_query("SELECT * FROM {aggregator_category} WHERE title = '%s'", $edit['title']));
+ $category = db_fetch_object(db_query("SELECT * FROM [{aggregator_category}] WHERE [title] = %s", $edit['title']));
$this->assertTrue(!empty($category), t('The category found in database.'));
$link_path = 'aggregator/categories/' . $category->cid;
- $menu_link = db_fetch_object(db_query("SELECT * FROM {menu_links} WHERE link_path = '%s'", $link_path));
+ $menu_link = db_fetch_object(db_query("SELECT * FROM [{menu_links}] WHERE [link_path] = %s", $link_path));
$this->assertTrue(!empty($menu_link), t('The menu link associated with the category found in database.'));
// TODO: Need to add categories to the feed on creation.
@@ -450,7 +450,7 @@ class CategorizeFeedItemTestCase extends
if (!empty($feed->categories) && !empty($feed->items)) {
foreach ($feed->categories as $category) {
$items_str = implode(', ', $feed->items);
- $categorized_count = db_result(db_query('SELECT COUNT(*) FROM {aggregator_category_item} WHERE iid IN (' . $items_str . ')'));
+ $categorized_count = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_category_item}] WHERE [iid] IN (' . $items_str . ')'));
$this->assertEqual($feed->item_count, $categorized_count, t('Total items in feed equal to the total categorized feed items in database'));
}
}
@@ -478,10 +478,10 @@ class ImportOPMLTestCase extends Aggrega
* Open OPML import form.
*/
function openImportForm() {
- db_query('DELETE FROM {aggregator_category}');
+ db_query('DELETE FROM [{aggregator_category}]');
$category = $this->randomName(10, self::$prefix);
- db_query("INSERT INTO {aggregator_category} (cid, title, description) VALUES (%d, '%s', '%s')", 1, $category, '');
+ db_query("INSERT INTO [{aggregator_category}] ([cid], [title], [description]) VALUES (%d, %s, %s)", 1, $category, '');
$this->drupalGet('admin/content/aggregator/add/opml');
$this->assertText('A single OPML document may contain a collection of many feeds.', t('Looking for help text.'));
@@ -495,7 +495,7 @@ class ImportOPMLTestCase extends Aggrega
* Submit form filled with invalid fields.
*/
function validateImportFormFields() {
- $before = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}'));
+ $before = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]'));
$form = array();
$this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import'));
@@ -513,7 +513,7 @@ class ImportOPMLTestCase extends Aggrega
$this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import'));
$this->assertText(t('This URL is not valid.'), t('Error if the URL is invalid.'));
- $after = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}'));
+ $after = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]'));
$this->assertEqual($before, $after, t('No feeds were added during the three last form submissions.'));
}
@@ -521,7 +521,7 @@ class ImportOPMLTestCase extends Aggrega
* Submit form with invalid, empty and valid OPML files.
*/
function submitImportForm() {
- $before = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}'));
+ $before = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]'));
$form['files[upload]'] = $this->getInvalidOpml();
$this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import'));
@@ -531,15 +531,15 @@ class ImportOPMLTestCase extends Aggrega
$this->drupalPost('admin/content/aggregator/add/opml', $form, t('Import'));
$this->assertText(t('No new feed has been added.'), t('Attempting to load empty OPML from remote URL.'));
- $after = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}'));
+ $after = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]'));
$this->assertEqual($before, $after, t('No feeds were added during the two last form submissions.'));
- db_query('DELETE FROM {aggregator_feed}');
- db_query('DELETE FROM {aggregator_category}');
- db_query('DELETE FROM {aggregator_category_feed}');
+ db_query('DELETE FROM [{aggregator_feed}]');
+ db_query('DELETE FROM [{aggregator_category}]');
+ db_query('DELETE FROM [{aggregator_category_feed}]');
$category = $this->randomName(10, self::$prefix);
- db_query("INSERT INTO {aggregator_category} (cid, title, description) VALUES (%d, '%s', '%s')", 1, $category, '');
+ db_query("INSERT INTO [{aggregator_category}] ([cid], [title], [description]) VALUES (%d, %s, %s)", 1, $category, '');
$feeds[0] = $this->getFeedEditArray();
$feeds[1] = $this->getFeedEditArray();
@@ -553,10 +553,10 @@ class ImportOPMLTestCase extends Aggrega
$this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url'])), t('Verifying that a duplicate URL was identified'));
$this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title'])), t('Verifying that a duplicate title was identified'));
- $after = db_result(db_query('SELECT COUNT(*) FROM {aggregator_feed}'));
+ $after = db_result(db_query('SELECT COUNT(*) FROM [{aggregator_feed}]'));
$this->assertEqual($after, 2, t('Verifying that two distinct feeds were added.'));
- $feeds_from_db = db_query("SELECT f.title, f.url, f.refresh, cf.cid FROM {aggregator_feed} f LEFT JOIN {aggregator_category_feed} cf ON f.fid = cf.fid");
+ $feeds_from_db = db_query("SELECT f.[title], f.[url], f.[refresh], cf.[cid] FROM [{aggregator_feed}] f LEFT JOIN [{aggregator_category_feed}] cf ON f.[fid] = cf.[fid]");
$refresh = $category = TRUE;
while ($feed = db_fetch_array($feeds_from_db)) {
$title[$feed['url']] = $feed['title'];
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 28 Sep 2008 16:44:06 -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.310
diff -u -p -r1.310 block.module
--- modules/block/block.module 27 Sep 2008 19:47:42 -0000 1.310
+++ modules/block/block.module 28 Sep 2008 16:44:06 -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));
}
/**
@@ -329,7 +329,7 @@ function block_box_save($edit, $delta) {
$edit['body_format'] = FILTER_FORMAT_DEFAULT;
}
- db_query("UPDATE {boxes} SET body = '%s', info = '%s', format = %d WHERE bid = %d", $edit['body'], $edit['info'], $edit['body_format'], $delta);
+ db_query("UPDATE [{boxes}] SET [body] = %s, [info] = %s, [format] = %d WHERE [bid] = %d", $edit['body'], $edit['info'], $edit['body_format'], $delta);
return TRUE;
}
@@ -345,7 +345,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');
@@ -410,7 +410,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 28 Sep 2008 16:44:06 -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/blog/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v
retrieving revision 1.309
diff -u -p -r1.309 blog.module
--- modules/blog/blog.module 22 Jul 2008 20:00:55 -0000 1.309
+++ modules/blog/blog.module 28 Sep 2008 16:44:06 -0000
@@ -85,7 +85,7 @@ function blog_form(&$node) {
$node->body = '' . $blog->body . ' [' . l($blog->name, "node/$nid") . ']';
}
- if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
+ if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.[title] AS [ftitle], f.[link] AS [flink] FROM [{aggregator_item}] i, [{aggregator_feed}] f WHERE i.[iid] = %d AND i.[fid] = f.[fid]', $iid))) {
$node->title = $item->title;
// Note: $item->description has been validated on aggregation.
$node->body = '' . check_plain($item->title) . ' - ' . $item->description . ' [' . check_plain($item->ftitle) . "]\n";
@@ -178,7 +178,7 @@ function blog_page_user_access($account)
* Helper function to determine if a user has blog posts already.
*/
function _blog_post_exists($account) {
- return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1"), $account->uid, 0, 1));
+ return (bool)db_result(db_query_range(db_rewrite_sql("SELECT 1 FROM [{node}] n WHERE n.[type] = 'blog' AND n.[uid] = %d AND n.[status] = 1"), $account->uid, 0, 1));
}
/**
@@ -194,7 +194,7 @@ function blog_block($op = 'list', $delta
}
elseif ($op == 'view') {
if (user_access('access content')) {
- $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), 0, 10);
+ $result = db_query_range(db_rewrite_sql("SELECT n.[nid], n.[title], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[status] = 1 ORDER BY n.[created] DESC"), 0, 10);
if ($node_title_list = node_title_list($result)) {
$block['content'] = $node_title_list;
$block['content'] .= theme('more_link', url('blog'), t('Read the latest blog entries.'));
Index: modules/blog/blog.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.pages.inc,v
retrieving revision 1.10
diff -u -p -r1.10 blog.pages.inc
--- modules/blog/blog.pages.inc 22 May 2008 19:27:13 -0000 1.10
+++ modules/blog/blog.pages.inc 28 Sep 2008 16:44:06 -0000
@@ -25,7 +25,7 @@ function blog_page_user($account) {
$output = theme('item_list', $items);
- $result = pager_query(db_rewrite_sql("SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
+ $result = pager_query(db_rewrite_sql("SELECT n.[nid], n.[sticky], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[uid] = %d AND n.[status] = 1 ORDER BY n.[sticky] DESC, n.[created] DESC"), variable_get('default_nodes_main', 10), 0, NULL, $account->uid);
$has_posts = FALSE;
while ($node = db_fetch_object($result)) {
@@ -64,7 +64,7 @@ function blog_page_last() {
$output = theme('item_list', $items);
- $result = pager_query(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' 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.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[status] = 1 ORDER BY n.[sticky] DESC, n.[created] DESC"), variable_get('default_nodes_main', 10));
$has_posts = FALSE;
while ($node = db_fetch_object($result)) {
@@ -87,7 +87,7 @@ function blog_page_last() {
* Menu callback; displays an RSS feed containing recent blog entries of a given user.
*/
function blog_feed_user($account) {
- $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.uid = %d AND n.status = 1 ORDER BY n.created DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
+ $result = db_query_range(db_rewrite_sql("SELECT n.[nid], n.[created] FROM [{node}] n WHERE n.[type] = 'blog' AND n.[uid] = %d AND n.[status] = 1 ORDER BY n.[created] DESC"), $account->uid, 0, variable_get('feed_default_items', 10));
$channel['title'] = $account->name . "'s blog";
$channel['link'] = url('blog/' . $account->uid, array('absolute' => TRUE));
@@ -102,7 +102,7 @@ function blog_feed_user($account) {
* Menu callback; displays an RSS feed containing recent blog entries of all users.
*/
function blog_feed_last() {
- $result = db_query_range(db_rewrite_sql("SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' 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.[type] = 'blog' AND n.[status] = 1 ORDER BY n.[created] DESC"), 0, variable_get('feed_default_items', 10));
$channel['title'] = variable_get('site_name', 'Drupal') . ' blogs';
$channel['link'] = url('blog', array('absolute' => TRUE));
Index: modules/blogapi/blogapi.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blogapi/blogapi.module,v
retrieving revision 1.126
diff -u -p -r1.126 blogapi.module
--- modules/blogapi/blogapi.module 17 Sep 2008 21:07:47 -0000 1.126
+++ modules/blogapi/blogapi.module 28 Sep 2008 16:44:07 -0000
@@ -338,13 +338,13 @@ function blogapi_blogger_get_recent_post
}
if ($bodies) {
- $result = db_query_range("SELECT n.nid, n.title, r.body, r.format, n.comment, n.created, u.name FROM {node} n, {node_revisions} r, {users} u WHERE n.uid = u.uid AND n.vid = r.vid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array(
+ $result = db_query_range("SELECT n.[nid], n.[title], r.[body], r.[format], n.[comment], n.[created], u.[name] FROM [{node}] n, [{node_revisions}] r, [{users}] u WHERE n.[uid] = u.[uid] AND n.[vid] = r.[vid] AND n.[type] = :type AND n.[uid] = :uid ORDER BY n.[created] DESC", array(
':type' => $blogid,
':uid' => $user->uid
), 0, $number_of_posts);
}
else {
- $result = db_query_range("SELECT n.nid, n.title, n.created, u.name FROM {node} n, {users} u WHERE n.uid = u.uid AND n.type = :type AND n.uid = :uid ORDER BY n.created DESC", array(
+ $result = db_query_range("SELECT n.[nid], n.[title], n.[created], u.[name] FROM [{node}] n, [{users}] u WHERE n.[uid] = u.[uid] AND n.[type] = :type AND n.[uid] = :uid ORDER BY n.[created] DESC", array(
':type' => $blogid,
':uid' => $user->uid
), 0, $number_of_posts);
Index: modules/book/book.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.install,v
retrieving revision 1.22
diff -u -p -r1.22 book.install
--- modules/book/book.install 15 May 2008 21:19:24 -0000 1.22
+++ modules/book/book.install 28 Sep 2008 16:44:07 -0000
@@ -16,7 +16,7 @@ function book_install() {
*/
function book_uninstall() {
// Delete menu links.
- db_query("DELETE FROM {menu_links} WHERE module = 'book'");
+ db_query("DELETE FROM [{menu_links}] WHERE [module] = 'book'");
menu_cache_clear_all();
// Remove tables.
drupal_uninstall_schema('book');
Index: modules/book/book.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.module,v
retrieving revision 1.469
diff -u -p -r1.469 book.module
--- modules/book/book.module 27 Sep 2008 20:37:00 -0000 1.469
+++ modules/book/book.module 28 Sep 2008 16:44:07 -0000
@@ -210,7 +210,7 @@ function book_block($op = 'list', $delta
}
elseif ($current_bid) {
// Only display this block when the user is browsing a book.
- $title = db_result(db_query(db_rewrite_sql('SELECT n.title FROM {node} n WHERE n.nid = %d'), $node->book['bid']));
+ $title = db_result(db_query(db_rewrite_sql('SELECT n.[title] FROM [{node}] n WHERE n.[nid] = %d'), $node->book['bid']));
// Only show the block if the user has view access for the top-level node.
if ($title) {
$tree = menu_tree_all_data($node->book['menu_name'], $node->book);
@@ -266,14 +266,14 @@ function book_get_books() {
if (!isset($all_books)) {
$all_books = array();
- $result = db_query("SELECT DISTINCT(bid) FROM {book}");
+ $result = db_query("SELECT DISTINCT([bid]) FROM [{book}]");
$nids = array();
while ($book = db_fetch_array($result)) {
$nids[] = $book['bid'];
}
if ($nids) {
- $result2 = db_query(db_rewrite_sql("SELECT n.type, n.title, b.*, ml.* FROM {book} b INNER JOIN {node} n on b.nid = n.nid INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE n.nid IN (" . implode(',', $nids) . ") AND n.status = 1 ORDER BY ml.weight, ml.link_title"));
+ $result2 = db_query(db_rewrite_sql("SELECT n.[type], n.[title], b.*, ml.* FROM [{book}] b INNER JOIN [{node}] n on b.[nid] = n.[nid] INNER JOIN [{menu_links}] ml ON b.[mlid] = ml.[mlid] WHERE n.[nid] IN (" . implode(',', $nids) . ") AND n.[status] = 1 ORDER BY ml.[weight], ml.[link_title]"));
while ($link = db_fetch_array($result2)) {
$link['href'] = $link['link_path'];
$link['options'] = unserialize($link['options']);
@@ -466,10 +466,10 @@ function _book_update_outline(&$node) {
else {
// Check in case the parent is not is this book; the book takes precedence.
if (!empty($node->book['plid'])) {
- $parent = db_fetch_array(db_query("SELECT * FROM {book} WHERE mlid = %d", $node->book['plid']));
+ $parent = db_fetch_array(db_query("SELECT * FROM [{book}] WHERE [mlid] = %d", $node->book['plid']));
}
if (empty($node->book['plid']) || !$parent || $parent['bid'] != $node->book['bid']) {
- $node->book['plid'] = db_result(db_query("SELECT mlid FROM {book} WHERE nid = %d", $node->book['bid']));
+ $node->book['plid'] = db_result(db_query("SELECT [mlid] FROM [{book}] WHERE [nid] = %d", $node->book['bid']));
$node->book['parent_mismatch'] = TRUE; // Likely when JS is disabled.
}
}
@@ -477,10 +477,10 @@ function _book_update_outline(&$node) {
if (menu_link_save($node->book)) {
if ($new) {
// Insert new.
- db_query("INSERT INTO {book} (nid, mlid, bid) VALUES (%d, %d, %d)", $node->nid, $node->book['mlid'], $node->book['bid']);
+ db_query("INSERT INTO [{book}] ([nid], [mlid], [bid]) VALUES (%d, %d, %d)", $node->nid, $node->book['mlid'], $node->book['bid']);
}
else {
- if ($node->book['bid'] != db_result(db_query("SELECT bid FROM {book} WHERE nid = %d", $node->nid))) {
+ if ($node->book['bid'] != db_result(db_query("SELECT [bid] FROM [{book}] WHERE [nid] = %d", $node->nid))) {
// Update the bid for this page and all children.
book_update_bid($node->book);
}
@@ -501,10 +501,10 @@ function _book_update_outline(&$node) {
*/
function book_update_bid($book_link) {
for ($i = 1; $i <= MENU_MAX_DEPTH && $book_link["p$i"]; $i++) {
- $match[] = "p$i = %d";
+ $match[] = "[p$i] = %d";
$args[] = $book_link["p$i"];
}
- $result = db_query("SELECT mlid FROM {menu_links} WHERE " . implode(' AND ', $match), $args);
+ $result = db_query("SELECT [mlid] FROM [{menu_links}] WHERE " . implode(' AND ', $match), $args);
$mlids = array();
while ($a = db_fetch_array($result)) {
@@ -512,7 +512,7 @@ function book_update_bid($book_link) {
}
if ($mlids) {
- db_query("UPDATE {book} SET bid = %d WHERE mlid IN (" . implode(',', $mlids) . ")", $book_link['bid']);
+ db_query("UPDATE [{book}] SET [bid] = %d WHERE [mlid] IN (" . implode(',', $mlids) . ")", $book_link['bid']);
}
}
@@ -677,7 +677,7 @@ function book_nodeapi(&$node, $op, $teas
switch ($op) {
case 'load':
// Note - we cannot use book_link_load() because it will call node_load().
- $info['book'] = db_fetch_array(db_query('SELECT * FROM {book} b INNER JOIN {menu_links} ml ON b.mlid = ml.mlid WHERE b.nid = %d', $node->nid));
+ $info['book'] = db_fetch_array(db_query('SELECT * FROM [{book}] b INNER JOIN [{menu_links}] ml ON b.[mlid] = ml.[mlid] WHERE b.[nid] = %d', $node->nid));
if ($info['book']) {
$info['book']['href'] = $info['book']['link_path'];
@@ -732,7 +732,7 @@ function book_nodeapi(&$node, $op, $teas
if (!empty($node->book['bid'])) {
if ($node->nid == $node->book['bid']) {
// Handle deletion of a top-level post.
- $result = db_query("SELECT b.nid FROM {menu_links} ml INNER JOIN {book} b on b.mlid = ml.mlid WHERE ml.plid = %d", $node->book['mlid']);
+ $result = db_query("SELECT b.[nid] FROM [{menu_links}] ml INNER JOIN [{book}] b on b.[mlid] = ml.[mlid] WHERE ml.[plid] = %d", $node->book['mlid']);
while ($child = db_fetch_array($result)) {
$child_node = node_load($child['nid']);
$child_node->book['bid'] = $child_node->nid;
@@ -740,7 +740,7 @@ function book_nodeapi(&$node, $op, $teas
}
}
menu_link_delete($node->book['mlid']);
- db_query('DELETE FROM {book} WHERE mlid = %d', $node->book['mlid']);
+ db_query('DELETE FROM [{book}] WHERE [mlid] = %d', $node->book['mlid']);
}
break;
@@ -1060,7 +1060,7 @@ function book_help($path, $arg) {
* Do not call when loading a node, since this function may call node_load().
*/
function book_link_load($mlid) {
- if ($item = db_fetch_array(db_query("SELECT * FROM {menu_links} ml INNER JOIN {book} b ON b.mlid = ml.mlid LEFT JOIN {menu_router} m ON m.path = ml.router_path WHERE ml.mlid = %d", $mlid))) {
+ if ($item = db_fetch_array(db_query("SELECT * FROM [{menu_links}] ml INNER JOIN [{book}] b ON b.[mlid] = ml.[mlid] LEFT JOIN [{menu_router}] m ON m.[path] = ml.[router_path] WHERE ml.[mlid] = %d", $mlid))) {
_menu_link_translate($item);
return $item;
}
@@ -1100,20 +1100,20 @@ function book_menu_subtree_data($item) {
// If the subtree data was not in the cache, $data will be NULL.
if (!isset($data)) {
- $match = array("menu_name = '%s'");
+ $match = array("[menu_name] = %s");
$args = array($item['menu_name']);
$i = 1;
while ($i <= MENU_MAX_DEPTH && $item["p$i"]) {
- $match[] = "p$i = %d";
+ $match[] = "[p$i] = %d";
$args[] = $item["p$i"];
$i++;
}
$sql = "
- SELECT b.*, 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 m.path = ml.router_path
- INNER JOIN {book} b ON ml.mlid = b.mlid
+ SELECT b.*, 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 m.[path] = ml.[router_path]
+ INNER JOIN [{book}] b ON ml.[mlid] = b.[mlid]
WHERE " . implode(' AND ', $match) . "
- ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
+ ORDER BY [p1] ASC, [p2] ASC, [p3] ASC, [p4] ASC, [p5] ASC, [p6] ASC, [p7] ASC, [p8] ASC, [p9] ASC";
$data['tree'] = menu_tree_data(db_query($sql, $args), array(), $item['depth']);
$data['node_links'] = array();
Index: modules/book/book.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/book/book.pages.inc,v
retrieving revision 1.7
diff -u -p -r1.7 book.pages.inc
--- modules/book/book.pages.inc 15 May 2008 21:19:24 -0000 1.7
+++ modules/book/book.pages.inc 28 Sep 2008 16:44:07 -0000
@@ -210,7 +210,7 @@ function book_remove_form_submit($form,
if ($node->nid != $node->book['bid']) {
// Only allowed when this is not a book (top-level page).
menu_link_delete($node->book['mlid']);
- db_query('DELETE FROM {book} WHERE nid = %d', $node->nid);
+ db_query('DELETE FROM [{book}] WHERE [nid] = %d', $node->nid);
drupal_set_message(t('The post has been removed from the book.'));
}
$form_state['redirect'] = 'node/' . $node->nid;
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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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.652
diff -u -p -r1.652 comment.module
--- modules/comment/comment.module 27 Sep 2008 20:37:00 -0000 1.652
+++ modules/comment/comment.module 28 Sep 2008 16:44:07 -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;
}
@@ -558,7 +558,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);
@@ -569,24 +569,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':
@@ -604,8 +604,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);
}
}
@@ -664,7 +664,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['comment_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['comment_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.
@@ -676,7 +676,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.
@@ -691,7 +691,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.
@@ -717,7 +717,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['comment_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['comment_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');
@@ -895,10 +895,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;
}
@@ -915,23 +915,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');
@@ -1005,20 +1005,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'), '')
);
}
@@ -1039,7 +1039,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));
}
/**
@@ -1054,7 +1054,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];
@@ -1081,7 +1081,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;
}
@@ -1120,7 +1120,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.'));
}
@@ -1458,7 +1458,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);
@@ -1798,17 +1798,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);
}
}
@@ -1928,9 +1928,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));
}
@@ -1972,7 +1972,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;
}
@@ -1986,9 +1986,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 28 Sep 2008 16:44:07 -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.15
diff -u -p -r1.15 comment.test
--- modules/comment/comment.test 24 Sep 2008 22:38:20 -0000 1.15
+++ modules/comment/comment.test 28 Sep 2008 16:44:07 -0000
@@ -308,7 +308,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);
@@ -449,14 +449,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('
' . 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 28 Sep 2008 16:44:07 -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.169 diff -u -p -r1.169 menu.module --- modules/menu/menu.module 27 Sep 2008 20:37:00 -0000 1.169 +++ modules/menu/menu.module 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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' => '', '#suffix' => '
', '#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.978 diff -u -p -r1.978 node.module --- modules/node/node.module 27 Sep 2008 19:47:43 -0000 1.978 +++ modules/node/node.module 28 Sep 2008 16:44:07 -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(); @@ -1352,17 +1352,17 @@ function node_ranking() { 'relevance' => array( 'title' => t('Keyword relevance'), // Average relevance values hover around 0.15 - 'score' => 'i.relevance', + 'score' => 'i.[relevance]', ), 'sticky' => array( 'title' => t('Content is sticky at top of lists'), // The sticky flag is either 0 or 1, which is automatically normalized. - 'score' => 'n.sticky', + 'score' => 'n.[sticky]', ), 'promote' => array( 'title' => t('Content is promoted to the front page'), // The promote flag is either 0 or 1, which is automatically normalized. - 'score' => 'n.promote', + 'score' => 'n.[promote]', ), ); @@ -1371,7 +1371,7 @@ function node_ranking() { $ranking['recent'] = array( 'title' => t('Recently posted'), // Exponential decay with half-life of 6 months, starting at last indexed node - 'score' => '(POW(2, GREATEST(n.created, n.changed) - %d) * 6.43e-8)', + 'score' => '(POW(2, GREATEST(n.[created], n.[changed]) - %d) * 6.43e-8)', 'arguments' => array($node_cron_last), ); } @@ -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.39 diff -u -p -r1.39 node.pages.inc --- modules/node/node.pages.inc 27 Sep 2008 20:37:00 -0000 1.39 +++ modules/node/node.pages.inc 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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/openid/openid.module =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.module,v retrieving revision 1.29 diff -u -p -r1.29 openid.module --- modules/openid/openid.module 17 Sep 2008 07:11:57 -0000 1.29 +++ modules/openid/openid.module 28 Sep 2008 16:44:07 -0000 @@ -333,10 +333,10 @@ function openid_association($op_endpoint module_load_include('inc', 'openid'); // Remove Old Associations: - db_query("DELETE FROM {openid_association} WHERE created + expires_in < %d", REQUEST_TIME); + db_query("DELETE FROM [{openid_association}] WHERE [created] + [expires_in] < %d", REQUEST_TIME); // Check to see if we have an association for this IdP already - $assoc_handle = db_result(db_query("SELECT assoc_handle FROM {openid_association} WHERE idp_endpoint_uri = '%s'", $op_endpoint)); + $assoc_handle = db_result(db_query("SELECT [assoc_handle] FROM [{openid_association}] WHERE [idp_endpoint_uri] = %s", $op_endpoint)); if (empty($assoc_handle)) { $mod = OPENID_DH_DEFAULT_MOD; $gen = OPENID_DH_DEFAULT_GEN; @@ -366,7 +366,7 @@ function openid_association($op_endpoint $shared = bcpowmod($spub, $private, $mod); $assoc_response['mac_key'] = base64_encode(_openid_dh_xorsecret($shared, $enc_mac_key)); } - db_query("INSERT INTO {openid_association} (idp_endpoint_uri, session_type, assoc_handle, assoc_type, expires_in, mac_key, created) VALUES('%s', '%s', '%s', '%s', %d, '%s', %d)", + db_query("INSERT INTO [{openid_association}] ([idp_endpoint_uri], [session_type], [assoc_handle], [assoc_type], [expires_in], [mac_key], [created]) VALUES(%s, %s, %s, %s, %d, %s, %d)", $op_endpoint, $assoc_response['session_type'], $assoc_response['assoc_handle'], $assoc_response['assoc_type'], $assoc_response['expires_in'], $assoc_response['mac_key'], REQUEST_TIME); $assoc_handle = $assoc_response['assoc_handle']; @@ -494,7 +494,7 @@ function openid_verify_assertion($op_end $valid = FALSE; - $association = db_fetch_object(db_query("SELECT * FROM {openid_association} WHERE assoc_handle = '%s'", $response['openid.assoc_handle'])); + $association = db_fetch_object(db_query("SELECT * FROM [{openid_association}] WHERE [assoc_handle] = %s", $response['openid.assoc_handle'])); if ($association && isset($association->session_type)) { $keys_to_sign = explode(',', $response['openid.signed']); $self_sig = _openid_signature($association, $response, $keys_to_sign); Index: modules/openid/openid.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.pages.inc,v retrieving revision 1.6 diff -u -p -r1.6 openid.pages.inc --- modules/openid/openid.pages.inc 14 Apr 2008 17:48:38 -0000 1.6 +++ modules/openid/openid.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -35,14 +35,14 @@ function openid_user_identities($account $result = openid_complete(); if ($result['status'] == 'success') { $identity = $result['openid.claimed_id']; - db_query("INSERT INTO {authmap} (uid, authname, module) VALUES (%d, '%s','openid')", $account->uid, $identity); + db_query("INSERT INTO [{authmap}] ([uid], [authname], [module]) VALUES (%d, %s,'openid')", $account->uid, $identity); drupal_set_message(t('Successfully added %identity', array('%identity' => $identity))); } $header = array(t('OpenID'), t('Operations')); $rows = array(); - $result = db_query("SELECT * FROM {authmap} WHERE module='openid' AND uid=%d", $account->uid); + $result = db_query("SELECT * FROM [{authmap}] WHERE [module] = 'openid' AND [uid] = %d", $account->uid); while ($identity = db_fetch_object($result)) { $rows[] = array($identity->authname, l(t('Delete'), 'user/' . $account->uid . '/openid/delete/' . $identity->aid)); } @@ -70,7 +70,7 @@ function openid_user_add() { function openid_user_add_validate($form, &$form_state) { // Check for existing entries. $claimed_id = _openid_normalize($form_state['values']['openid_identifier']); - if (db_result(db_query("SELECT authname FROM {authmap} WHERE authname='%s'", $claimed_id))) { + if (db_result(db_query("SELECT [authname] FROM [{authmap}] WHERE [authname] = %s", $claimed_id))) { form_set_error('openid_identifier', t('That OpenID is already in use on this site.')); } else { @@ -83,7 +83,7 @@ function openid_user_add_validate($form, * Menu callback; Delete the specified OpenID identity from the system. */ function openid_user_delete($account, $aid = 0) { - db_query("DELETE FROM {authmap} WHERE uid=%d AND aid=%d AND module='openid'", $account->uid, $aid); + db_query("DELETE FROM [{authmap}] WHERE [uid] = %d AND [aid] = %d AND [module] = 'openid'", $account->uid, $aid); if (db_affected_rows()) { drupal_set_message(t('OpenID deleted.')); } 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 28 Sep 2008 16:44:07 -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.146 diff -u -p -r1.146 path.module --- modules/path/path.module 27 Sep 2008 20:37:00 -0000 1.146 +++ modules/path/path.module 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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/php/php.install =================================================================== RCS file: /cvs/drupal/drupal/modules/php/php.install,v retrieving revision 1.2 diff -u -p -r1.2 php.install --- modules/php/php.install 14 Apr 2008 17:48:41 -0000 1.2 +++ modules/php/php.install 28 Sep 2008 16:44:07 -0000 @@ -5,17 +5,17 @@ * Implementation of hook_install(). */ function php_install() { - $format_exists = db_result(db_query("SELECT COUNT(*) FROM {filter_formats} WHERE name = 'PHP code'")); + $format_exists = db_result(db_query("SELECT COUNT(*) FROM [{filter_formats}] WHERE [name] = %s", 'PHP code')); // Add a PHP code input format, if it does not exist. Do this only for the // first install (or if the format has been manually deleted) as there is no // reliable method to identify the format in an uninstall hook or in // subsequent clean installs. if (!$format_exists) { - db_query("INSERT INTO {filter_formats} (name, roles, cache) VALUES ('PHP code', '', 0)"); - $format = db_result(db_query("SELECT MAX(format) FROM {filter_formats}")); + db_query("INSERT INTO [{filter_formats}] ([name], [roles], [cache]) VALUES (%s, %s, %d)", 'PHP code', '', 0); + $format = db_result(db_query("SELECT MAX([format]) FROM [{filter_formats}]")); // Enable the PHP evaluator filter. - db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, 'php', 0, 0)", $format); + db_query("INSERT INTO [{filters}] ([format], [module], [delta], [weight]) VALUES (%d, %s, %d, %d)", $format, 'php', 0, 0); drupal_set_message(t('A !php-code input format has been created.', array('!php-code' => l('PHP code', 'admin/settings/filters/' . $format)))); } Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.272 diff -u -p -r1.272 poll.module --- modules/poll/poll.module 17 Sep 2008 07:11:57 -0000 1.272 +++ modules/poll/poll.module 28 Sep 2008 16:44:07 -0000 @@ -139,7 +139,7 @@ function poll_block($op = 'list', $delta } else if ($op == 'view') { // Retrieve the latest poll. - $sql = db_rewrite_sql("SELECT MAX(n.created) FROM {node} n INNER JOIN {poll} p ON p.nid = n.nid WHERE n.status = 1 AND p.active = 1"); + $sql = db_rewrite_sql("SELECT MAX(n.[created]) FROM [{node}] n INNER JOIN [{poll}] p ON p.[nid] = n.[nid] WHERE n.[status] = 1 AND p.[active] = 1"); $timestamp = db_result(db_query($sql)); if ($timestamp) { $poll = node_load(array('type' => 'poll', 'created' => $timestamp, 'status' => 1)); @@ -161,9 +161,9 @@ function poll_block($op = 'list', $delta * Closes polls that have exceeded their allowed runtime. */ function poll_cron() { - $result = db_query('SELECT p.nid FROM {poll} p INNER JOIN {node} n ON p.nid = n.nid WHERE (n.created + p.runtime) < ' . REQUEST_TIME . ' AND p.active = 1 AND p.runtime != 0'); + $result = db_query('SELECT p.[nid] FROM [{poll}] p INNER JOIN [{node}] n ON p.[nid] = n.[nid] WHERE (n.[created] + p.[runtime]) < ' . REQUEST_TIME . ' AND p.[active] = 1 AND p.[runtime] <> 0'); while ($poll = db_fetch_object($result)) { - db_query("UPDATE {poll} SET active = 0 WHERE nid = %d", $poll->nid); + db_query("UPDATE [{poll}] SET [active] = 0 WHERE [nid] = %d", $poll->nid); } } @@ -443,10 +443,10 @@ function poll_validate($node) { function poll_load($node) { global $user; - $poll = db_fetch_object(db_query("SELECT runtime, active FROM {poll} WHERE nid = %d", $node->nid)); + $poll = db_fetch_object(db_query("SELECT [runtime], [active] FROM [{poll}] WHERE [nid] = %d", $node->nid)); // Load the appropriate choices into the $poll object. - $result = db_query("SELECT chid, chtext, chvotes, weight FROM {poll_choices} WHERE nid = %d ORDER BY weight", $node->nid); + $result = db_query("SELECT [chid], [chtext], [chvotes], [weight] FROM [{poll_choices}] WHERE [nid] = %d ORDER BY [weight]", $node->nid); while ($choice = db_fetch_array($result)) { $poll->choice[$choice['chid']] = $choice; } @@ -455,10 +455,10 @@ function poll_load($node) { $poll->allowvotes = FALSE; if (user_access('vote on polls') && $poll->active) { if ($user->uid) { - $result = db_fetch_object(db_query('SELECT chid FROM {poll_votes} WHERE nid = %d AND uid = %d', $node->nid, $user->uid)); + $result = db_fetch_object(db_query('SELECT [chid] FROM [{poll_votes}] WHERE [nid] = %d AND [uid] = %d', $node->nid, $user->uid)); } else { - $result = db_fetch_object(db_query("SELECT chid FROM {poll_votes} WHERE nid = %d AND hostname = '%s'", $node->nid, ip_address())); + $result = db_fetch_object(db_query("SELECT [chid] FROM [{poll_votes}] WHERE [nid] = %d AND [hostname] = %s", $node->nid, ip_address())); } if (isset($result->chid)) { $poll->vote = $result->chid; @@ -483,11 +483,11 @@ function poll_insert($node) { $node->active = 1; } - db_query("INSERT INTO {poll} (nid, runtime, active) VALUES (%d, %d, %d)", $node->nid, $node->runtime, $node->active); + db_query("INSERT INTO [{poll}] ([nid], [runtime], [active]) VALUES (%d, %d, %d)", $node->nid, $node->runtime, $node->active); foreach ($node->choice as $choice) { if ($choice['chtext'] != '') { - db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, weight) VALUES (%d, '%s', %d, %d)", $node->nid, $choice['chtext'], $choice['chvotes'], $choice['weight']); + db_query("INSERT INTO [{poll_choices}] ([nid], [chtext], [chvotes], [weight]) VALUES (%d, %s, %d, %d)", $node->nid, $choice['chtext'], $choice['chvotes'], $choice['weight']); } } } @@ -497,21 +497,21 @@ function poll_insert($node) { */ function poll_update($node) { // Update poll settings. - db_query('UPDATE {poll} SET runtime = %d, active = %d WHERE nid = %d', $node->runtime, $node->active, $node->nid); + db_query('UPDATE [{poll}] SET [runtime] = %d, [active] = %d WHERE [nid] = %d', $node->runtime, $node->active, $node->nid); // Poll choices with empty titles signifies removal. We remove all votes to // the removed options, so people who voted on them can vote again. foreach ($node->choice as $key => $choice) { if (!empty($choice['chtext'])) { if (isset($choice['chid'])) { - db_query("UPDATE {poll_choices} SET chtext = '%s', chvotes = %d, weight = %d WHERE chid = %d", $choice['chtext'], (int)$choice['chvotes'], $choice['weight'], $choice['chid']); + db_query("UPDATE [{poll_choices}] SET [chtext] = %s, [chvotes] = %d, [weight] = %d WHERE [chid] = %d", $choice['chtext'], (int)$choice['chvotes'], $choice['weight'], $choice['chid']); } else { - db_query("INSERT INTO {poll_choices} (nid, chtext, chvotes, weight) VALUES (%d, '%s', %d, %d)", $node->nid, $choice['chtext'], (int)$choice['chvotes'], $choice['weight']); + db_query("INSERT INTO [{poll_choices}] ([nid], [chtext], [chvotes], [weight]) VALUES (%d, %s, %d, %d)", $node->nid, $choice['chtext'], (int)$choice['chvotes'], $choice['weight']); } } else { - db_query("DELETE FROM {poll_votes} WHERE nid = %d AND chid = %d", $node->nid, $key); + db_query("DELETE FROM [{poll_votes}] WHERE [nid] = %d AND [chid] = %d", $node->nid, $key); } } } @@ -520,9 +520,9 @@ function poll_update($node) { * Implementation of hook_delete(). */ function poll_delete($node) { - db_query("DELETE FROM {poll} WHERE nid = %d", $node->nid); - db_query("DELETE FROM {poll_choices} WHERE nid = %d", $node->nid); - db_query("DELETE FROM {poll_votes} WHERE nid = %d", $node->nid); + db_query("DELETE FROM [{poll}] WHERE [nid] = %d", $node->nid); + db_query("DELETE FROM [{poll_choices}] WHERE [nid] = %d", $node->nid); + db_query("DELETE FROM [{poll_votes}] WHERE [nid] = %d", $node->nid); } /** @@ -637,14 +637,14 @@ function poll_vote($form, &$form_state) global $user; if ($user->uid) { - db_query('INSERT INTO {poll_votes} (nid, chid, uid) VALUES (%d, %d, %d)', $node->nid, $choice, $user->uid); + db_query('INSERT INTO [{poll_votes}] ([nid], [chid], [uid]) VALUES (%d, %d, %d)', $node->nid, $choice, $user->uid); } else { - db_query("INSERT INTO {poll_votes} (nid, chid, hostname) VALUES (%d, %d, '%s')", $node->nid, $choice, ip_address()); + db_query("INSERT INTO [{poll_votes}] ([nid], [chid], [hostname]) VALUES (%d, %d, %s)", $node->nid, $choice, ip_address()); } // Add one to the votes. - db_query("UPDATE {poll_choices} SET chvotes = chvotes + 1 WHERE chid = %d", $choice); + db_query("UPDATE [{poll_choices}] SET [chvotes] = [chvotes] + 1 WHERE [chid] = %d", $choice); cache_clear_all(); drupal_set_message(t('Your vote was recorded.')); @@ -812,14 +812,14 @@ function poll_cancel($form, &$form_state global $user; if ($user->uid) { - db_query('DELETE FROM {poll_votes} WHERE nid = %d and uid = %d', $node->nid, $user->uid); + db_query('DELETE FROM [{poll_votes}] WHERE [nid] = %d and [uid] = %d', $node->nid, $user->uid); } else { - db_query("DELETE FROM {poll_votes} WHERE nid = %d and hostname = '%s'", $node->nid, ip_address()); + db_query("DELETE FROM [{poll_votes}] WHERE [nid] = %d and [hostname] = %s", $node->nid, ip_address()); } // Subtract from the votes. - db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE chid = %d", $node->vote); + db_query("UPDATE [{poll_choices}] SET [chvotes] = [chvotes] - 1 WHERE [chid] = %d", $node->vote); } /** @@ -827,6 +827,6 @@ function poll_cancel($form, &$form_state */ function poll_user($op, &$edit, &$user) { if ($op == 'delete') { - db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE [{poll_votes}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); } } Index: modules/poll/poll.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.pages.inc,v retrieving revision 1.6 diff -u -p -r1.6 poll.pages.inc --- modules/poll/poll.pages.inc 15 May 2008 20:55:58 -0000 1.6 +++ modules/poll/poll.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -11,9 +11,9 @@ */ function poll_page() { // List all polls. - $sql = db_rewrite_sql("SELECT n.nid, n.title, p.active, n.created, SUM(c.chvotes) AS votes FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid INNER JOIN {poll_choices} c ON n.nid = c.nid WHERE n.status = 1 GROUP BY n.nid, n.title, p.active, n.created ORDER BY n.created DESC"); + $sql = db_rewrite_sql("SELECT n.[nid], n.[title], p.[active], n.[created], SUM(c.[chvotes]) AS [votes] FROM [{node}] n INNER JOIN [{poll}] p ON n.[nid] = p.[nid] INNER JOIN [{poll_choices}] c ON n.[nid] = c.[nid] WHERE n.[status] = 1 GROUP BY n.[nid], n.[title], p.[active], n.[created] ORDER BY n.[created] DESC"); // Count all polls for the pager. - $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM {node} n INNER JOIN {poll} p ON n.nid = p.nid WHERE n.status = 1'); + $count_sql = db_rewrite_sql('SELECT COUNT(*) FROM [{node}] n INNER JOIN [{poll}] p ON n.[nid] = p.[nid] WHERE n.[status] = 1'); $result = pager_query($sql, 15, 0, $count_sql); $output = ''; while ($node = db_fetch_object($result)) { @@ -35,7 +35,7 @@ function poll_votes($node) { $header[] = array('data' => t('Vote'), 'field' => 'pv.chorder'); $header[] = array('data' => t('Vote'), 'field' => 'pc.weight'); - $result = pager_query("SELECT pv.chid, pv.uid, pv.hostname, u.name FROM {poll_votes} pv INNER JOIN {poll_choices} pc ON pv.chid = pc.chid LEFT JOIN {users} u ON pv.uid = u.uid WHERE pv.nid = %d". tablesort_sql($header), 20, 0, NULL, $node->nid); + $result = pager_query("SELECT pv.[chid], pv.[uid], pv.[hostname], u.[name] FROM [{poll_votes}] pv INNER JOIN [{poll_choices}] pc ON pv.[chid] = pc.[chid] LEFT JOIN [{users}] u ON pv.[uid] = u.[uid] WHERE pv.[nid] = %d". tablesort_sql($header), 20, 0, NULL, $node->nid); $rows = array(); while ($vote = db_fetch_object($result)) { $rows[] = array( Index: modules/profile/profile.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.admin.inc,v retrieving revision 1.12 diff -u -p -r1.12 profile.admin.inc --- modules/profile/profile.admin.inc 21 Aug 2008 19:36:38 -0000 1.12 +++ modules/profile/profile.admin.inc 28 Sep 2008 16:44:07 -0000 @@ -13,7 +13,7 @@ * @see profile_admin_overview_submit() */ function profile_admin_overview() { - $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_fields} ORDER BY category, weight'); + $result = db_query('SELECT [title], [name], [type], [category], [fid], [weight] FROM [{profile_fields}] ORDER BY [category], [weight]'); $form = array(); $categories = array(); @@ -74,7 +74,7 @@ function profile_admin_overview_submit($ $weight = $form_state['values'][$fid]['weight']; $category = $form_state['values'][$fid]['category']; if ($weight != $form[$fid]['weight']['#default_value'] || $category != $form[$fid]['category']['#default_value']) { - db_query("UPDATE {profile_fields} SET weight = %d, category = '%s' WHERE fid = %d", $weight, $category, $fid); + db_query("UPDATE [{profile_fields}] SET [weight] = %d, [category] = %s WHERE [fid] = %d", $weight, $category, $fid); } } } @@ -169,7 +169,7 @@ function profile_field_form(&$form_state if (is_numeric($arg)) { $fid = $arg; - $edit = db_fetch_array(db_query('SELECT * FROM {profile_fields} WHERE fid = %d', $fid)); + $edit = db_fetch_array(db_query('SELECT * FROM [{profile_fields}] WHERE [fid] = %d', $fid)); if (!$edit) { drupal_not_found(); @@ -310,13 +310,13 @@ function profile_field_form_validate($fo if (isset($form_state['values']['fid'])) { $args1[] = $args2[] = $form_state['values']['fid']; - $query_suffix = ' AND fid != %d'; + $query_suffix = ' AND [fid] <> %d'; } - if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE title = '%s' AND category = '%s'" . $query_suffix, $args1))) { + if (db_result(db_query("SELECT [fid] FROM [{profile_fields}] WHERE [title] = %s AND [category] = %s" . $query_suffix, $args1))) { form_set_error('title', t('The specified title is already in use.')); } - if (db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'" . $query_suffix, $args2))) { + if (db_result(db_query("SELECT [fid] FROM [{profile_fields}] WHERE [name] = %s" . $query_suffix, $args2))) { form_set_error('name', t('The specified name is already in use.')); } if ($form_state['values']['visibility'] == PROFILE_HIDDEN) { @@ -340,13 +340,13 @@ function profile_field_form_submit($form $form_state['values']['page'] = ''; } if (!isset($form_state['values']['fid'])) { - db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s', '%s')", $form_state['values']['title'], $form_state['values']['name'], $form_state['values']['explanation'], $form_state['values']['category'], $form_state['values']['type'], $form_state['values']['weight'], $form_state['values']['required'], $form_state['values']['register'], $form_state['values']['visibility'], $form_state['values']['autocomplete'], $form_state['values']['options'], $form_state['values']['page']); + db_query("INSERT INTO [{profile_fields}] ([title], [name], [explanation], [category], [type], [weight], [required], [register], [visibility], [autocomplete], [options], [page]) VALUES (%s, %s, %s, %s, %s, %d, %d, %d, %d, %d, %s, %s)", $form_state['values']['title'], $form_state['values']['name'], $form_state['values']['explanation'], $form_state['values']['category'], $form_state['values']['type'], $form_state['values']['weight'], $form_state['values']['required'], $form_state['values']['register'], $form_state['values']['visibility'], $form_state['values']['autocomplete'], $form_state['values']['options'], $form_state['values']['page']); drupal_set_message(t('The field has been created.')); watchdog('profile', 'Profile field %field added under category %category.', array('%field' => $form_state['values']['title'], '%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/user/profile')); } else { - db_query("UPDATE {profile_fields} SET title = '%s', name = '%s', explanation = '%s', category = '%s', weight = %d, required = %d, register = %d, visibility = %d, autocomplete = %d, options = '%s', page = '%s' WHERE fid = %d", $form_state['values']['title'], $form_state['values']['name'], $form_state['values']['explanation'], $form_state['values']['category'], $form_state['values']['weight'], $form_state['values']['required'], $form_state['values']['register'], $form_state['values']['visibility'], $form_state['values']['autocomplete'], $form_state['values']['options'], $form_state['values']['page'], $form_state['values']['fid']); + db_query("UPDATE [{profile_fields}] SET [title] = %s, [name] = %s, [explanation] = %s, [category] = %s, [weight] = %d, [required] = %d, [register] = %d, [visibility] = %d, [autocomplete] = %d, [options] = %s, [page] = %s WHERE [fid] = %d", $form_state['values']['title'], $form_state['values']['name'], $form_state['values']['explanation'], $form_state['values']['category'], $form_state['values']['weight'], $form_state['values']['required'], $form_state['values']['register'], $form_state['values']['visibility'], $form_state['values']['autocomplete'], $form_state['values']['options'], $form_state['values']['page'], $form_state['values']['fid']); drupal_set_message(t('The field has been updated.')); } @@ -361,7 +361,7 @@ function profile_field_form_submit($form * Menu callback; deletes a field from all user profiles. */ function profile_field_delete(&$form_state, $fid) { - $field = db_fetch_object(db_query("SELECT title FROM {profile_fields} WHERE fid = %d", $fid)); + $field = db_fetch_object(db_query("SELECT [title] FROM [{profile_fields}] WHERE [fid] = %d", $fid)); if (!$field) { drupal_not_found(); return; @@ -379,8 +379,8 @@ function profile_field_delete(&$form_sta * Process a field delete form submission. */ function profile_field_delete_submit($form, &$form_state) { - db_query('DELETE FROM {profile_fields} WHERE fid = %d', $form_state['values']['fid']); - db_query('DELETE FROM {profile_values} WHERE fid = %d', $form_state['values']['fid']); + db_query('DELETE FROM [{profile_fields}] WHERE [fid] = %d', $form_state['values']['fid']); + db_query('DELETE FROM [{profile_values}] WHERE [fid] = %d', $form_state['values']['fid']); cache_clear_all(); @@ -396,7 +396,7 @@ function profile_field_delete_submit($fo */ function profile_admin_settings_autocomplete($string) { $matches = array(); - $result = db_query_range("SELECT category FROM {profile_fields} WHERE LOWER(category) LIKE LOWER(:category)", array(':category' => $string .'%'), 0, 10); + $result = db_query_range("SELECT [category] FROM [{profile_fields}] WHERE LOWER([category]) LIKE LOWER(:category)", array(':category' => $string . '%'), 0, 10); while ($data = db_fetch_object($result)) { $matches[$data->category] = check_plain($data->category); } Index: modules/profile/profile.module =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v retrieving revision 1.244 diff -u -p -r1.244 profile.module --- modules/profile/profile.module 5 Sep 2008 09:25:52 -0000 1.244 +++ modules/profile/profile.module 28 Sep 2008 16:44:07 -0000 @@ -138,7 +138,7 @@ function profile_block($op = 'list', $de else if ($op == 'configure') { // Compile a list of fields to show $fields = array(); - $result = db_query('SELECT name, title, weight, visibility FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS); + $result = db_query('SELECT [name], [title], [weight], [visibility] FROM [{profile_fields}] WHERE [visibility] IN (%d, %d) ORDER BY [weight]', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS); while ($record = db_fetch_object($result)) { $fields[$record->name] = check_plain($record->title); } @@ -165,7 +165,7 @@ function profile_block($op = 'list', $de if ($use_fields = variable_get('profile_block_author_fields', array())) { // Compile a list of fields to show. $fields = array(); - $result = db_query('SELECT name, title, type, visibility, weight FROM {profile_fields} WHERE visibility IN (%d, %d) ORDER BY weight', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS); + $result = db_query('SELECT [name], [title], [type], [visibility], [weight] FROM [{profile_fields}] WHERE [visibility] IN (%d, %d) ORDER BY [weight]', PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS); while ($record = db_fetch_object($result)) { // Ensure that field is displayed only if it is among the defined block fields and, if it is private, the user has appropriate permissions. if (isset($use_fields[$record->name]) && $use_fields[$record->name]) { @@ -215,12 +215,12 @@ function profile_user($type, &$edit, &$u case 'categories': return profile_categories(); case 'delete': - db_query('DELETE FROM {profile_values} WHERE uid = %d', $user->uid); + db_query('DELETE FROM [{profile_values}] WHERE [uid] = %d', $user->uid); } } function profile_load_profile(&$user) { - $result = db_query('SELECT f.name, f.type, v.value FROM {profile_fields} f INNER JOIN {profile_values} v ON f.fid = v.fid WHERE uid = %d', $user->uid); + $result = db_query('SELECT f.[name], f.[type], v.[value] FROM [{profile_fields}] f INNER JOIN [{profile_values}] v ON f.[fid] = v.[fid] WHERE [uid] = %d', $user->uid); while ($field = db_fetch_object($result)) { if (empty($user->{$field->name})) { $user->{$field->name} = _profile_field_serialize($field->type) ? unserialize($field->value) : $field->value; @@ -234,8 +234,8 @@ function profile_save_profile(&$edit, &$ if (_profile_field_serialize($field->type)) { $edit[$field->name] = serialize($edit[$field->name]); } - db_query("DELETE FROM {profile_values} WHERE fid = %d AND uid = %d", $field->fid, $user->uid); - db_query("INSERT INTO {profile_values} (fid, uid, value) VALUES (%d, %d, '%s')", $field->fid, $user->uid, $edit[$field->name]); + db_query("DELETE FROM [{profile_values}] WHERE [fid] = %d AND [uid] = %d", $field->fid, $user->uid); + db_query("INSERT INTO [{profile_values}] ([fid], [uid], [value]) VALUES (%d, %d, %s)", $field->fid, $user->uid, $edit[$field->name]); // Mark field as handled (prevents saving to user->data). $edit[$field->name] = NULL; } @@ -294,10 +294,10 @@ function profile_view_profile(&$user) { // Show private fields to administrators and people viewing their own account. if (user_access('administer users') || $GLOBALS['user']->uid == $user->uid) { - $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d ORDER BY category, weight', PROFILE_HIDDEN); + $result = db_query('SELECT * FROM [{profile_fields}] WHERE [visibility] <> %d ORDER BY [category], [weight]', PROFILE_HIDDEN); } else { - $result = db_query('SELECT * FROM {profile_fields} WHERE visibility != %d AND visibility != %d ORDER BY category, weight', PROFILE_PRIVATE, PROFILE_HIDDEN); + $result = db_query('SELECT * FROM [{profile_fields}] WHERE [visibility] <> %d AND [visibility] <> %d ORDER BY [category], [weight]', PROFILE_PRIVATE, PROFILE_HIDDEN); } $fields = array(); @@ -443,7 +443,7 @@ function profile_validate_profile($edit, } function profile_categories() { - $result = db_query("SELECT DISTINCT(category) FROM {profile_fields}"); + $result = db_query("SELECT DISTINCT([category]) FROM [{profile_fields}]"); $data = array(); while ($category = db_fetch_object($result)) { $data[] = array( @@ -465,7 +465,7 @@ function profile_category_access($accoun return TRUE; } else { - return user_edit_access($account) && db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE category = '%s' AND visibility <> %d", $category, PROFILE_HIDDEN)); + return user_edit_access($account) && db_result(db_query("SELECT COUNT(*) FROM [{profile_fields}] WHERE [category] = %s AND [visibility] <> %d", $category, PROFILE_HIDDEN)); } } @@ -552,22 +552,22 @@ function _profile_field_serialize($type function _profile_get_fields($category, $register = FALSE) { $args = array(); - $sql = 'SELECT * FROM {profile_fields} WHERE '; + $sql = 'SELECT * FROM [{profile_fields}] WHERE '; $filters = array(); if ($register) { - $filters[] = 'register = 1'; + $filters[] = '[register] = 1'; } else { // Use LOWER('%s') instead of PHP's strtolower() to avoid UTF-8 conversion issues. - $filters[] = "LOWER(category) = LOWER('%s')"; + $filters[] = "LOWER([category]) = LOWER(%s)"; $args[] = $category; } if (!user_access('administer users')) { - $filters[] = 'visibility != %d'; + $filters[] = '[visibility] != %d'; $args[] = PROFILE_HIDDEN; } $sql .= implode(' AND ', $filters); - $sql .= ' ORDER BY category, weight'; + $sql .= ' ORDER BY [category], [weight]'; return db_query($sql, $args); } Index: modules/profile/profile.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.pages.inc,v retrieving revision 1.4 diff -u -p -r1.4 profile.pages.inc --- modules/profile/profile.pages.inc 15 Sep 2008 20:48:09 -0000 1.4 +++ modules/profile/profile.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -13,7 +13,7 @@ function profile_browse() { // Ensure that the path is converted to 3 levels always. list(, $name, $value) = array_pad(explode('/', $_GET['q'], 3), 3, ''); - $field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name)); + $field = db_fetch_object(db_query("SELECT DISTINCT([fid]), [type], [title], [page], [visibility] FROM [{profile_fields}] WHERE [name] = %s", $name)); if ($name && $field->fid) { // Only allow browsing of fields that have a page title set. @@ -29,7 +29,7 @@ function profile_browse() { // Compile a list of fields to show. $fields = array(); - $result = db_query('SELECT name, title, type, weight, page FROM {profile_fields} WHERE fid != %d AND visibility = %d ORDER BY weight', $field->fid, PROFILE_PUBLIC_LISTINGS); + $result = db_query('SELECT [name], [title], [type], [weight], [page] FROM [{profile_fields}] WHERE [fid] <> %d AND [visibility] = %d ORDER BY [weight]', $field->fid, PROFILE_PUBLIC_LISTINGS); while ($record = db_fetch_object($result)) { $fields[] = $record; } @@ -38,16 +38,16 @@ function profile_browse() { $arguments = array($field->fid); switch ($field->type) { case 'checkbox': - $query = 'v.value = 1'; + $query = 'v.[value] = 1'; break; case 'textfield': case 'selection': - $query = "v.value = '%s'"; + $query = "v.[value] = %s"; $arguments[] = $value; break; case 'list': - $query = "v.value LIKE '%%%s%%'"; - $arguments[] = $value; + $query = "v.[value] LIKE %s"; + $arguments[] = '%' . $value . '%'; break; default: drupal_not_found(); @@ -55,7 +55,7 @@ function profile_browse() { } // Extract the affected users: - $result = pager_query("SELECT u.uid, u.access FROM {users} u INNER JOIN {profile_values} v ON u.uid = v.uid WHERE v.fid = %d AND $query AND u.access != 0 AND u.status != 0 ORDER BY u.access DESC", 20, 0, NULL, $arguments); + $result = pager_query("SELECT u.[uid], u.[access] FROM [{users}] u INNER JOIN [{profile_values}] v ON u.[uid] = v.[uid] WHERE v.[fid] = %d AND $query AND u.[access] <> 0 AND u.[status] <> 0 ORDER BY u.[access] DESC", 20, 0, NULL, $arguments); $content = ''; while ($account = db_fetch_object($result)) { @@ -82,13 +82,13 @@ function profile_browse() { else { // Compile a list of fields to show. $fields = array(); - $result = db_query('SELECT name, title, type, weight, page FROM {profile_fields} WHERE visibility = %d ORDER BY category, weight', PROFILE_PUBLIC_LISTINGS); + $result = db_query('SELECT [name], [title], [type], [weight], [page] FROM [{profile_fields}] WHERE [visibility] = %d ORDER BY [category], [weight]', PROFILE_PUBLIC_LISTINGS); while ($record = db_fetch_object($result)) { $fields[] = $record; } // Extract the affected users: - $result = pager_query('SELECT uid, access FROM {users} WHERE uid > 0 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL); + $result = pager_query('SELECT [uid], [access] FROM [{users}] WHERE [uid] > 0 AND [status] <> 0 AND [access] <> 0 ORDER BY [access] DESC', 20, 0, NULL); $content = ''; while ($account = db_fetch_object($result)) { @@ -109,10 +109,10 @@ function profile_browse() { */ function profile_autocomplete($field, $string) { $matches = array(); - if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) { - $result = db_query_range("SELECT value FROM {profile_values} WHERE fid = :fid AND LOWER(value) LIKE LOWER(:value) GROUP BY value ORDER BY value ASC", array( + if (db_result(db_query("SELECT COUNT(*) FROM [{profile_fields}] WHERE [fid] = %d AND [autocomplete] = 1", $field))) { + $result = db_query_range("SELECT [value] FROM [{profile_values}] WHERE [fid] = :fid AND LOWER([value]) LIKE LOWER(:value) GROUP BY [value] ORDER BY [value] ASC", array( ':fid' => $field, - ':value' => $string .'%', + ':value' => $string . '%', ), 0, 10); while ($data = db_fetch_object($result)) { $matches[$data->value] = check_plain($data->value); Index: modules/profile/profile.test =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.test,v retrieving revision 1.6 diff -u -p -r1.6 profile.test --- modules/profile/profile.test 5 Jun 2008 21:55:44 -0000 1.6 +++ modules/profile/profile.test 28 Sep 2008 16:44:07 -0000 @@ -37,7 +37,7 @@ class ProfileTestCase extends DrupalWebT $edit['explanation'] = $this->randomName(50); $this->drupalPost('admin/user/profile/add/' . $type, $edit, t('Save field')); - $fid = db_result(db_query("SELECT fid FROM {profile_fields} WHERE title = '%s'", $title)); + $fid = db_result(db_query("SELECT [fid] FROM [{profile_fields}] WHERE [title] = %s", $title)); $this->assertTrue($fid, t('New Profile field has been entered in the database')); // Check that the new field is appearing on the user edit form. 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 28 Sep 2008 16:44:07 -0000 @@ -232,11 +232,11 @@ function search_wipe($sid = NULL, $type module_invoke_all('search', 'reset'); } else { - db_query("DELETE FROM {search_dataset} WHERE sid = %d AND type = '%s'", $sid, $type); - db_query("DELETE FROM {search_index} WHERE sid = %d AND type = '%s'", $sid, $type); + db_query("DELETE FROM [{search_dataset}] WHERE [sid] = %d AND [type] = %s", $sid, $type); + db_query("DELETE FROM [{search_index}] WHERE [sid] = %d AND [type] = %s", $sid, $type); // Don't remove links if re-indexing. if (!$reindex) { - db_query("DELETE FROM {search_node_links} WHERE sid = %d AND type = '%s'", $sid, $type); + db_query("DELETE FROM [{search_node_links}] WHERE [sid] = %d AND [type] = %s", $sid, $type); } } } @@ -281,7 +281,7 @@ function search_update_totals() { // Update word IDF (Inverse Document Frequency) counts for new/changed words foreach (search_dirty() as $word => $dummy) { // Get total count - $total = db_result(db_query("SELECT SUM(score) FROM {search_index} WHERE word = '%s'", $word)); + $total = db_result(db_query("SELECT SUM([score]) FROM [{search_index}] WHERE [word] = %s", $word)); // Apply Zipf's law to equalize the probability distribution $total = log10(1 + 1/(max(1, $total))); db_merge('search_total')->key(array('word' => $word))->fields(array('count' => $total))->execute(); @@ -289,9 +289,9 @@ function search_update_totals() { // Find words that were deleted from search_index, but are still in // search_total. We use a LEFT JOIN between the two tables and keep only the // rows which fail to join. - $result = db_query("SELECT t.word AS realword, i.word FROM {search_total} t LEFT JOIN {search_index} i ON t.word = i.word WHERE i.word IS NULL"); + $result = db_query("SELECT t.[word] AS [realword], i.[word] FROM [{search_total}] t LEFT JOIN [{search_index}] i ON t.[word] = i.[word] WHERE i.[word] IS NULL"); while ($word = db_fetch_object($result)) { - db_query("DELETE FROM {search_total} WHERE word = '%s'", $word->realword); + db_query("DELETE FROM [{search_total}] WHERE [word] = %s", $word->realword); } } @@ -498,7 +498,7 @@ function search_index($sid, $type, $text $linknid = $match[1]; if ($linknid > 0) { // Note: ignore links to uncachable nodes to avoid redirect bugs. - $node = db_fetch_object(db_query('SELECT n.title, n.nid, n.vid, r.format FROM {node} n INNER JOIN {node_revisions} r ON n.vid = r.vid WHERE n.nid = %d', $linknid)); + $node = db_fetch_object(db_query('SELECT n.[title], n.[nid], n.[vid], r.[format] FROM [{node}] n INNER JOIN [{node_revisions}] r ON n.[vid] = r.[vid] WHERE n.[nid] = %d', $linknid)); if (filter_format_allowcache($node->format)) { $link = TRUE; $linktitle = $node->title; @@ -566,25 +566,25 @@ function search_index($sid, $type, $text search_wipe($sid, $type, TRUE); // Insert cleaned up data into dataset - db_query("INSERT INTO {search_dataset} (sid, type, data, reindex) VALUES (%d, '%s', '%s', %d)", $sid, $type, $accum, 0); + db_query("INSERT INTO [{search_dataset}] ([sid], [type], [data], [reindex]) VALUES (%d, %s, %s, %d)", $sid, $type, $accum, 0); // 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, 'sid' => $sid, 'type' => $type, - ))->fields(array('score' => $score))->expression('score', 'score + :score', array(':score' => $score)) + ))->fields(array('score' => $score))->expression('score', '[score] + :score', array(':score' => $score)) ->execute(); search_dirty($word); } unset($results[0]); // Get all previous links from this item. - $result = db_query("SELECT nid, caption FROM {search_node_links} WHERE sid = %d AND type = '%s'", $sid, $type); + $result = db_query("SELECT [nid], [caption] FROM [{search_node_links}] WHERE [sid] = %d AND [type] = %s", $sid, $type); $links = array(); while ($link = db_fetch_object($result)) { $links[$link->nid] = $link->caption; @@ -596,7 +596,7 @@ function search_index($sid, $type, $text if (isset($links[$nid])) { if ($links[$nid] != $caption) { // Update the existing link and mark the node for reindexing. - db_query("UPDATE {search_node_links} SET caption = '%s' WHERE sid = %d AND type = '%s' AND nid = %d", $caption, $sid, $type, $nid); + db_query("UPDATE [{search_node_links}] SET [caption] = %s WHERE [sid] = %d AND [type] = %s AND [nid] = %d", $caption, $sid, $type, $nid); search_touch_node($nid); } // Unset the link to mark it as processed. @@ -604,13 +604,13 @@ function search_index($sid, $type, $text } else { // Insert the existing link and mark the node for reindexing. - db_query("INSERT INTO {search_node_links} (caption, sid, type, nid) VALUES ('%s', %d, '%s', %d)", $caption, $sid, $type, $nid); + db_query("INSERT INTO [{search_node_links}] ([caption], [sid], [type], [nid]) VALUES (%s, %d, %s, %d)", $caption, $sid, $type, $nid); search_touch_node($nid); } } // Any left-over links in $links no longer exist. Delete them and mark the nodes for reindexing. foreach ($links as $nid => $caption) { - db_query("DELETE FROM {search_node_links} WHERE sid = %d AND type = '%s' AND nid = %d", $sid, $type, $nid); + db_query("DELETE FROM [{search_node_links}] WHERE [sid] = %d AND [type] = %s AND [nid] = %d", $sid, $type, $nid); search_touch_node($nid); } } @@ -622,7 +622,7 @@ function search_index($sid, $type, $text * The nid of the node that needs reindexing. */ function search_touch_node($nid) { - db_query("UPDATE {search_dataset} SET reindex = %d WHERE sid = %d AND type = 'node'", REQUEST_TIME, $nid); + db_query("UPDATE [{search_dataset}] SET [reindex] = %d WHERE [sid] = %d AND [type] = 'node'", REQUEST_TIME, $nid); } /** @@ -632,7 +632,7 @@ function search_nodeapi(&$node, $op, $te switch ($op) { // Transplant links to a node into the target node. case 'update index': - $result = db_query("SELECT caption FROM {search_node_links} WHERE nid = %d", $node->nid); + $result = db_query("SELECT [caption] FROM [{search_node_links}] WHERE [nid] = %d", $node->nid); $output = array(); while ($link = db_fetch_object($result)) { $output[] = $link->caption; @@ -828,7 +828,7 @@ function search_parse_query($text) { $query = implode(' AND ', $query); // Build word-index conditions for the first pass - $query2 = substr(str_repeat("i.word = '%s' OR ", count($arguments2)), 0, -4); + $query2 = substr(str_repeat("i.[word] = %s OR ", count($arguments2)), 0, -4); return array($query, $arguments, $query2, $arguments2, $matches, $simple, $warning); } @@ -855,7 +855,7 @@ function _search_parse_query(&$word, &$s } } // Return matching snippet and number of added words - return array("d.data " . ($not ? 'NOT ' : '') . "LIKE '%s'", $num_new_scores, $num_valid_words); + return array("d.[data] " . ($not ? 'NOT ' : '') . "LIKE %s", $num_new_scores, $num_valid_words); } /** @@ -912,7 +912,7 @@ function _search_parse_query(&$word, &$s * * @ingroup search */ -function do_search($keywords, $type, $join1 = '', $where1 = '1 = 1', $arguments1 = array(), $columns2 = 'i.relevance AS score', $join2 = '', $arguments2 = array(), $sort_parameters = 'ORDER BY score DESC') { +function do_search($keywords, $type, $join1 = '', $where1 = '1 = 1', $arguments1 = array(), $columns2 = 'i.[relevance] AS [score]', $join2 = '', $arguments2 = array(), $sort_parameters = 'ORDER BY [score] DESC') { $query = search_parse_query($keywords); if ($query[2] == '') { @@ -928,26 +928,26 @@ function do_search($keywords, $type, $jo } // Build query for keyword normalization. - $conditions = "$where1 AND ($query[2]) AND i.type = '%s'"; + $conditions = "$where1 AND ($query[2]) AND i.[type] = %s"; $arguments1 = array_merge($arguments1, $query[3], array($type)); - $join = "INNER JOIN {search_total} t ON i.word = t.word $join1"; + $join = "INNER JOIN [{search_total}] t ON i.[word] = t.[word] $join1"; if (!$query[5]) { $conditions .= " AND ($query[0])"; $arguments1 = array_merge($arguments1, $query[1]); - $join .= " INNER JOIN {search_dataset} d ON i.sid = d.sid AND i.type = d.type"; + $join .= " INNER JOIN [{search_dataset}] d ON i.[sid] = d.[sid] AND i.[type] = d.[type]"; } // Calculate maximum keyword relevance, to normalize it. - $select = "SELECT SUM(i.score * t.count) AS score FROM {search_index} i $join WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d ORDER BY score DESC"; + $select = "SELECT SUM(i.[score] * t.[count]) AS [score] FROM [{search_index}] i $join WHERE $conditions GROUP BY i.[type], i.[sid] HAVING COUNT(*) >= %d ORDER BY [score] DESC"; $arguments = array_merge($arguments1, array($query[4])); $normalize = db_result(db_query_range($select, $arguments, 0, 1)); if (!$normalize) { return array(); } - $columns2 = str_replace('i.relevance', '(' . (1.0 / $normalize) . ' * SUM(i.score * t.count))', $columns2); + $columns2 = str_replace('i.[relevance]', '(' . (1.0 / $normalize) . ' * SUM(i.[score] * t.[count]))', $columns2); // Build query to retrieve results. - $select = "SELECT i.type, i.sid, $columns2 FROM {search_index} i $join $join2 WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d"; + $select = "SELECT i.[type], i.[sid], $columns2 FROM [{search_index}] i $join $join2 WHERE $conditions GROUP BY i.[type], i.[sid] HAVING COUNT(*) >= %d"; $count_select = "SELECT COUNT(*) FROM ($select) n1"; $arguments = array_merge($arguments2, $arguments1, array($query[4])); 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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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/files/sql-1.txt =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/files/sql-1.txt,v retrieving revision 1.1 diff -u -p -r1.1 sql-1.txt --- modules/simpletest/files/sql-1.txt 20 Apr 2008 18:23:30 -0000 1.1 +++ modules/simpletest/files/sql-1.txt 28 Sep 2008 16:44:07 -0000 @@ -1 +1 @@ -SELECT invalid_field FROM {invalid_table} \ No newline at end of file +SELECT [invalid_field] FROM [{invalid_table}] \ No newline at end of file Index: modules/simpletest/files/sql-2.sql =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/files/sql-2.sql,v retrieving revision 1.1 diff -u -p -r1.1 sql-2.sql --- modules/simpletest/files/sql-2.sql 20 Apr 2008 18:23:30 -0000 1.1 +++ modules/simpletest/files/sql-2.sql 28 Sep 2008 16:44:07 -0000 @@ -1 +1 @@ -SELECT invalid_field FROM {invalid_table} \ No newline at end of file +SELECT [invalid_field] FROM [{invalid_table}] \ No newline at end of file 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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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.8 diff -u -p -r1.8 database_test.test --- modules/simpletest/tests/database_test.test 28 Sep 2008 00:03:33 -0000 1.8 +++ modules/simpletest/tests/database_test.test 28 Sep 2008 16:44:07 -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, @@ -180,7 +180,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; @@ -196,7 +196,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.')); @@ -211,7 +211,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.'))) { @@ -229,7 +229,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.'))) { @@ -263,7 +263,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.'))) { @@ -279,7 +279,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.'))) { @@ -296,12 +296,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.')); @@ -327,7 +327,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( @@ -336,10 +336,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) { @@ -351,8 +351,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( @@ -371,15 +371,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()); } @@ -390,7 +390,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'); @@ -411,15 +411,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()); } @@ -437,7 +437,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.')); } @@ -453,7 +453,7 @@ class DatabaseInsertTestCase extends Dat ->execute(); $this->assertIdentical($id, '5', t('Auto-increment ID returned successfully.')); - } + } catch (Exception $e) { $this->assertTrue(FALSE, $e->getMessage()); } @@ -480,7 +480,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)))); } @@ -494,7 +494,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.')); } @@ -523,7 +523,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) { @@ -541,7 +541,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) { @@ -570,7 +570,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.')); } @@ -581,7 +581,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.')); } @@ -592,7 +592,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.')); } @@ -603,7 +603,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.')); } @@ -615,7 +615,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.')); } } @@ -646,7 +646,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.')); } @@ -659,7 +659,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.')); } @@ -672,7 +672,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.')); } @@ -686,7 +686,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) { @@ -703,7 +703,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.')); } @@ -712,7 +712,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') @@ -721,10 +721,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.')); @@ -760,7 +760,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)))); } @@ -777,7 +777,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.')); } @@ -805,12 +805,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.')); } } @@ -833,7 +833,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')) @@ -843,10 +843,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.')); @@ -860,14 +860,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.')); @@ -877,14 +877,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.')); @@ -894,14 +894,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.')); @@ -911,9 +911,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. @@ -926,10 +926,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.')); @@ -998,7 +998,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(); @@ -1135,7 +1135,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'); @@ -1165,7 +1165,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'); @@ -1195,7 +1195,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); @@ -1236,7 +1236,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); @@ -1521,7 +1521,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); @@ -1585,7 +1585,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(); @@ -1651,7 +1651,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.")); } } @@ -1676,8 +1676,8 @@ class DatabaseLoggingTestCase extends Da try { Database::startLog('testing'); - db_query("SELECT name FROM {test} WHERE age > :age", array(':age' => 25))->fetchCol(); - db_query("SELECT age FROM {test} WHERE name > :name", array(':name' => 'Ringo'))->fetchCol(); + db_query("SELECT [name] FROM [{test}] WHERE [age] > :age", array(':age' => 25))->fetchCol(); + db_query("SELECT [age] FROM [{test}] WHERE [name] > :name", array(':name' => 'Ringo'))->fetchCol(); $queries = Database::getLog('testing', 'default'); @@ -1706,11 +1706,11 @@ class DatabaseLoggingTestCase extends Da try { Database::startLog('testing1'); - db_query("SELECT name FROM {test} WHERE age > :age", array(':age' => 25))->fetchCol(); + db_query("SELECT [name] FROM [{test}] WHERE [age] > :age", array(':age' => 25))->fetchCol(); Database::startLog('testing2'); - db_query("SELECT age FROM {test} WHERE name > :name", array(':name' => 'Ringo'))->fetchCol(); + db_query("SELECT [age] FROM [{test}] WHERE [name] > :name", array(':name' => 'Ringo'))->fetchCol(); $queries1 = Database::getLog('testing1'); $queries2 = Database::getLog('testing2'); 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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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 28 Sep 2008 16:44:07 -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/statistics/statistics.module =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v retrieving revision 1.283 diff -u -p -r1.283 statistics.module --- modules/statistics/statistics.module 17 Sep 2008 07:11:58 -0000 1.283 +++ modules/statistics/statistics.module 28 Sep 2008 16:44:07 -0000 @@ -178,7 +178,7 @@ function statistics_menu() { */ function statistics_user($op, &$edit, &$user) { if ($op == 'delete') { - db_query('UPDATE {accesslog} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE [{accesslog}] SET [uid] = 0 WHERE [uid] = %d', $user->uid); } } @@ -190,12 +190,12 @@ function statistics_cron() { if ((REQUEST_TIME - $statistics_timestamp) >= 86400) { // Reset day counts. - db_query('UPDATE {node_counter} SET daycount = 0'); + db_query('UPDATE [{node_counter}] SET [daycount] = 0'); variable_set('statistics_day_timestamp', REQUEST_TIME); } // Clean up expired access logs. - db_query('DELETE FROM {accesslog} WHERE timestamp < %d', REQUEST_TIME - variable_get('statistics_flush_accesslog_timer', 259200)); + db_query('DELETE FROM [{accesslog}] WHERE [timestamp] < %d', REQUEST_TIME - variable_get('statistics_flush_accesslog_timer', 259200)); } /** @@ -216,7 +216,7 @@ function statistics_cron() { */ function statistics_title_list($dbfield, $dbrows) { if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) { - return db_query_range(db_rewrite_sql("SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {node_counter} s ON n.nid = s.nid INNER JOIN {users} u ON n.uid = u.uid WHERE s." . $dbfield . " != 0 AND n.status = 1 ORDER BY s." . $dbfield . " DESC"), 0, $dbrows); + return db_query_range(db_rewrite_sql("SELECT n.[nid], n.[title], u.[uid], u.[name] FROM [{node}] n INNER JOIN [{node_counter}] s ON n.[nid] = s.[nid] INNER JOIN [{users}] u ON n.[uid] = u.[uid] WHERE s.[" . $dbfield . "] <> 0 AND n.[status] = 1 ORDER BY s.[" . $dbfield . "] DESC"), 0, $dbrows); } return FALSE; } @@ -239,7 +239,7 @@ function statistics_get($nid) { if ($nid > 0) { // Retrieve an array with both totalcount and daycount. - $statistics = db_fetch_array(db_query('SELECT totalcount, daycount, timestamp FROM {node_counter} WHERE nid = %d', $nid)); + $statistics = db_fetch_array(db_query('SELECT [totalcount], [daycount], [timestamp] FROM [{node_counter}] WHERE [nid] = %d', $nid)); } return $statistics; @@ -325,7 +325,7 @@ function statistics_nodeapi(&$node, $op, switch ($op) { case 'delete': // clean up statistics table when node is deleted - db_query('DELETE FROM {node_counter} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{node_counter}] WHERE [nid] = %d', $node->nid); } } @@ -337,9 +337,9 @@ function statistics_ranking() { return array( 'views' => array( 'title' => t('Number of views'), - 'join' => 'LEFT JOIN {node_counter} node_counter ON node_counter.nid = i.sid', + 'join' => 'LEFT JOIN [{node_counter}] [node_counter] ON [node_counter].[nid] = i.[sid]', // Inverse law that maps the highest view count on the site to 1 and 0 to 0. - 'score' => '2.0 - 2.0 / (1.0 + node_counter.totalcount * %f)', + 'score' => '2.0 - 2.0 / (1.0 + [node_counter].[totalcount] * %f)', 'arguments' => array(variable_get('node_cron_views_scale', 0)), ), ); Index: modules/statistics/statistics.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.pages.inc,v retrieving revision 1.3 diff -u -p -r1.3 statistics.pages.inc --- modules/statistics/statistics.pages.inc 14 Apr 2008 17:48:41 -0000 1.3 +++ modules/statistics/statistics.pages.inc 28 Sep 2008 16:44:07 -0000 @@ -15,7 +15,7 @@ function statistics_node_tracker() { array('data' => t('User'), 'field' => 'u.name'), array('data' => t('Operations'))); - $result = pager_query('SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\'' . tablesort_sql($header), 30, 0, NULL, $node->nid); + $result = pager_query('SELECT a.[aid], a.[timestamp], a.[url], a.[uid], u.[name] FROM [{accesslog}] a LEFT JOIN [{users}] u ON a.[uid] = u.[uid] WHERE a.[path] LIKE %s' . tablesort_sql($header), 30, 0, NULL, 'node/' . (int) $node->nid . '%'); $rows = array(); while ($log = db_fetch_object($result)) { $rows[] = array( @@ -47,7 +47,7 @@ function statistics_user_tracker() { array('data' => t('Page'), 'field' => 'path'), array('data' => t('Operations'))); - $result = pager_query('SELECT aid, timestamp, path, title FROM {accesslog} WHERE uid = %d' . tablesort_sql($header), 30, 0, NULL, $account->uid); + $result = pager_query('SELECT [aid], [timestamp], [path], [title] FROM [{accesslog}] WHERE [uid] = %d' . tablesort_sql($header), 30, 0, NULL, $account->uid); $rows = array(); while ($log = db_fetch_object($result)) { $rows[] = array( Index: modules/statistics/statistics.test =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.test,v retrieving revision 1.4 diff -u -p -r1.4 statistics.test --- modules/statistics/statistics.test 17 Sep 2008 07:11:58 -0000 1.4 +++ modules/statistics/statistics.test 28 Sep 2008 16:44:07 -0000 @@ -23,7 +23,7 @@ class StatisticsBlockVisitorsTestCase ex $this->blocking_user = $this->drupalCreateUser(array('block IP addresses', 'access statistics')); // Insert dummy access by anonymous user into access log. - db_query("INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) values('%s', '%s', '%s', '%s', %d, '%s', %d, %d)", 'test', 'node/1', 'http://example.com', '192.168.1.1', '0', '10', '10', REQUEST_TIME); + db_query("INSERT INTO [{accesslog}] ([title], [path], [url], [hostname], [uid], [sid], [timer], [timestamp]) VALUES (%s, %s, %s, %s, %d, %s, %d, %d)", 'test', 'node/1', 'http://example.com', '192.168.1.1', '0', '10', '10', REQUEST_TIME); } /** @@ -49,7 +49,7 @@ class StatisticsBlockVisitorsTestCase ex $edit = array(); $edit['ip'] = $test_ip_address; $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/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.94 diff -u -p -r1.94 system.admin.inc --- modules/system/system.admin.inc 27 Sep 2008 19:03:30 -0000 1.94 +++ modules/system/system.admin.inc 28 Sep 2008 16:44:07 -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'); } @@ -998,7 +998,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 @@ -1113,7 +1113,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, @@ -1155,7 +1155,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()) { @@ -1168,7 +1168,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; @@ -1192,7 +1192,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'; @@ -1783,7 +1783,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.269 diff -u -p -r1.269 system.install --- modules/system/system.install 27 Sep 2008 20:16:17 -0000 1.269 +++ modules/system/system.install 28 Sep 2008 16:44:08 -0000 @@ -366,70 +366,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, status, data) VALUES('%s', '%s', %d, %d, '%s')", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, 1, serialize(array())); + db_query("INSERT INTO [{users}] ([name], [mail], [created], [status], [data]) VALUES (%s, %s, %d, %d, %s)", 'placeholder-for-uid-1', 'placeholder-for-uid-1', REQUEST_TIME, 1, 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.624 diff -u -p -r1.624 system.module --- modules/system/system.module 27 Sep 2008 19:47:43 -0000 1.624 +++ modules/system/system.module 28 Sep 2008 16:44:08 -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 28 Sep 2008 16:44:08 -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 28 Sep 2008 16:44:08 -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.430 diff -u -p -r1.430 taxonomy.module --- modules/taxonomy/taxonomy.module 27 Sep 2008 20:37:01 -0000 1.430 +++ modules/taxonomy/taxonomy.module 28 Sep 2008 16:44:08 -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; @@ -1006,7 +1006,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)) { @@ -1048,7 +1048,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]; } @@ -1110,7 +1110,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(); @@ -1126,20 +1126,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 28 Sep 2008 16:44:08 -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.8 diff -u -p -r1.8 taxonomy.test --- modules/taxonomy/taxonomy.test 24 Sep 2008 18:42:00 -0000 1.8 +++ modules/taxonomy/taxonomy.test 28 Sep 2008 16:44:08 -0000 @@ -474,7 +474,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'); } @@ -510,7 +510,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.')); } @@ -521,7 +521,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/tracker/tracker.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/tracker/tracker.pages.inc,v retrieving revision 1.8 diff -u -p -r1.8 tracker.pages.inc --- modules/tracker/tracker.pages.inc 17 Sep 2008 07:11:58 -0000 1.8 +++ modules/tracker/tracker.pages.inc 28 Sep 2008 16:44:08 -0000 @@ -22,16 +22,16 @@ function tracker_page($account = NULL, $ drupal_set_title(check_plain($account->name)); } // TODO: These queries are very expensive, see http://drupal.org/node/105639 - $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d) ORDER BY last_updated DESC'; + $sql = 'SELECT DISTINCT(n.[nid]), n.[title], n.[type], n.[changed], n.[uid], u.[name], GREATEST(n.[changed], l.[last_comment_timestamp]) AS [last_updated], l.[comment_count] FROM [{node}] n INNER JOIN [{node_comment_statistics}] l ON n.[nid] = l.[nid] INNER JOIN [{users}] u ON n.[uid] = u.[uid] LEFT JOIN [{comments}] c ON n.[nid] = c.[nid] AND (c.[status] = %d OR c.[status] IS NULL) WHERE n.[status] = 1 AND (n.[uid] = %d OR c.[uid] = %d) ORDER BY [last_updated] DESC'; $sql = db_rewrite_sql($sql); - $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n LEFT JOIN {comments} c ON n.nid = c.nid AND (c.status = %d OR c.status IS NULL) WHERE n.status = 1 AND (n.uid = %d OR c.uid = %d)'; + $sql_count = 'SELECT COUNT(DISTINCT(n.[nid])) FROM [{node}] n LEFT JOIN [{comments}] c ON n.[nid] = c.[nid] AND (c.[status] = %d OR c.[status] IS NULL) WHERE n.[status] = 1 AND (n.[uid] = %d OR c.[uid] = %d)'; $sql_count = db_rewrite_sql($sql_count); $result = pager_query($sql, 25, 0, $sql_count, COMMENT_PUBLISHED, $account->uid, $account->uid); } else { - $sql = 'SELECT DISTINCT(n.nid), n.title, n.type, n.changed, n.uid, u.name, GREATEST(n.changed, l.last_comment_timestamp) AS last_updated, l.comment_count FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 ORDER BY last_updated DESC'; + $sql = 'SELECT DISTINCT(n.[nid]), n.[title], n.[type], n.[changed], n.[uid], u.[name], GREATEST(n.[changed], l.[last_comment_timestamp]) AS [last_updated], l.[comment_count] FROM [{node}] n INNER JOIN [{users}] u ON n.[uid] = u.[uid] INNER JOIN [{node_comment_statistics}] l ON n.[nid] = l.[nid] WHERE n.[status] = 1 ORDER BY [last_updated] DESC'; $sql = db_rewrite_sql($sql); - $sql_count = 'SELECT COUNT(n.nid) FROM {node} n WHERE n.status = 1'; + $sql_count = 'SELECT COUNT(n.[nid]) FROM [{node}] n WHERE n.[status] = 1'; $sql_count = db_rewrite_sql($sql_count); $result = pager_query($sql, 25, 0, $sql_count); } Index: modules/translation/translation.module =================================================================== RCS file: /cvs/drupal/drupal/modules/translation/translation.module,v retrieving revision 1.29 diff -u -p -r1.29 translation.module --- modules/translation/translation.module 16 Aug 2008 21:36:57 -0000 1.29 +++ modules/translation/translation.module 28 Sep 2008 16:44:08 -0000 @@ -216,19 +216,19 @@ function translation_nodeapi(&$node, $op else { // Create new translation set, using nid from the source node. $tnid = $node->translation_source->nid; - db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $tnid, 0, $node->translation_source->nid); + db_query("UPDATE [{node}] SET [tnid] = %d, [translate] = %d WHERE [nid] = %d", $tnid, 0, $node->translation_source->nid); } - db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $tnid, 0, $node->nid); + db_query("UPDATE [{node}] SET [tnid] = %d, [translate] = %d WHERE [nid] = %d", $tnid, 0, $node->nid); } break; case 'update': if (isset($node->translation) && $node->translation && !empty($node->language) && $node->tnid) { // Update translation information. - db_query("UPDATE {node} SET tnid = %d, translate = %d WHERE nid = %d", $node->tnid, $node->translation['status'], $node->nid); + db_query("UPDATE [{node}] SET [tnid] = %d, [translate] = %d WHERE [nid] = %d", $node->tnid, $node->translation['status'], $node->nid); if (!empty($node->translation['retranslate'])) { // This is the source node, asking to mark all translations outdated. - db_query("UPDATE {node} SET translate = 1 WHERE tnid = %d AND nid <> %d", $node->tnid, $node->nid); + db_query("UPDATE [{node}] SET [translate] = 1 WHERE [tnid] = %d AND [nid] <> %d", $node->tnid, $node->nid); } } break; @@ -245,18 +245,18 @@ function translation_nodeapi(&$node, $op */ function translation_remove_from_set($node) { if (isset($node->tnid)) { - if (db_result(db_query('SELECT COUNT(*) FROM {node} WHERE tnid = %d', $node->tnid)) <= 2) { + if (db_result(db_query('SELECT COUNT(*) FROM [{node}] WHERE [tnid] = %d', $node->tnid)) <= 2) { // There would only be one node left in the set: remove the set altogether. - db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE tnid = %d', $node->tnid); + db_query('UPDATE [{node}] SET [tnid] = 0, [translate] = 0 WHERE [tnid] = %d', $node->tnid); } else { - db_query('UPDATE {node} SET tnid = 0, translate = 0 WHERE nid = %d', $node->nid); + db_query('UPDATE [{node}] SET [tnid] = 0, [translate] = 0 WHERE [nid] = %d', $node->nid); // If the node being removed was the source of the translation set, // we pick a new source - preferably one that is up to date. if ($node->tnid == $node->nid) { - $new_tnid = db_result(db_query('SELECT nid FROM {node} WHERE tnid = %d ORDER BY translate ASC, nid ASC', $node->tnid)); - db_query('UPDATE {node} SET tnid = %d WHERE tnid = %d', $new_tnid, $node->tnid); + $new_tnid = db_result(db_query('SELECT [nid] FROM [{node}] WHERE [tnid] = %d ORDER BY [translate] ASC, [nid] ASC', $node->tnid)); + db_query('UPDATE [{node}] SET [tnid] = %d WHERE [tnid] = %d', $new_tnid, $node->tnid); } } } @@ -281,7 +281,7 @@ function translation_node_get_translatio if (is_numeric($tnid) && $tnid) { if (!isset($translations[$tnid])) { $translations[$tnid] = array(); - $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, n.language FROM {node} n WHERE n.tnid = %d'), $tnid); + $result = db_query(db_rewrite_sql('SELECT n.[nid], n.[title], n.[language] FROM [{node}] n WHERE n.[tnid] = %d'), $tnid); while ($node = db_fetch_object($result)) { $translations[$tnid][$node->language] = $node; } Index: modules/trigger/trigger.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/trigger/trigger.admin.inc,v retrieving revision 1.7 diff -u -p -r1.7 trigger.admin.inc --- modules/trigger/trigger.admin.inc 16 Jul 2008 21:59:28 -0000 1.7 +++ modules/trigger/trigger.admin.inc 28 Sep 2008 16:44:08 -0000 @@ -82,7 +82,7 @@ function trigger_unassign_submit($form, $form_values = $form_state['values']; if ($form_values['confirm'] == 1) { $aid = actions_function_lookup($form_values['aid']); - db_query("DELETE FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $form_values['hook'], $form_values['operation'], $aid); + db_query("DELETE FROM [{trigger_assignments}] WHERE [hook] = %s AND [op] = %s AND [aid] = %s", $form_values['hook'], $form_values['operation'], $aid); $actions = actions_get_all_actions(); watchdog('actions', 'Action %action has been unassigned.', array('%action' => check_plain($actions[$aid]['description']))); drupal_set_message(t('Action %action has been unassigned.', array('%action' => $actions[$aid]['description']))); @@ -188,7 +188,7 @@ function trigger_assign_form_validate($f $form_values = $form_state['values']; if (!empty($form_values['aid'])) { $aid = actions_function_lookup($form_values['aid']); - if (db_result(db_query("SELECT aid FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = '%s'", $form_values['hook'], $form_values['operation'], $aid))) { + if (db_result(db_query("SELECT [aid] FROM [{trigger_assignments}] WHERE [hook] = %s AND [op] = %s AND [aid] = %s", $form_values['hook'], $form_values['operation'], $aid))) { form_set_error($form_values['operation'], t('The action you chose is already assigned to that trigger.')); } } @@ -202,18 +202,18 @@ function trigger_assign_form_submit($for if (!empty($form_values['aid'])) { $aid = actions_function_lookup($form_values['aid']); - $weight = db_result(db_query("SELECT MAX(weight) FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s'", $form_values['hook'], $form_values['operation'])); - db_query("INSERT INTO {trigger_assignments} values ('%s', '%s', '%s', %d)", $form_values['hook'], $form_values['operation'], $aid, $weight + 1); + $weight = db_result(db_query("SELECT MAX([weight]) FROM [{trigger_assignments}] WHERE [hook] = %s AND [op] = %s", $form_values['hook'], $form_values['operation'])); + db_query("INSERT INTO [{trigger_assignments}] VALUES (%s, %s, %s, %d)", $form_values['hook'], $form_values['operation'], $aid, $weight + 1); // If this action changes a node property, we need to save the node // so the change will persist. $actions = actions_list(); if (isset($actions[$aid]['behavior']) && in_array('changes_node_property', $actions[$aid]['behavior']) && ($form_values['operation'] != 'presave')) { // Delete previous node_save_action if it exists, and re-add a new one at a higher weight. - $save_post_action_assigned = db_result(db_query("SELECT aid FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = 'node_save_action'", $form_values['hook'], $form_values['operation'])); + $save_post_action_assigned = db_result(db_query("SELECT [aid] FROM [{trigger_assignments}] WHERE [hook] = %s AND [op] = %s AND [aid] = 'node_save_action'", $form_values['hook'], $form_values['operation'])); if ($save_post_action_assigned) { - db_query("DELETE FROM {trigger_assignments} WHERE hook = '%s' AND op = '%s' AND aid = 'node_save_action'", $form_values['hook'], $form_values['operation']); + db_query("DELETE FROM [{trigger_assignments}] WHERE [hook] = %s AND [op] = %s AND [aid] = 'node_save_action'", $form_values['hook'], $form_values['operation']); } - db_query("INSERT INTO {trigger_assignments} VALUES ('%s', '%s', '%s', %d)", $form_values['hook'], $form_values['operation'], 'node_save_action', $weight + 2); + db_query("INSERT INTO [{trigger_assignments}] VALUES (%s, %s, %s, %d)", $form_values['hook'], $form_values['operation'], 'node_save_action', $weight + 2); if (!$save_post_action_assigned) { drupal_set_message(t('You have added an action that changes a the property of a post. A Save post action has been added so that the property change will be saved.')); } @@ -273,10 +273,10 @@ function theme_trigger_display($element) function _trigger_get_hook_actions($hook, $op, $type = NULL) { $actions = array(); if ($type) { - $result = db_query("SELECT h.aid, a.description FROM {trigger_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE a.type = '%s' AND h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $type, $hook, $op); + $result = db_query("SELECT h.[aid], a.[description] FROM [{trigger_assignments}] h LEFT JOIN [{actions}] a on a.[aid] = h.[aid] WHERE a.[type] = %s AND h.[hook] = %s AND h.[op] = %s ORDER BY h.[weight]", $type, $hook, $op); } else { - $result = db_query("SELECT h.aid, a.description FROM {trigger_assignments} h LEFT JOIN {actions} a on a.aid = h.aid WHERE h.hook = '%s' AND h.op = '%s' ORDER BY h.weight", $hook, $op); + $result = db_query("SELECT h.[aid], a.[description] FROM [{trigger_assignments}] h LEFT JOIN [{actions}] a on a.[aid] = h.[aid] WHERE h.[hook] = %s AND h.[op] = %s ORDER BY h.[weight]", $hook, $op); } while ($action = db_fetch_object($result)) { $actions[$action->aid] = $action->description; Index: modules/trigger/trigger.module =================================================================== RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v retrieving revision 1.18 diff -u -p -r1.18 trigger.module --- modules/trigger/trigger.module 21 Aug 2008 19:36:38 -0000 1.18 +++ modules/trigger/trigger.module 28 Sep 2008 16:44:08 -0000 @@ -92,7 +92,7 @@ function trigger_menu() { if (in_array($module, array('node', 'comment', 'user', 'system', 'taxonomy'))) { continue; } - $info = db_result(db_query("SELECT info FROM {system} WHERE name = '%s'", $module)); + $info = db_result(db_query("SELECT [info] FROM [{system}] WHERE [name] = %s", $module)); $info = unserialize($info); $nice_name = $info['name']; $items["admin/build/trigger/$module"] = array( @@ -135,7 +135,7 @@ function trigger_access_check($module) { */ function _trigger_get_hook_aids($hook, $op = '') { $aids = array(); - $result = db_query("SELECT aa.aid, a.type FROM {trigger_assignments} aa LEFT JOIN {actions} a ON aa.aid = a.aid WHERE aa.hook = '%s' AND aa.op = '%s' ORDER BY weight", $hook, $op); + $result = db_query("SELECT aa.[aid], a.[type] FROM [{trigger_assignments}] aa LEFT JOIN [{actions}] a ON aa.[aid] = a.[aid] WHERE aa.[hook] = %s AND aa.[op] = %s ORDER BY [weight]", $hook, $op); while ($action = db_fetch_object($result)) { $aids[$action->aid]['type'] = $action->type; } @@ -423,5 +423,5 @@ function trigger_options($type = 'all') * Remove all trigger entries for the given action, when deleted. */ function trigger_actions_delete($aid) { - db_query("DELETE FROM {trigger_assignments} WHERE aid = '%s'", $aid); + db_query("DELETE FROM [{trigger_assignments}] WHERE [aid] = %s", $aid); } Index: modules/trigger/trigger.test =================================================================== RCS file: /cvs/drupal/drupal/modules/trigger/trigger.test,v retrieving revision 1.3 diff -u -p -r1.3 trigger.test --- modules/trigger/trigger.test 2 Jun 2008 17:39:12 -0000 1.3 +++ modules/trigger/trigger.test 28 Sep 2008 16:44:08 -0000 @@ -63,7 +63,7 @@ class TriggerContentTestCase extends Dru // Test 3: The action should be able to be unassigned from a trigger. $this->drupalPost('admin/build/trigger/unassign/nodeapi/presave/' . $hash, array(), t('Unassign')); $this->assertRaw(t('Action %action has been unassigned.', array('%action' => ucfirst($info['name']))), t('Check to make sure the @action action can be unassigned from the trigger.', array('@action' => $info['name']))); - $assigned = db_result(db_query("SELECT COUNT(*) FROM {trigger_assignments} WHERE aid IN ('" . implode("','", $content_actions) . "')")); + $assigned = db_result(db_query("SELECT COUNT(*) FROM [{trigger_assignments}] WHERE [aid] IN ('" . implode("', '", $content_actions) . "')")); $this->assertFalse($assigned, t('Check to make sure unassign worked properly at the database level.')); } } @@ -111,4 +111,4 @@ class TriggerContentTestCase extends Dru ); return $info[$action]; } -} \ No newline at end of file +} Index: modules/upload/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.module,v retrieving revision 1.207 diff -u -p -r1.207 upload.module --- modules/upload/upload.module 27 Sep 2008 20:37:01 -0000 1.207 +++ modules/upload/upload.module 28 Sep 2008 16:44:08 -0000 @@ -148,7 +148,7 @@ function _upload_file_limits($user) { */ function upload_file_download($filepath) { $filepath = file_create_path($filepath); - $result = db_query("SELECT f.* FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid WHERE filepath = '%s'", $filepath); + $result = db_query("SELECT f.* FROM [{files}] f INNER JOIN [{upload}] u ON f.[fid] = u.[fid] WHERE [filepath] = %s", $filepath); if ($file = db_fetch_object($result)) { if (!user_access('view uploaded files')) { return -1; @@ -386,7 +386,7 @@ function upload_space_used($uid) { * The amount of disk space used by uploaded files in bytes. */ function upload_total_space_used() { - return db_result(db_query('SELECT SUM(f.filesize) FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid')); + return db_result(db_query('SELECT SUM(f.[filesize]) FROM [{files}] f INNER JOIN [{upload}] u ON f.[fid] = u.[fid]')); } function upload_save(&$node) { @@ -401,13 +401,13 @@ function upload_save(&$node) { // Remove file. Process removals first since no further processing // will be required. if (!empty($file->remove)) { - db_query('DELETE FROM {upload} WHERE fid = %d AND vid = %d', $fid, $node->vid); + db_query('DELETE FROM [{upload}] WHERE [fid] = %d AND [vid] = %d', $fid, $node->vid); // If the file isn't used by any other revisions delete it. - $count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $fid)); + $count = db_result(db_query('SELECT COUNT([fid]) FROM [{upload}] WHERE [fid] = %d', $fid)); if ($count < 1) { file_delete($file->filepath); - db_query('DELETE FROM {files} WHERE fid = %d', $fid); + db_query('DELETE FROM [{files}] WHERE [fid] = %d', $fid); } // Remove it from the session in the case of new uploads, @@ -419,11 +419,11 @@ function upload_save(&$node) { // Create a new revision, or associate a new file needed. if (!empty($node->old_vid) || isset($_SESSION['upload_files'][$fid])) { - db_query("INSERT INTO {upload} (fid, nid, vid, list, description, weight) VALUES (%d, %d, %d, %d, '%s', %d)", $file->fid, $node->nid, $node->vid, $file->list, $file->description, $file->weight); + db_query("INSERT INTO [{upload}] ([fid], [nid], [vid], [list], [description], [weight]) VALUES (%d, %d, %d, %d, %s, %d)", $file->fid, $node->nid, $node->vid, $file->list, $file->description, $file->weight); } // Update existing revision. else { - db_query("UPDATE {upload} SET list = %d, description = '%s', weight = %d WHERE fid = %d AND vid = %d", $file->list, $file->description, $file->weight, $file->fid, $node->vid); + db_query("UPDATE [{upload}] SET [list] = %d, [description] = %s, [weight] = %d WHERE [fid] = %d AND [vid] = %d", $file->list, $file->description, $file->weight, $file->fid, $node->vid); } file_set_status($file, FILE_STATUS_PERMANENT); } @@ -434,37 +434,37 @@ function upload_save(&$node) { function upload_delete($node) { $files = array(); - $result = db_query('SELECT DISTINCT f.* FROM {upload} u INNER JOIN {files} f ON u.fid = f.fid WHERE u.nid = %d', $node->nid); + $result = db_query('SELECT DISTINCT f.* FROM [{upload}] u INNER JOIN [{files}] f ON u.[fid] = f.[fid] WHERE u.[nid] = %d', $node->nid); while ($file = db_fetch_object($result)) { $files[$file->fid] = $file; } foreach ($files as $fid => $file) { // Delete all files associated with the node - db_query('DELETE FROM {files} WHERE fid = %d', $fid); + db_query('DELETE FROM [{files}] WHERE [fid] = %d', $fid); file_delete($file->filepath); } // Delete all file revision information associated with the node - db_query('DELETE FROM {upload} WHERE nid = %d', $node->nid); + db_query('DELETE FROM [{upload}] WHERE [nid] = %d', $node->nid); } function upload_delete_revision($node) { if (is_array($node->files)) { foreach ($node->files as $file) { // Check if the file will be used after this revision is deleted - $count = db_result(db_query('SELECT COUNT(fid) FROM {upload} WHERE fid = %d', $file->fid)); + $count = db_result(db_query('SELECT COUNT([fid]) FROM [{upload}] WHERE [fid] = %d', $file->fid)); // if the file won't be used, delete it if ($count < 2) { - db_query('DELETE FROM {files} WHERE fid = %d', $file->fid); + db_query('DELETE FROM [{files}] WHERE [fid] = %d', $file->fid); file_delete($file->filepath); } } } // delete the revision - db_query('DELETE FROM {upload} WHERE vid = %d', $node->vid); + db_query('DELETE FROM [{upload}] WHERE [vid] = %d', $node->vid); } function _upload_form($node) { @@ -564,7 +564,7 @@ function upload_load($node) { $files = array(); if ($node->vid) { - $result = db_query('SELECT * FROM {files} f INNER JOIN {upload} r ON f.fid = r.fid WHERE r.vid = %d ORDER BY r.weight, f.fid', $node->vid); + $result = db_query('SELECT * FROM [{files}] f INNER JOIN [{upload}] r ON f.[fid] = r.[fid] WHERE r.[vid] = %d ORDER BY r.[weight], f.[fid]', $node->vid); while ($file = db_fetch_object($result)) { $files[$file->fid] = $file; } Index: modules/upload/upload.test =================================================================== RCS file: /cvs/drupal/drupal/modules/upload/upload.test,v retrieving revision 1.4 diff -u -p -r1.4 upload.test --- modules/upload/upload.test 15 Sep 2008 09:28:50 -0000 1.4 +++ modules/upload/upload.test 28 Sep 2008 16:44:08 -0000 @@ -54,7 +54,7 @@ class UploadTestCase extends DrupalWebTe $this->checkUploadedFile(basename($files[1])); // Fetch db record and use fid to rename and delete file. - $upload = db_fetch_object(db_query('SELECT fid, description FROM {upload} WHERE nid = %d', array($node->nid))); + $upload = db_fetch_object(db_query('SELECT [fid], [description] FROM [{upload}] WHERE [nid] = %d', array($node->nid))); if ($upload) { // Rename file. $edit = array(); 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 28 Sep 2008 16:44:08 -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 28 Sep 2008 16:44:08 -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' => '- ', '#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 28 Sep 2008 16:44:08 -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.12
diff -u -p -r1.12 run-tests.sh
--- scripts/run-tests.sh 24 Sep 2008 19:00:31 -0000 1.12
+++ scripts/run-tests.sh 28 Sep 2008 16:44:08 -0000
@@ -72,7 +72,7 @@ if (!ini_get('safe_mode')) {
simpletest_script_reporter_init();
// Setup database for test results.
-db_query('INSERT INTO {simpletest_test_id} VALUES (default)');
+db_query('INSERT INTO [{simpletest_test_id}] VALUES ([default][)');
$test_id = db_last_insert_id('simpletest_test_id', 'test_id');
// Execute tests.
@@ -82,7 +82,7 @@ simpletest_script_command($args['concurr
simpletest_script_reporter_display_results();
// Cleanup our test results.
-db_query("DELETE FROM {simpletest} WHERE test_id = %d", $test_id);
+db_query("DELETE FROM [{simpletest}] WHERE [test_id] = %d", $test_id);
@@ -111,19 +111,19 @@ All arguments are long options.
--url Immediately preceeds a URL to set the host and path. You will
need this parameter if Drupal is in a subdirectory on your
localhost and you have not set \$base_url in settings.php.
-
+
--php The absolute path to the PHP executable. Usually not needed.
--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').
@@ -391,7 +391,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);
@@ -476,7 +476,7 @@ function simpletest_script_reporter_disp
'exception' => 'Exception'
);
- $results = db_query("SELECT * FROM {simpletest} WHERE test_id = %d ORDER BY test_class, message_id", $test_id);
+ $results = db_query("SELECT * FROM [{simpletest}] WHERE [test_id] = %d ORDER BY [test_class], [message_id]", $test_id);
$test_class = '';
while($result = db_fetch_object($results)) {
if (isset($results_map[$result->status])) {
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 28 Sep 2008 16:44:08 -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:
', '#suffix' => '
', '#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' => '