SCORE_STRNORM = lowercase-if-necessary-for-comparison
This commit is contained in:
parent
8733249a80
commit
efac91598c
2 changed files with 11 additions and 8 deletions
|
@ -77,6 +77,7 @@ class MySQL extends DBEngine {
|
|||
$data = str_replace("SCORE_BOOL", "ENUM('Y', 'N')", $data);
|
||||
$data = str_replace("SCORE_DATETIME", "DATETIME", $data);
|
||||
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
|
||||
$data = str_replace("SCORE_STRNORM", "", $data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -97,6 +98,7 @@ class PostgreSQL extends DBEngine {
|
|||
$data = str_replace("SCORE_BOOL", "BOOL", $data);
|
||||
$data = str_replace("SCORE_DATETIME", "TIMESTAMP", $data);
|
||||
$data = str_replace("SCORE_NOW", "current_time", $data);
|
||||
$data = str_replace("SCORE_STRNORM", "lower", $data);
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -142,6 +144,7 @@ class SQLite extends DBEngine {
|
|||
$data = str_replace("SCORE_BOOL_N", "'N'", $data);
|
||||
$data = str_replace("SCORE_BOOL", "CHAR(1)", $data);
|
||||
$data = str_replace("SCORE_NOW", "\"1970-01-01\"", $data);
|
||||
$data = str_replace("SCORE_STRNORM", "", $data);
|
||||
$cols = array();
|
||||
$extras = "";
|
||||
foreach(explode(",", $data) as $bit) {
|
||||
|
|
|
@ -394,13 +394,11 @@ class Image {
|
|||
|
||||
// insert each new tags
|
||||
foreach($tags as $tag) {
|
||||
if($database->engine->name == "pgsql") {
|
||||
$query = "SELECT id FROM tags WHERE lower(tag) = lower(?)";
|
||||
}
|
||||
else {
|
||||
$query = "SELECT id FROM tags WHERE tag = ?";
|
||||
}
|
||||
$id = $database->db->GetOne($query, array($tag));
|
||||
$id = $database->db->GetOne(
|
||||
$database->engine->scoreql_to_sql(
|
||||
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(?)"
|
||||
),
|
||||
array($tag));
|
||||
if(empty($id)) {
|
||||
// a new tag
|
||||
$database->execute(
|
||||
|
@ -418,7 +416,9 @@ class Image {
|
|||
array($this->id, $id));
|
||||
}
|
||||
$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));
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue