static function config($key = null, $value = null, $environment = AK_ENVIRONMENT, $unset = false) { if (AkDbSchemaCache::shouldRefresh()) { return false; } static $config; if (!isset($config[$environment])) { $file_name = AkDbSchemaCache::getCacheFileName($environment); $config[$environment] = file_exists($file_name) ? unserialize(file_get_contents($file_name)) : array(); if (AK_LOG_EVENTS) { $Logger = Ak::getLogger(); $Logger->message('Loading cached database settings'); } } if (!is_null($key)) { if (!is_null($value)) { $config[$environment][$key] = $value; } elseif ($unset) { unset($config[$environment][$key]); } return isset($config[$environment][$key]) ? $config[$environment][$key] : false; } return $config[$environment]; }
public function Test_of_loadColumnsSettings() { AkDbSchemaCache::shouldRefresh(false); $AkTestField = new AkTestField(); $AkTestField->loadColumnsSettings(); // Testing database settings cache on session (this might be changed in a future $this->assertEqual($AkTestField->_columnsSettings, AkDbSchemaCache::get('AkTestField_column_settings')); AkDbSchemaCache::shouldRefresh(true); }