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


PHP ContentModel::findOneBy方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:Jobu,项目名称:core,代码行数:101,代码来源:ModuleFormdataListing.php

示例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);
 }
开发者ID:contao-bootstrap,项目名称:core,代码行数:25,代码来源:Helper.php

示例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);
 }
开发者ID:netzmacht,项目名称:contao-bootstrap,代码行数:17,代码来源:Repository.php


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