mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-05 10:49:37 +02:00
Use latest php-cs-fixer version
This commit is contained in:
parent
356b8f1e43
commit
47a6585c88
298 changed files with 7977 additions and 4559 deletions
|
@ -45,7 +45,9 @@ abstract class database_object
|
|||
$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);
|
||||
|
@ -54,14 +56,15 @@ abstract class database_object
|
|||
$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);
|
||||
|
||||
self::add_to_cache($table_name,$id,$row);
|
||||
|
||||
return $row;
|
||||
|
||||
} // get_info
|
||||
|
||||
/**
|
||||
|
@ -79,10 +82,11 @@ abstract class database_object
|
|||
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; }
|
||||
if (!isset(self::$object_cache[$index])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset(self::$object_cache[$index][$id]);
|
||||
|
||||
} // is_cached
|
||||
|
||||
/**
|
||||
|
@ -98,7 +102,6 @@ abstract class database_object
|
|||
}
|
||||
|
||||
return false;
|
||||
|
||||
} // get_from_cache
|
||||
|
||||
/**
|
||||
|
@ -107,11 +110,12 @@ abstract class database_object
|
|||
*/
|
||||
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;
|
||||
self::$object_cache[$index][$id] = $value;
|
||||
|
||||
} // add_to_cache
|
||||
|
||||
/**
|
||||
|
@ -124,7 +128,6 @@ abstract class database_object
|
|||
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
|
||||
unset(self::$object_cache[$index][$id]);
|
||||
}
|
||||
|
||||
} // remove_from_cache
|
||||
|
||||
/**
|
||||
|
@ -134,7 +137,6 @@ abstract class database_object
|
|||
public static function _auto_init()
|
||||
{
|
||||
self::$_enabled = AmpConfig::get('memory_cache');
|
||||
|
||||
} // _auto_init
|
||||
|
||||
} // end database_object
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue