SCORE_STRNORM = lowercase-if-necessary-for-comparison

This commit is contained in:
Shish 2010-02-02 02:13:45 +00:00
parent 8733249a80
commit efac91598c
2 changed files with 11 additions and 8 deletions

View File

@ -77,6 +77,7 @@ class MySQL extends DBEngine {
$data = str_replace("SCORE_BOOL", "ENUM('Y', 'N')", $data); $data = str_replace("SCORE_BOOL", "ENUM('Y', 'N')", $data);
$data = str_replace("SCORE_DATETIME", "DATETIME", $data); $data = str_replace("SCORE_DATETIME", "DATETIME", $data);
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data); $data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
$data = str_replace("SCORE_STRNORM", "", $data);
return $data; return $data;
} }
@ -97,6 +98,7 @@ class PostgreSQL extends DBEngine {
$data = str_replace("SCORE_BOOL", "BOOL", $data); $data = str_replace("SCORE_BOOL", "BOOL", $data);
$data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data); $data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data);
$data = str_replace("SCORE_NOW", "current_time", $data); $data = str_replace("SCORE_NOW", "current_time", $data);
$data = str_replace("SCORE_STRNORM", "lower", $data);
return $data; return $data;
} }
@ -142,6 +144,7 @@ class SQLite extends DBEngine {
$data = str_replace("SCORE_BOOL_N", "'N'", $data); $data = str_replace("SCORE_BOOL_N", "'N'", $data);
$data = str_replace("SCORE_BOOL", "CHAR(1)", $data); $data = str_replace("SCORE_BOOL", "CHAR(1)", $data);
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data); $data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
$data = str_replace("SCORE_STRNORM", "", $data);
$cols = array(); $cols = array();
$extras = ""; $extras = "";
foreach(explode(",", $data) as $bit) { foreach(explode(",", $data) as $bit) {

View File

@ -394,13 +394,11 @@ class Image {
// insert each new tags // insert each new tags
foreach($tags as $tag) { foreach($tags as $tag) {
if($database->engine->name == "pgsql") { $id = $database->db->GetOne(
$query = "SELECT id FROM tags WHERE lower(tag) = lower(?)"; $database->engine->scoreql_to_sql(
} "SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(?)"
else { ),
$query = "SELECT id FROM tags WHERE tag = ?"; array($tag));
}
$id = $database->db->GetOne($query, array($tag));
if(empty($id)) { if(empty($id)) {
// a new tag // a new tag
$database->execute( $database->execute(
@ -418,7 +416,9 @@ class Image {
array($this->id, $id)); array($this->id, $id));
} }
$database->execute( $database->execute(
"UPDATE tags SET count = count + 1 WHERE tag = ?", $database->engine->scoreql_to_sql(
"UPDATE tags SET count = count + 1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(?)"
),
array($tag)); array($tag));
} }