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


PHP AppModel::hasAny方法代码示例

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


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

示例1: array

 /**
  * Sets the active field value in the Search Index data property according
  * to the scope of the Searchable Model record
  *
  * @param AppModel $model
  * @param boolean $created
  */
 function _setScope(&$model, $created)
 {
     // If the Searchable model doesn't have scope, just go back.
     if (empty($this->settings[$model->alias]['scope'])) {
         return;
     }
     // Check whether the Searchable Model scope has actually been set, i.e. the
     // scope data is available in model data. If it is not and the record has
     // not just been created, do not explicitly set the active field in the
     // Search Index data property - i.e. active will remain unchanged.
     $scopeFieldsInModelData = array_intersect_key($this->_modelData[$model->alias], $this->settings[$model->alias]['scope']);
     if (empty($scopeFieldsInModelData) && !$created) {
         return;
     }
     // Find out the scope of the current record in the Searchable Model by
     // checking whether it meets the scope conditions
     $conditions = $this->settings[$model->alias]['scope'] + array($model->primaryKey => $this->_foreignKey);
     $inScope = $model->hasAny($conditions);
     $this->SearchIndex->data['SearchIndex']['active'] = (int) $inScope;
 }
开发者ID:TehTreag,项目名称:cakepackages,代码行数:27,代码来源:searchable.php

示例2: isUniqueInScope

 /**
  * Custom validation for scoped pseudo unique model fields
  *
  * @param AppModel $Model
  * @param array $data
  * @param string $field
  * @return boolean
  * @access public
  */
 public function isUniqueInScope($Model, $data, $field)
 {
     if (empty($data[$field])) {
         trigger_error('SluggableBehavior: missing data for VALIDATING unique scoped field ' . $field . ' in model ' . $Model->name, E_USER_ERROR);
         return false;
     }
     $conditions = array($Model->alias . '.' . $field => $data[$field]);
     if ($Model->id) {
         $conditions[$Model->alias . '.' . $Model->primaryKey] = '!= ' . $Model->id;
     }
     $scope = $this->settings[$Model->alias]['scope'];
     if (empty($Model->data[$Model->alias][$scope])) {
         trigger_error('SluggableBehavior: missing data for VALIDATING over scoped field ' . $scope . ' in model ' . $Model->name, E_USER_ERROR);
         return false;
     }
     $conditions[$Model->alias . '.' . $scope] = $Model->data[$Model->alias][$scope];
     return !$Model->hasAny($conditions);
 }
开发者ID:hadzi,项目名称:brekfarm,代码行数:27,代码来源:sluggable.php


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