tags(image_id,tag) split into image_tags(image_id,tag_id) and tags(id,tag,count)

git-svn-id: file:///home/shish/svn/shimmie2/trunk@227 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish
2007-07-05 21:30:37 +00:00
parent 9d6becdb6c
commit b6809c3b0a
11 changed files with 75 additions and 34 deletions

View File

@ -1,7 +1,6 @@
<?php
class AutoComplete extends Extension {
// event handling {{{
public function receive_event($event) {
if(is_a($event, 'PageRequestEvent') && ($event->page == "index" || $event->page == "view")) {
global $page;
@ -14,14 +13,12 @@ class AutoComplete extends Extension {
$page->set_data($this->get_completions($event->get_arg(0)));
}
}
// }}}
// do things {{{
private function get_completions($start) {
global $database;
$tags = $database->db->GetCol("SELECT tag,count(image_id) AS count FROM tags WHERE tag LIKE ? GROUP BY tag ORDER BY count DESC", array($start.'%'));
$tags = $database->db->GetCol("SELECT tag,count FROM tags WHERE tag LIKE ? ORDER BY count DESC", array($start.'%'));
return implode("\n", $tags);
}
// }}}
}
add_event_listener(new AutoComplete());
?>