本文整理汇总了PHP中AppModel::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::exists方法的具体用法?PHP AppModel::exists怎么用?PHP AppModel::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::exists方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateStatus
/**
* Method for validation of status change flow
*
* @param AppModel $Model
* @param array $data
* @return boolean
* @access public
*/
public function validateStatus($Model, $data)
{
if ($Model->exists() && ($current = $Model->field('status'))) {
return in_array($data['status'], $this->settings[$Model->alias]['status'][$current]);
}
return false;
}
示例2: beforeSave
/**
* beforeSave callback, initializes created_by or modified_by field values
*
* @param AppModel $Model
* @return boolean
* @access public
*/
public function beforeSave($Model)
{
$field = $Model->exists() ? 'modified_by' : 'created_by';
if ($Model->hasField($field)) {
$Model->set($field, $this->_getUserId());
$this->_addToWhitelist($Model, $field);
}
return true;
}
示例3: beforeSave
/**
* beforeSave callback, initializes unique code fields
*
* @param AppModel $Model
* @return boolean
* @access public
*/
public function beforeSave($Model)
{
extract($this->settings[$Model->alias]);
if ($field && !$Model->exists()) {
do {
$token = $this->generateToken($Model, $length, $possible, $notStartWith);
} while ((bool) $Model->find('count', array('conditions' => array($field => $token))));
$Model->set($field, $token);
$this->_addToWhitelist($Model, $field);
}
return true;
}
示例4: exists
/**
* Returns true if there is any row in this table matching the specified
* conditions.
*
* @param array $conditions list of conditions to pass to the query
* @return bool
*/
public function exists($conditions = null)
{
if (!is_array($conditions)) {
return parent::exists($conditions);
}
return (bool) $this->find('count', ['conditions' => $conditions, 'recursive' => -1, 'callbacks' => false]);
}