本文整理匯總了PHP中DBField::exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBField::exists方法的具體用法?PHP DBField::exists怎麽用?PHP DBField::exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBField
的用法示例。
在下文中一共展示了DBField::exists方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: setValue
/**
* Set the value of this field in various formats.
* Used by {@link DataObject->getField()}, {@link DataObject->setCastedField()}
* {@link DataObject->dbObject()} and {@link DataObject->write()}.
*
* As this method is used both for initializing the field after construction,
* and actually changing its values, it needs a {@link $markChanged}
* parameter.
*
* @param DBField|array $value
* @param array $record Map of values loaded from the database
* @param boolean $markChanged Indicate wether this field should be marked changed.
* Set to FALSE if you are initializing this field after construction, rather
* than setting a new value.
*/
public function setValue($value, $record = null, $markChanged = true)
{
if ($value instanceof NamedLinkField && $value->exists()) {
$this->setPageID($value->getPageID(), $markChanged);
$this->setCustomURL($value->getCustomURL(), $markChanged);
$this->setTitle($value->getTitle(), $markChanged);
$this->setLinkmode($value->getLinkmode(), $markChanged);
} elseif ($record && (isset($record[$this->name . 'PageID']) || isset($record[$this->name . 'CustomURL']) || isset($record[$this->name . 'Title']) || isset($record[$this->name . 'Linkmode']))) {
$this->setPageID(isset($record[$this->name . 'PageID']) ? $record[$this->name . 'PageID'] : null, $markChanged);
$this->setCustomURL(isset($record[$this->name . 'CustomURL']) ? $record[$this->name . 'CustomURL'] : null, $markChanged);
$this->setTitle(isset($record[$this->name . 'Title']) ? $record[$this->name . 'Title'] : null, $markChanged);
$this->setLinkmode(isset($record[$this->name . 'Linkmode']) ? $record[$this->name . 'Linkmode'] : null, $markChanged);
} else {
if (is_array($value)) {
if (array_key_exists('PageID', $value)) {
$this->setPageID($value['PageID'], $markChanged);
}
if (array_key_exists('CustomURL', $value)) {
$this->setCustomURL($value['CustomURL'], $markChanged);
}
if (array_key_exists('Title', $value)) {
$this->setTitle($value['Title'], $markChanged);
}
if (array_key_exists('Linkmode', $value)) {
$this->setLinkmode($value['Linkmode'], $markChanged);
}
} else {
// user_error('Invalid value in LinkField->setValue()', E_USER_ERROR);
}
}
}