aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc/poche/Database.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/poche/Database.class.php')
-rwxr-xr-xinc/poche/Database.class.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/inc/poche/Database.class.php b/inc/poche/Database.class.php
index edc775f5..5b51b507 100755
--- a/inc/poche/Database.class.php
+++ b/inc/poche/Database.class.php
@@ -389,12 +389,15 @@ class Database {
389 return $this->getHandle()->lastInsertId($column); 389 return $this->getHandle()->lastInsertId($column);
390 } 390 }
391 391
392 public function retrieveAllTags($user_id) { 392 public function retrieveAllTags($user_id, $term = null) {
393 $sql = "SELECT DISTINCT tags.* FROM tags 393 $sql = "SELECT DISTINCT tags.*, count(entries.id) AS entriescount FROM tags
394 LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id 394 LEFT JOIN tags_entries ON tags_entries.tag_id=tags.id
395 LEFT JOIN entries ON tags_entries.entry_id=entries.id 395 LEFT JOIN entries ON tags_entries.entry_id=entries.id
396 WHERE entries.content <> '' AND entries.user_id=?"; 396 WHERE entries.content <> '' AND entries.user_id=?
397 $query = $this->executeQuery($sql, array($user_id)); 397 ". (($term) ? "AND lower(tags.value) LIKE ?" : '') ."
398 GROUP BY tags.id, tags.value
399 ORDER BY tags.value";
400 $query = $this->executeQuery($sql, (($term)? array($user_id, strtolower('%'.$term.'%')) : array($user_id) ));
398 $tags = $query->fetchAll(); 401 $tags = $query->fetchAll();
399 402
400 return $tags; 403 return $tags;