当前位置: 首页>>代码示例>>PHP>>正文


PHP DataMapper::config方法代码示例

本文整理汇总了PHP中DataMapper::config方法的典型用法代码示例。如果您正苦于以下问题:PHP DataMapper::config方法的具体用法?PHP DataMapper::config怎么用?PHP DataMapper::config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataMapper的用法示例。


在下文中一共展示了DataMapper::config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DataMapper

 /**
  * Constructor
  *
  * Initialize DataMapper.
  */
 function DataMapper()
 {
     $this->_assign_libraries();
     $this->_load_languages();
     $this->_load_helpers();
     // Determine model name
     if (empty($this->model)) {
         $this->model = singular(get_class($this));
     }
     // Load stored config settings by reference
     foreach (array_keys(DataMapper::$config) as $key) {
         // Only if they're not already set
         if (empty($this->{$key})) {
             $this->{$key} =& DataMapper::$config[$key];
         }
     }
     // Load model settings if not in common storage
     if (!array_key_exists($this->model, DataMapper::$common)) {
         // If model is 'datamapper' then this is the initial autoload by CodeIgniter
         if ($this->model == 'datamapper') {
             // Load config settings
             $this->config->load('datamapper', TRUE, TRUE);
             // Get and store config settings
             DataMapper::$config = $this->config->item('datamapper');
             return;
         }
         // Determine table name
         if (empty($this->table)) {
             $this->table = plural(get_class($this));
         }
         // Add prefix to table
         $this->table = $this->prefix . $this->table;
         // Convert validation into associative array by field name
         $associative_validation = array();
         foreach ($this->validation as $validation) {
             // Populate associative validation array
             $associative_validation[$validation['field']] = $validation;
         }
         $this->validation = $associative_validation;
         // Get and store the table's field names and meta data
         $fields = $this->db->field_data($this->table);
         // Store only the field names and ensure validation list includes all fields
         foreach ($fields as $field) {
             // Populate fields array
             $this->fields[] = $field->name;
             // Add validation if current field has none
             if (!array_key_exists($field->name, $this->validation)) {
                 $this->validation[$field->name] = array('field' => $field->name, 'label' => '', 'rules' => array());
             }
         }
         // Store common model settings
         DataMapper::$common[$this->model]['table'] = $this->table;
         DataMapper::$common[$this->model]['fields'] = $this->fields;
         DataMapper::$common[$this->model]['validation'] = $this->validation;
     }
     // Load stored common model settings by reference
     foreach (array_keys(DataMapper::$common[$this->model]) as $key) {
         $this->{$key} =& DataMapper::$common[$this->model][$key];
     }
     // Clear object properties to set at default values
     $this->clear();
 }
开发者ID:narendranag,项目名称:Snippets,代码行数:67,代码来源:datamapper.php

