[geeklog-cvs] geeklog: We really should be using DB_delete instead of DB_query...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Mar 1 03:10:55 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/9ec56f3acd37
changeset: 6805:9ec56f3acd37
user: Dirk Haun <dirk at haun-online.de>
date: Sat Feb 28 19:44:23 2009 +0100
description:
We really should be using DB_delete instead of DB_query("DELETE...") where possible
diffstat:
4 files changed, 20 insertions(+), 20 deletions(-)
plugins/links/functions.inc | 2 +-
plugins/polls/functions.inc | 11 ++++++-----
system/lib-plugins.php | 24 ++++++++++++------------
system/lib-security.php | 3 +--
diffs (122 lines):
diff -r 80cdeb74d1a6 -r 9ec56f3acd37 plugins/links/functions.inc
--- a/plugins/links/functions.inc Sat Feb 28 19:25:22 2009 +0100
+++ b/plugins/links/functions.inc Sat Feb 28 19:44:23 2009 +0100
@@ -441,7 +441,7 @@
if ($_LI_CONF['delete_links'] == 1) {
// delete the links
- DB_query ("DELETE FROM {$_TABLES['links']} WHERE owner_id = $uid");
+ DB_delete($_TABLES['links'], 'owner_id', $uid);
} else {
// assign ownership to a user from the Root group
$rootgroup = DB_getItem ($_TABLES['groups'], 'grp_id',
diff -r 80cdeb74d1a6 -r 9ec56f3acd37 plugins/polls/functions.inc
--- a/plugins/polls/functions.inc Sat Feb 28 19:25:22 2009 +0100
+++ b/plugins/polls/functions.inc Sat Feb 28 19:44:23 2009 +0100
@@ -336,12 +336,13 @@
$result = DB_query ("SELECT pid FROM {$_TABLES['polltopics']} WHERE owner_id = $uid");
$numPolls = DB_numRows ($result);
for ($i = 0; $i < $numPolls; $i++) {
- list($pid) = DB_fetchArray ($result);
- DB_delete ($_TABLES['pollanswers'], 'pid', $pid);
- DB_delete ($_TABLES['pollvoters'], 'pid', $pid);
- DB_query ("DELETE FROM {$_TABLES['comments']} WHERE sid = '$pid' AND type = 'polls'");
+ list($pid) = DB_fetchArray($result);
+ DB_delete($_TABLES['pollanswers'], 'pid', $pid);
+ DB_delete($_TABLES['pollvoters'], 'pid', $pid);
+ DB_delete($_TABLES['comments'], array('sid', 'type'),
+ array($pid, 'polls'));
}
- DB_delete ($_TABLES['polltopics'], 'owner_id', $uid);
+ DB_delete($_TABLES['polltopics'], 'owner_id', $uid);
} else {
// assign ownership to a user from the Root group
$rootgroup = DB_getItem ($_TABLES['groups'], 'grp_id',
diff -r 80cdeb74d1a6 -r 9ec56f3acd37 system/lib-plugins.php
--- a/system/lib-plugins.php Sat Feb 28 19:25:22 2009 +0100
+++ b/system/lib-plugins.php Sat Feb 28 19:44:23 2009 +0100
@@ -210,7 +210,7 @@
// removing variables
for ($i = 0; $i < count($remvars['vars']); $i++) {
COM_errorLog ("Removing variable {$remvars['vars'][$i]}", 1);
- DB_query("DELETE FROM {$_TABLES['vars']} WHERE name = '{$remvars['vars'][$i]}'");
+ DB_delete($_TABLES['vars'], 'name', $remvars['vars'][$i]);
COM_errorLog ('...success', 1);
}
@@ -220,10 +220,10 @@
"grp_name = '{$remvars['groups'][$i]}'");
if (!empty ($grp_id)) {
COM_errorLog ("Attempting to remove the {$remvars['groups'][$i]} group", 1);
- DB_query ("DELETE FROM {$_TABLES['groups']} WHERE grp_id = $grp_id");
+ DB_delete($_TABLES['groups'], 'grp_id', $grp_id);
COM_errorLog ('...success', 1);
COM_errorLog ("Attempting to remove the {$remvars['groups'][$i]} group from all groups.", 1);
- DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id = $grp_id");
+ DB_delete($_TABLES['group_assignments'], 'ug_main_grp_id', $grp_id);
COM_errorLog ('...success', 1);
}
}
@@ -234,10 +234,10 @@
"ft_name = '{$remvars['features'][$i]}'");
if (!empty ($access_id)) {
COM_errorLog ("Attempting to remove {$remvars['features'][$i]} rights from all groups" ,1);
- DB_query ("DELETE FROM {$_TABLES['access']} WHERE acc_ft_id = $access_id");
+ DB_delete($_TABLES['access'], 'acc_ft_id', $access_id);
COM_errorLog ('...success', 1);
COM_errorLog ("Attempting to remove the {$remvars['features'][$i]} feature", 1);
- DB_query ("DELETE FROM {$_TABLES['features']} WHERE ft_name = '{$remvars['features'][$i]}'");
+ DB_delete($_TABLES['features'], 'ft_name', $remvars['features'][$i]);
COM_errorLog ('...success', 1);
}
}
@@ -263,29 +263,29 @@
COM_errorLog ('...success', 1);
// Remove Links Feeds from syndiaction table
COM_errorLog ('removing links feeds from table', 1);
- DB_query ("DELETE FROM {$_TABLES['syndication']} WHERE `type` = '$type'");
+ DB_delete($_TABLES['syndication'], 'type', $type);
COM_errorLog ('...success', 1);
}
// remove comments for this plugin
COM_errorLog ("Attempting to remove comments for $type", 1);
- DB_query ("DELETE FROM {$_TABLES['comments']} WHERE type = '$type'");
+ DB_delete($_TABLES['comments'], 'type', $type);
COM_errorLog ('...success', 1);
// uninstall php-blocks
- for ($i=0; $i < count($remvars['php_blocks']); $i++) {
- DB_delete ($_TABLES['blocks'], array ('type', 'phpblockfn'),
- array ('phpblock', $remvars['php_blocks'][$i]));
+ for ($i = 0; $i < count($remvars['php_blocks']); $i++) {
+ DB_delete($_TABLES['blocks'], array('type', 'phpblockfn'),
+ array('phpblock', $remvars['php_blocks'][$i]));
}
// remove config table data for this plugin
COM_errorLog ("Attempting to remove config table records for group_name: $type", 1);
- DB_query ("DELETE FROM {$_TABLES['conf_values']} WHERE group_name = '$type'");
+ DB_delete($_TABLES['conf_values'], 'group_name', $type);
COM_errorLog ('...success', 1);
// uninstall the plugin
COM_errorLog ("Attempting to unregister the $type plugin from Geeklog", 1);
- DB_query ("DELETE FROM {$_TABLES['plugins']} WHERE pi_name = '$type'");
+ DB_delete($_TABLES['plugins'], 'pi_name', $type);
COM_errorLog ('...success',1);
COM_errorLog ("Finished uninstalling the $type plugin.", 1);
diff -r 80cdeb74d1a6 -r 9ec56f3acd37 system/lib-security.php
--- a/system/lib-security.php Sat Feb 28 19:25:22 2009 +0100
+++ b/system/lib-security.php Sat Feb 28 19:44:23 2009 +0100
@@ -1171,8 +1171,7 @@
}
// It's a one time token. So eat it.
- $sql = "DELETE FROM {$_TABLES['tokens']} WHERE token='$token'";
- DB_query($sql);
+ DB_delete($_TABLES['tokens'], 'token', $token);
}
} else {
$return = false; // no token.
More information about the geeklog-cvs
mailing list