more pdo compat, database bits

This commit is contained in:
Shish 2011-01-03 15:18:24 +00:00
parent 732c9644ec
commit ee3c24117b
7 changed files with 14 additions and 7 deletions

View File

@ -389,6 +389,13 @@ class Database {
return $row[0];
}
/**
* get the ID of the last inserted row
*/
public function get_last_insert_id() {
return $this->get_last_insert_id();
}
/**
* Create a table from pseudo-SQL

View File

@ -611,7 +611,7 @@ class Image {
$tags_ok = true;
foreach($tag_querylets as $tq) {
$tag_ids = $database->db->GetCol(
$tag_ids = $database->get_col(
$database->engine->scoreql_to_sql(
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
),
@ -912,7 +912,7 @@ class Tag {
}
else {
global $database;
$newtags = $database->db->GetCol("SELECT tag FROM tags WHERE tag LIKE ?", array($tag));
$newtags = $database->get_col("SELECT tag FROM tags WHERE tag LIKE ?", array($tag));
if(count($newtags) > 0) {
$resolved = $newtags;
} else {

View File

@ -122,7 +122,7 @@ class AliasEditor extends SimpleExtension {
private function get_alias_csv($database) {
$csv = "";
$aliases = $database->db->GetAssoc("SELECT oldtag, newtag FROM aliases");
$aliases = $database->get_pairs("SELECT oldtag, newtag FROM aliases");
foreach($aliases as $old => $new) {
$csv .= "$old,$new\n";
}

View File

@ -450,7 +450,7 @@ class CommentList extends SimpleExtension {
"INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ".
"VALUES(?, ?, ?, now(), ?)",
array($image_id, $user->id, $_SERVER['REMOTE_ADDR'], $comment));
$cid = $database->db->lastInsertId();
$cid = $database->get_last_insert_id();
log_info("comment", "Comment #$cid added to Image #$image_id");
}
}

View File

@ -250,7 +250,7 @@ class ImageIO extends SimpleExtension {
$image->id = $database->get_one("SELECT id FROM images WHERE hash=?", array($image->hash));
}
else {
$image->id = $database->db->lastInsertId();
$image->id = $database->get_last_insert_id();
}
log_info("image", "Uploaded Image #{$image->id} ({$image->hash})");

View File

@ -312,7 +312,7 @@ class TagList implements Extension {
$tag = str_replace("?", "_", $tag);
$tag_ids = $database->get_col("SELECT id FROM tags WHERE tag LIKE :tag", array("tag"=>$tag));
// $search_tags = array_merge($search_tags,
// $database->db->GetCol("SELECT tag FROM tags WHERE tag LIKE :tag", array("tag"=>$tag)));
// $database->get_col("SELECT tag FROM tags WHERE tag LIKE :tag", array("tag"=>$tag)));
$tag_id_array = array_merge($tag_id_array, $tag_ids);
$tags_ok = count($tag_ids) > 0;
if(!$tags_ok) break;

View File

@ -304,7 +304,7 @@ class UserPage extends SimpleExtension {
$database->Execute(
"INSERT INTO users (name, pass, joindate, email, admin) VALUES (?, ?, now(), ?, ?)",
array($event->username, $hash, $email, $admin));
$uid = $database->db->lastInsertId();
$uid = $database->get_last_insert_id();
log_info("user", "Created User #$uid ({$event->username})");
}