summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAfterster <afterster@gmail.com>2013-10-31 22:29:18 +0100
committerPaul Arthur <paul.arthur@flowerysong.com>2013-11-05 20:40:13 -0500
commit76bca9785acd884b6a1984f1830effa2a0d6a2da (patch)
tree37e413cfde3435614a6949646c6970f04bbbfee0 /lib
parentc097a72952af5f6f9fd2ad9f60398365f49c99c6 (diff)
downloadampache-76bca9785acd884b6a1984f1830effa2a0d6a2da.tar.gz
ampache-76bca9785acd884b6a1984f1830effa2a0d6a2da.tar.bz2
ampache-76bca9785acd884b6a1984f1830effa2a0d6a2da.zip
Add paging on Tag::get_tag_objects
Diffstat (limited to 'lib')
-rw-r--r--lib/class/tag.class.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php
index 03c44ed0..bf5919f4 100644
--- a/lib/class/tag.class.php
+++ b/lib/class/tag.class.php
@@ -412,15 +412,19 @@ class Tag extends database_object {
* get_tag_objects
* This gets the objects from a specified tag and returns an array of object ids, nothing more
*/
- public static function get_tag_objects($type,$tag_id) {
+ public static function get_tag_objects($type,$tag_id,$count='',$offset='') {
if (!self::validate_type($type)) { return array(); }
-
- $tag_id = Dba::escape($tag_id);
+
+ if ($count) {
+ $limit_sql = "LIMIT ";
+ if ($offset) $limit_sql .= intval($offset) . ',';
+ $limit_sql .= intval($count);
+ }
$sql = "SELECT DISTINCT `tag_map`.`object_id` FROM `tag_map` " .
- "WHERE `tag_map`.`tag_id`='$tag_id' AND `tag_map`.`object_type`='$type'";
- $db_results = Dba::read($sql);
+ "WHERE `tag_map`.`tag_id` = ? AND `tag_map`.`object_type` = ? $limit_sql";
+ $db_results = Dba::read($sql, array($tag_id, $type));
$results = array();
@@ -438,13 +442,15 @@ class Tag extends database_object {
* This is a non-object non type depedent function that just returns tags
* we've got, it can take filters (this is used by the tag cloud)
*/
- public static function get_tags($limit,$filters=array()) {
+ public static function get_tags($limit = 0,$filters=array()) {
$sql = "SELECT `tag_map`.`tag_id`,COUNT(`tag_map`.`object_id`) AS `count` " .
"FROM `tag_map` " .
"LEFT JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " .
- "GROUP BY `tag`.`name` ORDER BY `count` DESC " .
- "LIMIT $limit";
+ "GROUP BY `tag`.`name` ORDER BY `count` DESC ";
+ if ($limit >0) {
+ $sql .= " LIMIT $limit";
+ }
$db_results = Dba::read($sql);
$results = array();