Line 12 | Line 12 |
---|
*/
namespace phpbb\config;
|
*/
namespace phpbb\config;
|
| use phpbb\cache\driver\driver_interface as cache_interface; use phpbb\db\driver\driver_interface as db_interface;
|
/** * Configuration container class */
|
/** * Configuration container class */
|
class db extends \phpbb\config\config
| class db extends config
|
{ /** * Cache instance
|
{ /** * Cache instance
|
* @var \phpbb\cache\driver\driver_interface
| * @var cache_interface
|
*/ protected $cache;
/** * Database connection
|
*/ protected $cache;
/** * Database connection
|
* @var \phpbb\db\driver\driver_interface
| * @var db_interface
|
*/ protected $db;
| */ protected $db;
|
Line 39 | Line 42 |
---|
/** * Creates a configuration container with a default set of values *
|
/** * Creates a configuration container with a default set of values *
|
* @param \phpbb\db\driver\driver_interface $db Database connection * @param \phpbb\cache\driver\driver_interface $cache Cache instance
| * @param db_interface $db Database connection * @param cache_interface $cache Cache instance
|
* @param string $table Configuration table name */
|
* @param string $table Configuration table name */
|
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, $table)
| public function __construct(db_interface $db, cache_interface $cache, $table)
|
{ $this->db = $db; $this->cache = $cache; $this->table = $table;
|
{ $this->db = $db; $this->cache = $cache; $this->table = $table;
|
| $this->initialise($cache);
parent::__construct($this->config); }
/** * Initialise config with database and/or cached entries * * @param cache_interface $cache */ public function initialise(cache_interface $cache) {
|
if (($config = $cache->get('config')) !== false) { $sql = 'SELECT config_name, config_value
| if (($config = $cache->get('config')) !== false) { $sql = 'SELECT config_name, config_value
|
Line 84 | Line 99 |
---|
$cache->put('config', $cached_config); }
|
$cache->put('config', $cached_config); }
|
parent::__construct($config);
| $this->config = $config;
|
}
/**
| }
/**
|
Line 93 | Line 108 |
---|
* @param String $key The configuration option's name * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached
|
* @param String $key The configuration option's name * @param bool $use_cache Whether this variable should be cached or if it * changes too frequently to be efficiently cached
|
* @return null
| * @return void
|
*/ public function delete($key, $use_cache = true) {
| */ public function delete($key, $use_cache = true) {
|
Line 157 | Line 172 |
---|
$sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array( 'config_name' => $key, 'config_value' => $new_value,
|
$sql = 'INSERT INTO ' . $this->table . ' ' . $this->db->sql_build_array('INSERT', array( 'config_name' => $key, 'config_value' => $new_value,
|
'is_dynamic' => ($use_cache) ? 0 : 1));
| 'is_dynamic' => $use_cache ? 0 : 1));
|
$this->db->sql_query($sql); }
| $this->db->sql_query($sql); }
|