本文整理汇总了PHP中DataMapper::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP DataMapper::exists方法的具体用法?PHP DataMapper::exists怎么用?PHP DataMapper::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataMapper
的用法示例。
在下文中一共展示了DataMapper::exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _remove_other_one_to_one
/**
* Remove Other One-to-One
* Removes other relationships on a one-to-one ITFK relationship
*
* @ignore
* @param string $rf Related field to look at.
* @param DataMapper $object Object to look at.
*/
private function _remove_other_one_to_one($rf, $object)
{
if (!$object->exists()) {
return;
}
$related_properties = $this->_get_related_properties($rf, TRUE);
if (!array_key_exists($related_properties['other_field'], $object->has_one)) {
return;
}
// This should be a one-to-one relationship with an ITFK if we got this far.
$other_column = $related_properties['join_other_as'] . '_id';
$c = get_class($this);
$update = new $c();
$update->where($other_column, $object->id);
if ($this->exists()) {
$update->where('id <>', $this->id);
}
$update->update($other_column, NULL);
}
示例2: throwModelNotFoundException
/**
* Check model for existence and throw NotFoundException exception
*
* @param DataMapper $model
* @param string $message
*/
protected function throwModelNotFoundException(\DataMapper $model, $message = 'Resource not found!')
{
if (!$model->exists()) {
$this->throwNotFoundException($message);
}
}