more sqlite fixes
This commit is contained in:
parent
4e4f0be4e5
commit
35cc1aad48
@ -255,13 +255,25 @@ class Image {
|
|||||||
|
|
||||||
// insert each new tags
|
// insert each new tags
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
$this->database->execute(
|
$id = $this->database->db->GetOne(
|
||||||
"INSERT IGNORE INTO tags(tag) VALUES (?)",
|
"SELECT id FROM tags WHERE tag = ?",
|
||||||
array($tag));
|
array($tag));
|
||||||
$this->database->execute(
|
if(empty($id)) {
|
||||||
"INSERT INTO image_tags(image_id, tag_id) ".
|
// a new tag
|
||||||
"VALUES(?, (SELECT id FROM tags WHERE tag = ?))",
|
$this->database->execute(
|
||||||
array($this->id, $tag));
|
"INSERT INTO tags(tag) VALUES (?)",
|
||||||
|
array($tag));
|
||||||
|
$this->database->execute(
|
||||||
|
"INSERT INTO image_tags(image_id, tag_id)
|
||||||
|
VALUES(?, (SELECT id FROM tags WHERE tag = ?))",
|
||||||
|
array($this->id, $tag));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// user of an existing tag
|
||||||
|
$this->database->execute(
|
||||||
|
"INSERT INTO image_tags(image_id, tag_id) VALUES(?, ?)",
|
||||||
|
array($this->id, $id));
|
||||||
|
}
|
||||||
$this->database->execute(
|
$this->database->execute(
|
||||||
"UPDATE tags SET count = count + 1 WHERE tag = ?",
|
"UPDATE tags SET count = count + 1 WHERE tag = ?",
|
||||||
array($tag));
|
array($tag));
|
||||||
|
@ -210,7 +210,7 @@ class TagList implements Extension {
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
$query = "
|
$query = "
|
||||||
SELECT COUNT(it3.image_id) as count, t3.tag AS tag
|
SELECT COUNT(it3.image_id) as calc_count, t3.tag AS tag
|
||||||
FROM
|
FROM
|
||||||
image_tags AS it1,
|
image_tags AS it1,
|
||||||
image_tags AS it2,
|
image_tags AS it2,
|
||||||
@ -226,7 +226,7 @@ class TagList implements Extension {
|
|||||||
AND t1.id = it1.tag_id
|
AND t1.id = it1.tag_id
|
||||||
AND t3.id = it3.tag_id
|
AND t3.id = it3.tag_id
|
||||||
GROUP BY it3.tag_id
|
GROUP BY it3.tag_id
|
||||||
ORDER BY count DESC
|
ORDER BY calc_count DESC
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
";
|
";
|
||||||
$args = array($image->id, $config->get_int('tag_list_length'));
|
$args = array($image->id, $config->get_int('tag_list_length'));
|
||||||
|
@ -40,7 +40,7 @@ class TagListTheme extends Themelet {
|
|||||||
$tag = $row['tag'];
|
$tag = $row['tag'];
|
||||||
$h_tag = html_escape($tag);
|
$h_tag = html_escape($tag);
|
||||||
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
||||||
$count = $row['count'];
|
$count = $row['calc_count'];
|
||||||
if($n++) $html .= "\n<br/>";
|
if($n++) $html .= "\n<br/>";
|
||||||
if(!is_null($config->get_string('info_link'))) {
|
if(!is_null($config->get_string('info_link'))) {
|
||||||
$link = str_replace('$tag', $tag, $config->get_string('info_link'));
|
$link = str_replace('$tag', $tag, $config->get_string('info_link'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user