Beispiel #1
0
 function &_get($type, $environment = AK_ENVIRONMENT, $uncached = false, $set = null, $var_export = false)
 {
     $false = false;
     if (AkDbSchemaCache::doRefresh() && $set === null) {
         return $false;
     }
     $null = null;
     static $configs = array();
     if ($set !== null) {
         if (!isset($configs[$environment])) {
             $configs[$environment] = array();
         }
         if ($set === false) {
             unset($configs[$environment][$type]);
         } else {
             $configs[$environment][$type] = $set;
         }
         return $null;
     }
     if ($type === true) {
         return isset($configs[$environment]) ? $configs[$environment] : array();
     }
     if (!$uncached && isset($configs[$environment]) && isset($configs[$environment][$type])) {
         return $configs[$environment][$type];
     }
     if ($uncached || !($config = AkDbSchemaCache::_readCache($type, $environment, false, $var_export))) {
         return $false;
     }
     if (!isset($configs[$environment])) {
         $configs[$environment] = array($type => $config);
     } else {
         $configs[$environment][$type] = $config;
     }
     return $configs[$environment][$type];
 }
Beispiel #2
0
/**#@+
* Constants
*/
// Akelos args is a short way to call functions that is only intended for fast prototyping
defined('AK_ENABLE_AKELOS_ARGS') ? null : define('AK_ENABLE_AKELOS_ARGS', false);
// Use setColumnName if available when using set('column_name', $value);
defined('AK_ACTIVE_RECORD_INTERNATIONALIZE_MODELS_BY_DEFAULT') ? null : define('AK_ACTIVE_RECORD_INTERNATIONALIZE_MODELS_BY_DEFAULT', true);
defined('AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS') ? null : define('AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS', false);
defined('AK_ACTIVE_RECORD_ENABLE_CALLBACK_SETTERS') ? null : define('AK_ACTIVE_RECORD_ENABLE_CALLBACK_SETTERS', AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS);
defined('AK_ACTIVE_RECORD_ENABLE_CALLBACK_GETTERS') ? null : define('AK_ACTIVE_RECORD_ENABLE_CALLBACK_GETTERS', AK_ACTIVE_RECORD_ENABLE_AUTOMATIC_SETTERS_AND_GETTERS);
// Forces loading database schema on every call
if (AK_DEV_MODE) {
    AkDbSchemaCache::doRefresh(true);
} else {
    if (AK_ENVIRONMENT == 'testing') {
        AkDbSchemaCache::doRefresh(true);
        define('AK_ACTIVE_RECORD_CACHE_DATABASE_SCHEMA', true);
    }
}
defined('AK_ACTIVE_RECORD_ENABLE_PERSISTENCE') ? null : define('AK_ACTIVE_RECORD_ENABLE_PERSISTENCE', AK_ENVIRONMENT != 'testing');
defined('AK_ACTIVE_RECORD_CACHE_DATABASE_SCHEMA') ? null : define('AK_ACTIVE_RECORD_CACHE_DATABASE_SCHEMA', AK_ACTIVE_RECORD_ENABLE_PERSISTENCE && AK_ENVIRONMENT != 'development');
defined('AK_ACTIVE_RECORD_CACHE_DATABASE_SCHEMA_LIFE') ? null : define('AK_ACTIVE_RECORD_CACHE_DATABASE_SCHEMA_LIFE', 300);
defined('AK_ACTIVE_RECORD_VALIDATE_TABLE_NAMES') ? null : define('AK_ACTIVE_RECORD_VALIDATE_TABLE_NAMES', true);
defined('AK_ACTIVE_RECORD_SKIP_SETTING_ACTIVE_RECORD_DEFAULTS') ? null : define('AK_ACTIVE_RECORD_SKIP_SETTING_ACTIVE_RECORD_DEFAULTS', false);
defined('AK_NOT_EMPTY_REGULAR_EXPRESSION') ? null : define('AK_NOT_EMPTY_REGULAR_EXPRESSION', '/.+/');
defined('AK_EMAIL_REGULAR_EXPRESSION') ? null : define('AK_EMAIL_REGULAR_EXPRESSION', "/^([a-z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-z0-9\\-]+\\.)+))([a-z]{2,4}|[0-9]{1,3})(\\]?)\$/i");
defined('AK_NUMBER_REGULAR_EXPRESSION') ? null : define('AK_NUMBER_REGULAR_EXPRESSION', "/^[0-9]+\$/");
defined('AK_PHONE_REGULAR_EXPRESSION') ? null : define('AK_PHONE_REGULAR_EXPRESSION', "/^([\\+]?[(]?[\\+]?[ ]?[0-9]{2,3}[)]?[ ]?)?[0-9 ()\\-]{4,25}\$/");
defined('AK_DATE_REGULAR_EXPRESSION') ? null : define('AK_DATE_REGULAR_EXPRESSION', "/^(([0-9]{1,2}(\\-|\\/|\\.| )[0-9]{1,2}(\\-|\\/|\\.| )[0-9]{2,4})|([0-9]{2,4}(\\-|\\/|\\.| )[0-9]{1,2}(\\-|\\/|\\.| )[0-9]{1,2})){1}\$/");
defined('AK_IP4_REGULAR_EXPRESSION') ? null : define('AK_IP4_REGULAR_EXPRESSION', "/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\$/");
defined('AK_POST_CODE_REGULAR_EXPRESSION') ? null : define('AK_POST_CODE_REGULAR_EXPRESSION', "/^[0-9A-Za-z  -]{2,9}\$/");
Beispiel #3
0
 function Test_of_loadColumnsSettings()
 {
     $AkTestField = new AkTestField();
     $AkTestField->loadColumnsSettings();
     // Testing database settings cache on session (this might be changed in a future
     AkDbSchemaCache::doRefresh(false);
     $this->assertEqual($AkTestField->_columnsSettings, AkDbSchemaCache::getModelColumnSettings('AkTestField'));
     AkDbSchemaCache::doRefresh(true);
 }