diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-30 08:15:01 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-11-30 08:15:01 +0000 |
commit | 8f866451bc83acd66f05804488c1a982c9c82736 (patch) | |
tree | 9533af434e0c06654e4edbfceb0e9eb7f447585a /lib/class | |
parent | 4ff16a2c33746a57a2f3bd67c6dc2f1199b19252 (diff) | |
download | ampache-8f866451bc83acd66f05804488c1a982c9c82736.tar.gz ampache-8f866451bc83acd66f05804488c1a982c9c82736.tar.bz2 ampache-8f866451bc83acd66f05804488c1a982c9c82736.zip |
massive speed boost on the standard browse functions
Diffstat (limited to 'lib/class')
-rw-r--r-- | lib/class/browse.class.php | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index cad974ed..020f486b 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -33,6 +33,9 @@ class Browse { public static $start = '0'; public static $total_objects; + // Boolean if this is a simple browse method (use different paging code) + public static $simple_browse; + /** * constructor * This should never be called @@ -121,6 +124,8 @@ class Browse { case 'genre': case 'live_stream': $_SESSION['browse']['type'] = $type; + // Resets the simple browse + self::set_simple_browse(0); break; default: // Rien a faire @@ -193,6 +198,20 @@ class Browse { } // set_start /** + * set_simple_browse + * This sets the current browse object to a 'simple' browse method + * which means use the base query provided and expand from there + */ + public static function set_simple_browse($value) { + + $value = make_bool($value); + self::$simple_browse = $value; + + $_SESSION['browse']['simple'] = $value; + + } // set_simple_browse + + /** * get_saved * This looks in the session for the saved * stuff and returns what it finds @@ -592,19 +611,28 @@ class Browse { */ private static function resort_objects() { - // First pull the objects - $objects = self::get_saved(); + // There are two ways to do this.. the easy way... + // and the vollmer way, hopefully we don't have to + // do it the vollmer way + if (self::$simple_browse) { + $sql = self::get_base_sql(); + } + else { + // First pull the objects + $objects = self::get_saved(); + + // If there's nothing there don't do anything + if (!count($objects)) { return false; } - // If there's nothing there don't do anything - if (!count($objects)) { return false; } + foreach ($objects as $object_id) { + $object_id = Dba::escape($object_id); + $where_sql .= "`id`='$object_id' OR"; + } + $where_sql = rtrim($where_sql,'OR'); - foreach ($objects as $object_id) { - $object_id = Dba::escape($object_id); - $where_sql .= "`id`='$object_id' OR"; + $sql = self::get_base_sql() . ' WHERE ' . $where_sql; } - $where_sql = rtrim($where_sql,'OR'); - $sql = self::get_base_sql() . ' WHERE ' . $where_sql; $order_sql = "ORDER BY "; @@ -628,4 +656,15 @@ class Browse { } // resort_objects + /** + * _auto_init + * this function reloads information back from the session + * it is called on creation of the class + */ + public static function _auto_init() { + + self::$simple_browse = make_bool($_SESSION['browse']['simple']); + + } // _auto_init + } // browse |