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


PHP AppController::loadModel方法代码示例

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


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

示例1: array

 /**
  * Return a conditions array to pass for instance to the paginate method of the calling controller
  *
  * @access public
  */
 function get_filter()
 {
     $this->_prepareFilter();
     $filter = array();
     if (isset($this->controller->data) && count($this->controller->data) > 0) {
         //Loop for models
         foreach ($this->controller->data as $model_name => $field_values) {
             if ($model_name == self::MODEL_TECHNICAL || $model_name == '_Token') {
                 continue;
             }
             $start_end_pairs = array();
             foreach ($field_values as $field_name => $value) {
                 /*
                  * If the linked Model is not loaded yet, tries to load it
                  */
                 if (!isset($this->controller->{$model_name})) {
                     $this->controller->loadModel($model_name);
                 }
                 if (isset($this->controller->{$model_name}) || array_key_exists($field_name, $this->alias_fields)) {
                     $build_from_to = false;
                     $field_wo_prefix = null;
                     if ($this->startsWith($field_name, self::START_PREFIX)) {
                         $field_wo_prefix = substr($field_name, strlen(self::START_PREFIX));
                         if (!array_key_exists($field_wo_prefix, $start_end_pairs)) {
                             $start_end_pairs[$field_wo_prefix] = array();
                         }
                         $start_end_pairs[$field_wo_prefix]['start'] = $value;
                         if (isset($start_end_pairs[$field_wo_prefix]['end'])) {
                             $build_from_to = true;
                         }
                     } elseif ($this->startsWith($field_name, self::END_PREFIX)) {
                         $field_wo_prefix = substr($field_name, strlen(self::END_PREFIX));
                         if (!array_key_exists($field_wo_prefix, $start_end_pairs)) {
                             $start_end_pairs[$field_wo_prefix] = array();
                         }
                         $start_end_pairs[$field_wo_prefix]['end'] = $value;
                         if (isset($start_end_pairs[$field_wo_prefix]['start'])) {
                             $build_from_to = true;
                         }
                     }
                     if ($build_from_to) {
                         $filter = $this->build_from_to_filter($filter, $model_name, $field_wo_prefix, $start_end_pairs);
                     } else {
                         if (!empty($value) && is_array($value)) {
                             $filter = $this->build_many_value_filter($filter, $model_name, $field_name, $value);
                         } else {
                             if (strlen($value) > 0 && !$this->startsWith($field_name, self::START_PREFIX) && !$this->startsWith($field_name, self::END_PREFIX)) {
                                 $filter = $this->build_one_value_filter($filter, $model_name, $field_name, $value);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $filter;
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:62,代码来源:alaxos_filter.php

示例2: auto_clean_logs

 public function auto_clean_logs()
 {
     if (isset($this->days_to_keep_logs)) {
         if (!isset($this->controller->Log)) {
             $this->controller->loadModel('Alaxos.Log');
         }
         if (!$this->controller->Log->deleteAll(array('Log.created < ' => date('Y-m-d H:i:s', strtotime('-' . $this->days_to_keep_logs . ' days')), 'NOT' => array('Log.log_category_id' => $this->log_categories_to_keep)), false, false)) {
             $this->controller->Session->setFlash(___('a log record could not be saved', true), 'flash_error');
         }
     }
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:11,代码来源:alaxos_logger.php

示例3: array

 function admin_configurations()
 {
     parent::loadModel('Option');
     $stitle = $this->Option->getOption('site_title');
     $title = $this->Option->getOption('title');
     $taglines = $this->Option->getOption('taglines');
     $viewlogo = $this->Option->getOption('viewlogo');
     $themes = $this->Option->getOption('theme');
     if (!empty($this->data)) {
         if ($title !== false && $title == null) {
             //do save
             $this->Option->setOption('title', $this->data['Option']['title']);
         } else {
             //do update
             $this->Option->setOption('title', $this->data['Option']['title'], false);
         }
         if ($stitle !== false && $stitle == null) {
             //do save
             $this->Option->setOption('site_title', $this->data['Option']['stitle']);
         } else {
             //do update
             $this->Option->setOption('site_title', $this->data['Option']['stitle'], false);
         }
         $taglines_val = array($this->data['Option'][0]['description'], $this->data['Option'][1]['description'], $this->data['Option'][2]['description'], $this->data['Option'][3]['description']);
         if ($taglines !== false && $taglines == null) {
             //do save
             $this->Option->setOption('taglines', $taglines_val);
         } else {
             //do update
             $this->Option->setOption('taglines', $taglines_val, false);
         }
         if ($viewlogo !== false && $viewlogo == null) {
             //do save
             $this->Option->setOption('viewlogo', $this->data['Option']['viewlogo']);
         } else {
             //do update
             $this->Option->setOption('viewlogo', $this->data['Option']['viewlogo'], false);
         }
         if ($themes !== false && $themes == null) {
             //do save
             $this->Option->setOption('theme', $this->data['Option']['theme']);
         } else {
             //do update
             $this->Option->setOption('theme', $this->data['Option']['theme'], false);
         }
         $this->Session->setFlash(__('Options Save!', true));
         $this->redirect($this->referer());
     }
     $this->set(compact('title', 'stitle', 'taglines', 'viewlogo', 'themes'));
 }
开发者ID:kevinmel2000,项目名称:Study-Buddy---CakePHP-Quiz-System,代码行数:50,代码来源:dashboards_controller.php

示例4: get_existing_user

 /**
  * Tries to find an already existing user in the database corresponding to the Shibboleth logged user
  *
  * @return Model
  */
 public function get_existing_user()
 {
     if ($this->has_shibboleth_session()) {
         $shibboleth_uid = $this->get_shibboleth_uid();
         if (isset($shibboleth_uid) && strlen($shibboleth_uid) > 0) {
             /*
              * Tries to find a Model in the database having this external uid
              */
             if (!isset($this->controller->{$this->user_model_name})) {
                 $this->controller->loadModel($this->user_model_name);
             }
             if (isset($this->authentication_type_fieldname) && isset($this->default_authentication_type_value)) {
                 $user = $this->controller->{$this->user_model_name}->find('first', array('conditions' => array($this->get_external_uid_fieldname() => $shibboleth_uid, $this->get_authentication_type_fieldname() => $this->default_authentication_type_value)));
             } else {
                 $user = $this->controller->{$this->user_model_name}->find('first', array('conditions' => array($this->get_external_uid_fieldname() => $shibboleth_uid)));
             }
             return $user;
         }
     } else {
         return null;
     }
 }
开发者ID:shashin62,项目名称:abc_audit,代码行数:27,代码来源:shibboleth_authenticator.php

示例5: initialize

 function initialize($controller, $settings = array())
 {
     $this->controller = $controller;
     $this->controller->loadModel("Member");
     $this->controller->loadModel("Country");
 }
开发者ID:redhattaccoss,项目名称:Qalanjo,代码行数:6,代码来源:information_merger.php

示例6:

 function _getOption($name)
 {
     $value = null;
     if ($this->_isTableExists('options')) {
         parent::loadModel('Options');
         $options = $this->Options->findByName($name);
         $value = $options['Options']['value'];
     }
     return $value;
 }
开发者ID:kevinmel2000,项目名称:Study-Buddy---CakePHP-Quiz-System,代码行数:10,代码来源:install_controller.php


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