safety wrapper for db->GetAll
git-svn-id: file:///home/shish/svn/shimmie2/trunk@690 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
0c639c1861
commit
3e25a08db2
@ -48,7 +48,7 @@ class EventLog extends Extension {
|
||||
$filter_sql = "WHERE $filter = $where";
|
||||
}
|
||||
|
||||
$events = $database->db->GetAll("
|
||||
$events = $database->get_all("
|
||||
SELECT event_log.*,users.name FROM event_log
|
||||
JOIN users ON event_log.owner_id = users.id
|
||||
$filter_sql
|
||||
|
@ -127,7 +127,7 @@ class Image_Hash_Ban extends Extension {
|
||||
public function get_image_hash_bans() {
|
||||
// FIXME: many
|
||||
global $database;
|
||||
$bans = $database->db->GetAll("SELECT * FROM image_bans");
|
||||
$bans = $database->get_all("SELECT * FROM image_bans");
|
||||
if($bans) {return $bans;}
|
||||
else {return array();}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Notes extends Extension {
|
||||
|
||||
if(is_a($event, 'DisplayingImageEvent')) {
|
||||
global $database;
|
||||
$notes = $database->db->GetAll("SELECT * FROM image_notes WHERE image_id = ?", array($event->image->id));
|
||||
$notes = $database->get_all("SELECT * FROM image_notes WHERE image_id = ?", array($event->image->id));
|
||||
$this->theme->display_notes($event->page, $notes);
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class report_image extends Extension {
|
||||
public function get_reported_images() {
|
||||
// FIXME: many
|
||||
global $database;
|
||||
$reportedimages = $database->db->GetAll("SELECT * FROM ReportImage");
|
||||
$reportedimages = $database->get_all("SELECT * FROM ReportImage");
|
||||
if($reportedimages) {return $reportedimages;}
|
||||
else {return array();}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class RSS_Comments extends Extension {
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/xml");
|
||||
|
||||
$comments = $database->db->GetAll("
|
||||
$comments = $database->get_all("
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name,
|
||||
comments.comment as comment, comments.id as comment_id,
|
||||
|
@ -141,7 +141,7 @@ class Tag_History extends Extension {
|
||||
public function get_tag_history_from_id($image_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->db->GetAll("
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
@ -154,7 +154,7 @@ class Tag_History extends Extension {
|
||||
public function get_global_tag_history()
|
||||
{
|
||||
global $database;
|
||||
$row = $database->db->GetAll("
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
|
@ -94,6 +94,17 @@ class Database {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function get_all($query, $args=array()) {
|
||||
$result = $this->db->GetAll($query, $args);
|
||||
if($result === False) {
|
||||
print "SQL Error: " . $this->db->ErrorMsg();
|
||||
print "<br>Query: $query";
|
||||
print "<br>Args: "; print_r($args);
|
||||
exit;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function cache_execute($time, $query, $args=array()) {
|
||||
global $config;
|
||||
if($config->get_bool('db_cache')) {
|
||||
|
@ -205,7 +205,7 @@ class CommentList extends Extension {
|
||||
private function get_recent_comments() {
|
||||
global $config;
|
||||
global $database;
|
||||
$rows = $database->db->GetAll("
|
||||
$rows = $database->get_all("
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name,
|
||||
comments.comment as comment, comments.id as comment_id,
|
||||
@ -227,7 +227,7 @@ class CommentList extends Extension {
|
||||
global $config;
|
||||
global $database;
|
||||
$i_image_id = int_escape($image_id);
|
||||
$rows = $database->db->GetAll("
|
||||
$rows = $database->get_all("
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name,
|
||||
comments.comment as comment, comments.id as comment_id,
|
||||
|
@ -54,7 +54,7 @@ class ET extends Extension {
|
||||
$info['sys_extensions'] = join(', ', $els);
|
||||
|
||||
//$cfs = array();
|
||||
//foreach($database->db->GetAll("SELECT name, value FROM config") as $pair) {
|
||||
//foreach($database->get_all("SELECT name, value FROM config") as $pair) {
|
||||
// $cfs[] = $pair['name']."=".$pair['value'];
|
||||
//}
|
||||
//$info[''] = "Config: ".join(", ", $cfs);
|
||||
|
@ -122,7 +122,7 @@ class IPBan extends Extension {
|
||||
// database {{{
|
||||
private function get_bans() {
|
||||
global $database;
|
||||
$bans = $database->db->GetAll("SELECT * FROM bans");
|
||||
$bans = $database->get_all("SELECT * FROM bans");
|
||||
if($bans) {return $bans;}
|
||||
else {return array();}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ class TagList extends Extension {
|
||||
";
|
||||
$args = array($image->id, $config->get_int('tag_list_length'));
|
||||
|
||||
$tags = $database->db->GetAll($query, $args);
|
||||
$tags = $database->get_all($query, $args);
|
||||
if(count($tags) > 0) {
|
||||
$this->theme->display_related_block($page, $tags);
|
||||
}
|
||||
@ -206,7 +206,7 @@ class TagList extends Extension {
|
||||
";
|
||||
$args = array($config->get_int('tag_list_length'));
|
||||
|
||||
$tags = $database->db->GetAll($query, $args);
|
||||
$tags = $database->get_all($query, $args);
|
||||
if(count($tags) > 0) {
|
||||
$this->theme->display_popular_block($page, $tags);
|
||||
}
|
||||
@ -216,12 +216,17 @@ class TagList extends Extension {
|
||||
global $database;
|
||||
global $config;
|
||||
|
||||
$tags = tag_explode($search);
|
||||
$wild_tags = tag_explode($search);
|
||||
// $search_tags = array();
|
||||
|
||||
$tag_id_array = array();
|
||||
$tags_ok = true;
|
||||
foreach($tags as $tag) {
|
||||
foreach($wild_tags as $tag) {
|
||||
$tag = str_replace("*", "%", $tag);
|
||||
$tag = str_replace("?", "_", $tag);
|
||||
$tag_ids = $database->db->GetCol("SELECT id FROM tags WHERE tag LIKE ?", array($tag));
|
||||
// $search_tags = array_merge($search_tags,
|
||||
// $database->db->GetCol("SELECT tag FROM tags WHERE tag LIKE ?", array($tag)));
|
||||
$tag_id_array = array_merge($tag_id_array, $tag_ids);
|
||||
$tags_ok = count($tag_ids) > 0;
|
||||
if(!$tags_ok) break;
|
||||
@ -247,10 +252,10 @@ class TagList extends Extension {
|
||||
";
|
||||
$args = array($config->get_int('tag_list_length'));
|
||||
|
||||
$tags = $database->db->GetAll($query, $args);
|
||||
$related_tags = $database->get_all($query, $args);
|
||||
print $database->db->ErrorMsg();
|
||||
if(count($tags) > 0) {
|
||||
$this->theme->display_refine_block($page, $tags, $search);
|
||||
if(count($related_tags) > 0) {
|
||||
$this->theme->display_refine_block($page, $related_tags, $wild_tags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user