use wrapped database execute function

git-svn-id: file:///home/shish/svn/shimmie2/trunk@129 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2007-05-23 22:19:12 +00:00
parent 6bbe00304b
commit 6c26fa0fc1
11 changed files with 30 additions and 32 deletions

View file

@ -18,7 +18,7 @@ class Notes extends Extension {
protected function install() {
global $database;
global $config;
$database->db->Execute("CREATE TABLE `image_notes` (
$database->Execute("CREATE TABLE `image_notes` (
`id` int(11) NOT NULL auto_increment,
`image_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,

View file

@ -50,7 +50,7 @@ class Ratings extends Extension {
protected function install() {
global $database;
global $config;
$database->db->Execute("CREATE TABLE `image_voters` (
$database->Execute("CREATE TABLE `image_voters` (
`image_id` int(11) NOT NULL,
`user_id` int(11) NOT NULL,
`vote` tinyint(4) NOT NULL,
@ -111,7 +111,7 @@ class Ratings extends Extension {
}
else {
$i_rating = int_escape($rating);
$database->db->Execute(
$database->Execute(
"INSERT INTO image_ratings(image_id, user_id, rating, rated) ".
"VALUES(?, ?, ?, now())",
array($image_id, $user->id, $i_rating));
@ -122,7 +122,7 @@ class Ratings extends Extension {
private function delete_ratings($image_id) {
global $database;
$database->db->Execute("DELETE FROM image_voters WHERE image_id=?", array($image_id));
$database->Execute("DELETE FROM image_voters WHERE image_id=?", array($image_id));
}
// }}}
}

View file

@ -46,15 +46,15 @@ class Config {
foreach($this->values as $name => $value) {
// does "or update" work with sqlite / postgres?
$database->db->StartTrans();
$database->db->Execute("DELETE FROM config WHERE name = ?", array($name));
$database->db->Execute("INSERT INTO config VALUES (?, ?)", array($name, $value));
$database->Execute("DELETE FROM config WHERE name = ?", array($name));
$database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $value));
$database->db->CommitTrans();
}
}
else {
$database->db->StartTrans();
$database->db->Execute("DELETE FROM config WHERE name = ?", array($name));
$database->db->Execute("INSERT INTO config VALUES (?, ?)", array($name, $this->values[$name]));
$database->Execute("DELETE FROM config WHERE name = ?", array($name));
$database->Execute("INSERT INTO config VALUES (?, ?)", array($name, $this->values[$name]));
$database->db->CommitTrans();
}
}

View file

@ -157,7 +157,7 @@ class ImageIO extends Extension {
}
// actually insert the info
$database->db->Execute(
$database->Execute(
"INSERT INTO images(owner_id, owner_ip, filename, filesize, hash, ext, width, height, posted) ".
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, now())",
array($user->id, $_SERVER['REMOTE_ADDR'], $image->filename, $image->filesize,

View file

@ -77,7 +77,7 @@ class TagEdit extends Extension {
private function mass_tag_edit($search, $replace) {
// FIXME: deal with collisions
global $database;
$database->db->Execute("UPDATE tags SET tag=? WHERE tag=?", Array($replace, $search));
$database->Execute("UPDATE tags SET tag=? WHERE tag=?", Array($replace, $search));
}
// }}}
// HTML {{{

View file

@ -156,7 +156,7 @@ class UserPage extends Extension {
$email = isset($_POST['email']) ? $_POST['email'] : null;
// FIXME: send_event()
$database->db->Execute(
$database->Execute(
"INSERT INTO users (name, pass, joindate, email) VALUES (?, ?, now(), ?)",
array($name, $hash, $email));
@ -209,7 +209,7 @@ class UserPage extends Extension {
// FIXME: send_event()
// FIXME: $duser->set_pass();
$database->db->Execute(
$database->Execute(
"UPDATE users SET pass = ? WHERE id = ?",
array($hash, $id));

View file

@ -31,8 +31,7 @@ class User {
global $database;
$yn = $enabled ? 'Y' : 'N';
$database->db->Execute("UPDATE users SET enabled=? WHERE id=?",
array($yn, $this->id));
$database->Execute("UPDATE users SET enabled=? WHERE id=?", array($yn, $this->id));
}
public function is_admin() {
@ -43,8 +42,7 @@ class User {
global $database;
$yn = $admin ? 'Y' : 'N';
$database->db->Execute("UPDATE users SET admin=? WHERE id=?",
array($yn, $this->id));
$database->Execute("UPDATE users SET admin=? WHERE id=?", array($yn, $this->id));
}
public function get_days_old() {

View file

@ -24,7 +24,7 @@ class AliasEditor extends Extension {
else if($event->get_arg(0) == "remove") {
if(isset($_POST['oldtag'])) {
global $database;
$database->db->Execute("DELETE FROM aliases WHERE oldtag=?", array($_POST['oldtag']));
$database->Execute("DELETE FROM aliases WHERE oldtag=?", array($_POST['oldtag']));
global $page;
$page->set_mode("redirect");
@ -41,7 +41,7 @@ class AliasEditor extends Extension {
if(is_a($event, 'AddAliasEvent')) {
global $database;
$database->db->Execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", array($event->oldtag, $event->newtag));
$database->Execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", array($event->oldtag, $event->newtag));
global $page;
$page->set_mode("redirect");

View file

@ -130,7 +130,7 @@ class CommentList extends Extension {
protected function install() {
global $database;
global $config;
$database->db->Execute("CREATE TABLE `comments` (
$database->Execute("CREATE TABLE `comments` (
`id` int(11) NOT NULL auto_increment,
`image_id` int(11) NOT NULL,
`owner_id` int(11) NOT NULL,
@ -162,7 +162,7 @@ class CommentList extends Extension {
ORDER BY latest DESC
LIMIT ?,?
";
$result = $database->db->Execute($get_threads, array($start, $threads_per_page));
$result = $database->Execute($get_threads, array($start, $threads_per_page));
$total_pages = (int)($database->db->GetOne("SELECT COUNT(distinct image_id) AS count FROM comments") / 10);
@ -257,7 +257,7 @@ class CommentList extends Extension {
global $config;
$html = "";
$result = $database->db->Execute($query, $args);
$result = $database->Execute($query, $args);
while(!$result->EOF) {
$comment = new Comment($result->fields);
$html .= $comment->to_html($trim);
@ -275,7 +275,7 @@ class CommentList extends Extension {
$window = int_escape($config->get_int('comment_window'));
$max = int_escape($config->get_int('comment_limit'));
$result = $database->db->Execute("SELECT * FROM comments WHERE owner_ip = ? ".
$result = $database->Execute("SELECT * FROM comments WHERE owner_ip = ? ".
"AND posted > date_sub(now(), interval ? minute)",
Array($_SERVER['REMOTE_ADDR'], $window));
$recent_comments = $result->RecordCount();
@ -343,7 +343,7 @@ class CommentList extends Extension {
"Akismet thinks that your comment is spam. Try rewriting the comment?"));
}
else {
$database->db->Execute(
$database->Execute(
"INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ".
"VALUES(?, ?, ?, now(), ?)",
array($image_id, $user->id, $_SERVER['REMOTE_ADDR'], $comment));
@ -354,12 +354,12 @@ class CommentList extends Extension {
private function delete_comments($image_id) {
global $database;
$database->db->Execute("DELETE FROM comments WHERE image_id=?", array($image_id));
$database->Execute("DELETE FROM comments WHERE image_id=?", array($image_id));
}
private function delete_comment($comment_id) {
global $database;
$database->db->Execute("DELETE FROM comments WHERE id=?", array($comment_id));
$database->Execute("DELETE FROM comments WHERE id=?", array($comment_id));
}
// }}}
}

View file

@ -75,7 +75,7 @@ class IPBan extends Extension {
protected function install() {
global $database;
global $config;
$database->db->Execute("CREATE TABLE bans (
$database->Execute("CREATE TABLE bans (
id int(11) NOT NULL auto_increment,
ip char(15) default NULL,
date datetime default NULL,
@ -119,14 +119,14 @@ class IPBan extends Extension {
public function add_ip_ban($ip, $reason) {
global $database;
$database->db->Execute(
$database->Execute(
"INSERT INTO bans (ip, reason, date) VALUES (?, ?, now())",
array($ip, $reason));
}
public function remove_ip_ban($ip) {
global $database;
$database->db->Execute("DELETE FROM bans WHERE ip = ?", array($ip));
$database->Execute("DELETE FROM bans WHERE ip = ?", array($ip));
}
// }}}
// admin page HTML {{{

View file

@ -84,7 +84,7 @@ class TagList extends Extension {
global $config;
$tags_min = $config->get_int('tags_min');
$result = $database->db->Execute(
$result = $database->Execute(
"SELECT tag,COUNT(image_id) AS count FROM tags GROUP BY tag HAVING count > ? ORDER BY tag",
array($tags_min));
@ -108,7 +108,7 @@ class TagList extends Extension {
global $config;
$tags_min = $config->get_int('tags_min');
$result = $database->db->Execute(
$result = $database->Execute(
"SELECT tag,COUNT(image_id) AS count FROM tags GROUP BY tag HAVING count > ? ORDER BY tag",
array($tags_min));
@ -135,7 +135,7 @@ class TagList extends Extension {
global $config;
$tags_min = $config->get_int('tags_min');
$result = $database->db->Execute(
$result = $database->Execute(
"SELECT tag,COUNT(image_id) AS count FROM tags GROUP BY tag HAVING count > ? ORDER BY count DESC, tag ASC",
array($tags_min)
);
@ -165,7 +165,7 @@ class TagList extends Extension {
$n = 0;
$html = "";
$result = $database->db->Execute($query, $args);
$result = $database->Execute($query, $args);
while(!$result->EOF) {
$row = $result->fields;
$tag = $row['tag'];