示例2: DataMapper

 public function DataMapper($id = NULL)
 {
     $this->_dmz_assign_libraries();
     $this_class = strtolower(get_class($this));
     $is_dmz = $this_class == 'datamapper';
     if ($is_dmz) {
         $this->_load_languages();
         $this->_load_helpers();
     }
     // this is to ensure that singular is only called once per model
     if (isset(DataMapper::$common[DMZ_CLASSNAMES_KEY][$this_class])) {
         $common_key = DataMapper::$common[DMZ_CLASSNAMES_KEY][$this_class];
     } else {
         DataMapper::$common[DMZ_CLASSNAMES_KEY][$this_class] = $common_key = singular($this_class);
     }
     // Determine model name
     if (empty($this->model)) {
         $this->model = $common_key;
     }
     // Load stored config settings by reference
     foreach (DataMapper::$config as $config_key => &$config_value) {
         // Only if they're not already set
         if (property_exists($this, $config_key)) {
             $this->{$config_key} =& $config_value;
         }
     }
     // Load model settings if not in common storage
     if (!isset(DataMapper::$common[$common_key])) {
         // If model is 'datamapper' then this is the initial autoload by CodeIgniter
         if ($is_dmz) {
             // Load config settings
             $this->config->load('datamapper', TRUE, TRUE);
             // Get and store config settings
             DataMapper::$config = $this->config->item('datamapper');
             // now double check that all required config values were set
             foreach (DataMapper::$_dmz_config_defaults as $config_key => $config_value) {
                 if (empty(DataMapper::$config[$config_key])) {
                     DataMapper::$config[$config_key] = $config_value;
                 }
             }
             DataMapper::_load_extensions(DataMapper::$global_extensions, DataMapper::$config['extensions']);
             unset(DataMapper::$config['extensions']);
             return;
         }
         // load language file, if requested and it exists
         if (!empty($this->lang_file_format)) {
             $lang_file = str_replace(array('${model}', '${table}'), array($this->model, $this->table), $this->lang_file_format);
             $deft_lang = $this->config->item('language');
             $idiom = $deft_lang == '' ? 'english' : $deft_lang;
             if (file_exists(APPPATH . 'language/' . $idiom . '/' . $lang_file . '_lang' . EXT)) {
                 $this->lang->load($lang_file, $idiom);
             }
         }
         $loaded_from_cache = FALSE;
         // Load in the production cache for this model, if it exists
         if (!empty(DataMapper::$config['production_cache'])) {
             // check if it's a fully qualified path first
             if (!is_dir($cache_folder = DataMapper::$config['production_cache'])) {
                 // if not, it's relative to the application path
                 $cache_folder = APPPATH . DataMapper::$config['production_cache'];
             }
             if (file_exists($cache_folder) && is_dir($cache_folder) && is_writeable($cache_folder)) {
                 $cache_file = $cache_folder . '/' . $common_key . EXT;
                 if (file_exists($cache_file)) {
                     include $cache_file;
                     if (isset($cache)) {
                         DataMapper::$common[$common_key] =& $cache;
                         unset($cache);
                         // allow subclasses to add initializations
                         if (method_exists($this, 'post_model_init')) {
                             $this->post_model_init(TRUE);
                         }
                         // Load extensions (they are not cacheable)
                         $this->_initiate_local_extensions($common_key);
                         $loaded_from_cache = TRUE;
                     }
                 }
             }
         }
         if (!$loaded_from_cache) {
             // Determine table name
             if (empty($this->table)) {
                 $this->table = strtolower(plural(get_class($this)));
             }
             // Add prefix to table
             $this->table = $this->prefix . $this->table;
             $this->_field_tracking = array('get_rules' => array(), 'matches' => array(), 'intval' => array('id'));
             // Convert validation into associative array by field name
             $associative_validation = array();
             foreach ($this->validation as $name => $validation) {
                 if (is_string($name)) {
                     $validation['field'] = $name;
                 } else {
                     $name = $validation['field'];
                 }
                 // clean up possibly missing fields
                 if (!isset($validation['rules'])) {
                     $validation['rules'] = array();
                 }
                 // Populate associative validation array
//.........这里部分代码省略.........
开发者ID:RVRKC,项目名称:Hackathon_2015,代码行数:101,代码来源:datamapper.php

示例3: DataMapper

 /**
  * Constructor
  *
  * Initialize DataMapper.
  */
 function DataMapper($id = NULL)
 {
     $this->_assign_libraries();
     $this->_load_languages();
     $this->_load_helpers();
     $common_key = singular(get_class($this));
     // Determine model name
     if (empty($this->model)) {
         $this->model = $common_key;
     }
     // Load stored config settings by reference
     foreach (array_keys(DataMapper::$config) as $key) {
         // Only if they're not already set
         if (empty($this->{$key})) {
             $this->{$key} =& DataMapper::$config[$key];
         }
     }
     // Load model settings if not in common storage
     if (!array_key_exists($common_key, DataMapper::$common)) {
         // If model is 'datamapper' then this is the initial autoload by CodeIgniter
         if ($this->model == 'datamapper') {
             // Load config settings
             $this->config->load('datamapper', TRUE, TRUE);
             // Get and store config settings
             DataMapper::$config = $this->config->item('datamapper');
             DataMapper::_load_extensions(DataMapper::$global_extensions, DataMapper::$config['extensions']);
             unset(DataMapper::$config['extensions']);
             return;
         }
         $loaded_from_cache = FALSE;
         // Load in the production cache for this model, if it exists
         if (!empty(DataMapper::$config['production_cache'])) {
             // attempt to load the production cache file
             $cache_folder = APPPATH . DataMapper::$config['production_cache'];
             if (file_exists($cache_folder) && is_dir($cache_folder) && is_writeable($cache_folder)) {
                 $cache_file = $cache_folder . '/' . $common_key . EXT;
                 if (file_exists($cache_file)) {
                     include $cache_file;
                     if (isset($cache)) {
                         DataMapper::$common[$common_key] =& $cache;
                         unset($cache);
                         // allow subclasses to add initializations
                         if (method_exists($this, 'post_model_init')) {
                             $this->post_model_init(TRUE);
                         }
                         // Load extensions (they are not cacheable)
                         $this->_initiate_local_extensions($common_key);
                         $loaded_from_cache = TRUE;
                     }
                 }
             }
         }
         if (!$loaded_from_cache) {
             // Determine table name
             if (empty($this->table)) {
                 $this->table = plural(get_class($this));
             }
             // Add prefix to table
             $this->table = $this->prefix . $this->table;
             // Convert validation into associative array by field name
             $associative_validation = array();
             foreach ($this->validation as $name => $validation) {
                 if (is_string($name)) {
                     $validation['field'] = $name;
                 } else {
                     $name = $validation['field'];
                 }
                 // clean up possibly missing fields
                 if (!isset($validation['rules'])) {
                     $validation['rules'] = array();
                 }
                 if (!isset($validation['label'])) {
                     $validation['label'] = $name;
                 }
                 // TODO: enable Localization of label
                 // Populate associative validation array
                 $associative_validation[$name] = $validation;
             }
             // set up id column, if not set
             if (!isset($associative_validation['id'])) {
                 $associative_validation['id'] = array('field' => 'id', 'label' => 'Identifier', 'rules' => array('integer'), 'get_rules' => array('intval'));
             }
             $this->validation = $associative_validation;
             // Get and store the table's field names and meta data
             $fields = $this->db->field_data($this->table);
             // Store only the field names and ensure validation list includes all fields
             foreach ($fields as $field) {
                 // Populate fields array
                 $this->fields[] = $field->name;
                 // Add validation if current field has none
                 if (!array_key_exists($field->name, $this->validation)) {
                     $this->validation[$field->name] = array('field' => $field->name, 'label' => '', 'rules' => array());
                 }
             }
             // convert simple has_one and has_many arrays into more advanced ones
//.........这里部分代码省略.........
开发者ID:par-orillonsoft,项目名称:CodeIgniter-Standard-DMZ-Project,代码行数:101,代码来源:datamapper.php


注:本文中的DataMapper::config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。