summaryrefslogtreecommitdiffstats
path: root/lib/class/database_object.abstract.php
diff options
context:
space:
mode:
authordipsol <dipsol@ampache>2009-12-14 08:06:20 +0000
committerdipsol <dipsol@ampache>2009-12-14 08:06:20 +0000
commita7838e2a13cf2f8875a34e122c44c9c923648bc6 (patch)
treea2c3a11be556358a59d38c260a1b40ce7c79dae0 /lib/class/database_object.abstract.php
parent9b3232ba299fbbe6bec922bf7034c005175c9365 (diff)
downloadampache-a7838e2a13cf2f8875a34e122c44c9c923648bc6.tar.gz
ampache-a7838e2a13cf2f8875a34e122c44c9c923648bc6.tar.bz2
ampache-a7838e2a13cf2f8875a34e122c44c9c923648bc6.zip
Replaced almost every dba::query to dba::read or dba::write.
Diffstat (limited to 'lib/class/database_object.abstract.php')
-rw-r--r--lib/class/database_object.abstract.php70
1 files changed, 35 insertions, 35 deletions
diff --git a/lib/class/database_object.abstract.php b/lib/class/database_object.abstract.php
index 50e45f23..c2fd9cc5 100644
--- a/lib/class/database_object.abstract.php
+++ b/lib/class/database_object.abstract.php
@@ -21,42 +21,42 @@
/**
* database_object
* This is a general object that is extended by all of the basic
- * database based objects in ampache. It attempts to do some standard
+ * database based objects in ampache. It attempts to do some standard
* caching for all of the objects to cut down on the database calls
*/
-abstract class database_object {
+abstract class database_object {
- private static $object_cache = array();
+ private static $object_cache = array();
// Statistics for debugging
- public static $cache_hit = 0;
- private static $_enabled = false;
+ public static $cache_hit = 0;
+ private static $_enabled = false;
/**
* get_info
* retrieves the info from the database and puts it in the cache
*/
- public function get_info($id,$table_name='') {
+ public function get_info($id,$table_name='') {
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
// Make sure we've got a real id
- if (!is_numeric($id)) { return array(); }
+ if (!is_numeric($id)) { return array(); }
- if (self::is_cached($table_name,$id)) {
- return self::get_from_cache($table_name,$id);
- }
+ if (self::is_cached($table_name,$id)) {
+ return self::get_from_cache($table_name,$id);
+ }
- $sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
- $db_results = Dba::query($sql);
+ $sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
+ $db_results = Dba::read($sql);
- if (!$db_results) { return array(); }
+ if (!$db_results) { return array(); }
- $row = Dba::fetch_assoc($db_results);
+ $row = Dba::fetch_assoc($db_results);
- self::add_to_cache($table_name,$id,$row);
+ self::add_to_cache($table_name,$id,$row);
- return $row;
+ return $row;
} // get_info
@@ -64,12 +64,12 @@ abstract class database_object {
* is_cached
* this checks the cache to see if the specified object is there
*/
- public static function is_cached($index,$id) {
+ public static function is_cached($index,$id) {
// Make sure we've got some parents here before we dive below
- if (!isset(self::$object_cache[$index])) { return false; }
-
- return isset(self::$object_cache[$index][$id]);
+ if (!isset(self::$object_cache[$index])) { return false; }
+
+ return isset(self::$object_cache[$index][$id]);
} // is_cached
@@ -77,18 +77,18 @@ abstract class database_object {
* get_from_cache
* This attempts to retrive the specified object from the cache we've got here
*/
- public static function get_from_cache($index,$id) {
+ public static function get_from_cache($index,$id) {
// Check if the object is set
if (isset(self::$object_cache[$index])
&& isset(self::$object_cache[$index][$id])
- ) {
-
- self::$cache_hit++;
- return self::$object_cache[$index][$id];
- }
+ ) {
+
+ self::$cache_hit++;
+ return self::$object_cache[$index][$id];
+ }
- return false;
+ return false;
} // get_from_cache
@@ -96,11 +96,11 @@ abstract class database_object {
* add_to_cache
* This adds the specified object to the specified index in the cache
*/
- public static function add_to_cache($index,$id,$data) {
+ public static function add_to_cache($index,$id,$data) {
- if (!self::$_enabled) { return false; }
+ if (!self::$_enabled) { return false; }
- $value = is_null($data) ? false : $data;
+ $value = is_null($data) ? false : $data;
self::$object_cache[$index][$id] = $value;
} // add_to_cache
@@ -110,11 +110,11 @@ abstract class database_object {
* This function clears something from the cache, there are a few places we need to do this
* in order to have things display correctly
*/
- public static function remove_from_cache($index,$id) {
-
- if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
- unset(self::$object_cache[$index][$id]);
- }
+ public static function remove_from_cache($index,$id) {
+
+ if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
+ unset(self::$object_cache[$index][$id]);
+ }
} // remove_from_cache