本文整理汇总了PHP中ContentModel::findOneBy方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentModel::findOneBy方法的具体用法?PHP ContentModel::findOneBy怎么用?PHP ContentModel::findOneBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContentModel
的用法示例。
在下文中一共展示了ContentModel::findOneBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editSingleRecord
/**
* Edit a record
*/
protected function editSingleRecord()
{
/**
* Prepare URL
*/
$page_get = 'page_fd' . $this->id;
$strUrl = preg_replace('/\\?.*$/', '', urldecode(\Environment::get('request')));
$strUrlParams = '';
$blnQuery = false;
foreach (preg_split('/&(amp;)?/', $_SERVER['QUERY_STRING']) as $fragment) {
if (strlen($fragment)) {
if (strncasecmp($fragment, $this->strDetailKey, strlen($this->strDetailKey)) !== 0 && strncasecmp($fragment, 'act', 3) !== 0 && strncasecmp($fragment, 'order_by', 8) !== 0 && strncasecmp($fragment, 'sort', 4) !== 0 && strncasecmp($fragment, $page_get, strlen($page_get)) !== 0) {
$strUrlParams .= (!$blnQuery ? '' : '&') . $fragment;
$blnQuery = true;
}
}
}
// Check record
if ($this->intRecordId === null || intval($this->intRecordId) < 1) {
unset($_GET[$this->strDetailKey]);
unset($_GET['act']);
$strRed = preg_replace(array('/\\/' . $this->strDetailKey . '\\/' . \Input::get($this->strDetailKey) . '/i', '/' . $this->strDetailKey . '=' . \Input::get($this->strDetailKey) . '/i'), array('', ''), $strUrl) . (strlen($strUrlParams) ? '?' . $strUrlParams : '');
\Controller::redirect($strRed);
}
// Check Owner and Alias
$objOwner = \Database::getInstance()->prepare("SELECT fd_member,alias FROM tl_formdata WHERE id=?")->execute($this->intRecordId);
$varOwner = $objOwner->fetchAssoc();
// Check access
if (!empty($this->efg_list_access) && $this->efg_list_access != 'public') {
if (!in_array(intval($varOwner['fd_member']), $this->arrAllowedOwnerIds)) {
$strRed = preg_replace(array('/\\/' . $this->strDetailKey . '\\/' . \Input::get($this->strDetailKey) . '/i', '/' . $this->strDetailKey . '=' . \Input::get($this->strDetailKey) . '/i', '/act=edit/i'), array('', '', ''), $strUrl) . (strlen($strUrlParams) ? '?' . $strUrlParams : '');
\Controller::redirect($strRed);
}
}
// Check edit access
$blnEditAllowed = false;
if ($this->efg_fe_edit_access == 'none') {
$blnEditAllowed = false;
} elseif ($this->efg_fe_edit_access == 'public') {
$blnEditAllowed = true;
} elseif (!empty($this->efg_fe_edit_access)) {
if (in_array(intval($varOwner['fd_member']), $this->arrAllowedEditOwnerIds)) {
$blnEditAllowed = true;
}
}
if ($blnEditAllowed == false) {
$strRed = preg_replace(array('/\\/' . $this->strDetailKey . '\\/' . \Input::get($this->strDetailKey) . '/i', '/' . $this->strDetailKey . '=' . \Input::get($this->strDetailKey) . '/i', '/act=edit/i'), array('', '', ''), $strUrl) . (strlen($strUrlParams) ? '?' . $strUrlParams : '');
\Controller::redirect($strRed);
}
$intListingId = 0;
if ($this->id) {
$intListingId = intval($this->id);
}
$strForm = '';
$intFormId = 0;
// Fallback template
if (!strlen($this->list_edit_layout)) {
$this->list_edit_layout = 'edit_fd_default';
}
// Get the form
$objCheckRecord = \Database::getInstance()->prepare("SELECT form FROM tl_formdata WHERE id=?")->limit(1)->execute($this->intRecordId);
if ($objCheckRecord->numRows == 1) {
$strForm = $objCheckRecord->form;
}
// Get the ContentElement holding the form
if (strlen($strForm)) {
$objForm = \FormModel::findOneBy('title', $strForm);
if ($objForm !== null) {
$objFormElement = \ContentModel::findOneBy('form', $objForm->id);
}
}
if ($objFormElement === null) {
$this->log("Could not find a ContentElement containing the form \"" . $strForm . "\"", __METHOD__, 'ERROR');
$strRed = preg_replace(array('/\\/' . $this->strDetailKey . '\\/' . \Input::get($this->strDetailKey) . '/i', '/' . $this->strDetailKey . '=' . \Input::get($this->strDetailKey) . '/i', '/act=edit/i'), array('', '', ''), $strUrl) . (strlen($strUrlParams) ? '?' . $strUrlParams : '');
\Controller::redirect($strRed);
}
$this->Template = new \FrontendTemplate($this->list_edit_layout);
$arrRecordFields = array_merge($this->arrBaseFields, $this->arrDetailFields);
$strQuery = "SELECT ";
$strWhere = '';
$strSep = '';
foreach ($arrRecordFields as $field) {
if (in_array($field, $this->arrBaseFields)) {
$strQuery .= $strSep . $field;
$strSep = ', ';
}
if (!empty($this->arrDetailFields) && in_array($field, $this->arrDetailFields)) {
$strQuery .= $strSep . '(SELECT value FROM tl_formdata_details WHERE ff_name="' . $field . '" AND pid=f.id ) AS `' . $field . '`';
$strSep = ', ';
}
}
$strQuery .= " FROM " . $this->list_table . " f";
$strWhere .= (strlen($strWhere) ? " AND " : " WHERE ") . "id=?";
$strQuery .= $strWhere;
$objRecord = \Database::getInstance()->prepare($strQuery)->limit(1)->execute($this->intRecordId);
if ($objRecord->numRows < 1) {
return;
//.........这里部分代码省略.........
示例2: findRelatedElement
/**
* Find related elements of a start element.
*
* @param string|null $type Name of the type. If empty current type is used.
*
* @return \ContentModel|null
*/
public function findRelatedElement($type = null)
{
$model = $this->model;
// invalid call
if ($model->bootstrap_parentId == '' && !$this->isTypeOf(static::TYPE_START)) {
return null;
}
$options = array('order' => 'sorting');
if ($type === null) {
$column = 'bootstrap_parentId';
$values[] = $model->id;
} else {
$column = array('bootstrap_parentId=? ', 'type=?');
$values[] = $model->id;
$values[] = $this->getTypeName($type);
}
return \ContentModel::findOneBy($column, $values, $options);
}
示例3: findPreviousElement
/**
* try to find previous element of same type or specified type
*
* @param Model $model
* @param null $type
*
* @return \Model|null
*/
public static function findPreviousElement(Model $model, $type = null)
{
if ($type === null) {
$type = $model->getType();
}
$column = array('pid=?', 'ptable=?', 'type=?', 'sorting<?');
$values = array($model->pid, $model->ptable, $model->getTypeName($type), $model->sorting);
return \ContentModel::findOneBy($column, $values);
}