summaryrefslogtreecommitdiff
path: root/modules/system/system.api.php
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-05-16 18:34:23 +0000
committerDries Buytaert <dries@buytaert.net>2009-05-16 18:34:23 +0000
commit196da1b876d3c2ed2c17109dcbda1ecd6f3d7d5e (patch)
treeb4379549ce783d70c8698d52aca9b2c5c6785d3d /modules/system/system.api.php
parent6cc59e52609302a9a2d2c53985144627e4443021 (diff)
downloadbrdo-196da1b876d3c2ed2c17109dcbda1ecd6f3d7d5e.tar.gz
brdo-196da1b876d3c2ed2c17109dcbda1ecd6f3d7d5e.tar.bz2
- Patch #394572 by Berdir: converted system module to the new database abstraction layer.
Diffstat (limited to 'modules/system/system.api.php')
-rw-r--r--modules/system/system.api.php17
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php
index 5a0b3f648..33c4d8890 100644
--- a/modules/system/system.api.php
+++ b/modules/system/system.api.php
@@ -141,7 +141,10 @@ function hook_elements() {
* None.
*/
function hook_exit($destination = NULL) {
- db_query('UPDATE {counter} SET hits = hits + 1 WHERE type = 1');
+ db_update('counter')
+ ->expression('hits', 'hits + 1')
+ ->condition('type', 1)
+ ->execute();
}
/**
@@ -1243,8 +1246,8 @@ function hook_file_delete($file) {
function hook_file_download($filepath) {
// Check if the file is controlled by the current module.
$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);
- if ($file = db_fetch_object($result)) {
+ $result = db_query("SELECT f.* FROM {files} f INNER JOIN {upload} u ON f.fid = u.fid WHERE filepath = :filepath", array('filepath' => $filepath));
+ foreach ($result as $file) {
if (!user_access('view uploaded files')) {
return -1;
}
@@ -1617,8 +1620,12 @@ function hook_update_N(&$sandbox = NULL) {
// We'll -1 to disregard the uid 0...
$sandbox['max'] = db_query('SELECT COUNT(DISTINCT uid) FROM {users}')->fetchField() - 1;
}
-
- $users = db_query_range("SELECT uid, name FROM {users} WHERE uid > %d ORDER BY uid ASC", $sandbox['current_uid'], 0, 3);
+ db_select('users', 'u')
+ ->fields('u', array('uid', 'name'))
+ ->condition('uid', $sandbox['current_uid'], '>')
+ ->range(0, 3)
+ ->orderBy('uid', 'ASC')
+ ->execute();
foreach ($users as $user) {
$user->name .= '!';
$ret[] = update_sql("UPDATE {users} SET name = '$user->name' WHERE uid = $user->uid");