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


PHP RedBean_OODBBean::withCondition方法代码示例

本文整理汇总了PHP中RedBean_OODBBean::withCondition方法的典型用法代码示例。如果您正苦于以下问题:PHP RedBean_OODBBean::withCondition方法的具体用法?PHP RedBean_OODBBean::withCondition怎么用?PHP RedBean_OODBBean::withCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedBean_OODBBean的用法示例。


在下文中一共展示了RedBean_OODBBean::withCondition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: openList

 /**
  * Opens a list and returns the contents of the list.
  * By default a list is interpreted as the own-list of the current bean.
  * If the list begins with the prefix 'shared-' the shared list of the
  * bean will be opened instead. Internal method.
  *
  * @return array
  */
 private function openList()
 {
     $listOfBeans = array();
     $listName = strpos($this->list, 'shared-') === 0 ? 'shared' . ucfirst(substr($this->list, 7)) : 'own' . ucfirst($this->list);
     if ($this->sqlSnippet) {
         if (preg_match('/^(ORDER|GROUP|HAVING|LIMIT|OFFSET|TOP)\\s+/i', ltrim($this->sqlSnippet))) {
             $beans = $this->bean->with($this->sqlSnippet, $this->sqlBindings)->{$listName};
         } else {
             $beans = $this->bean->withCondition($this->sqlSnippet, $this->sqlBindings)->{$listName};
         }
     } else {
         $beans = $this->bean->{$listName};
     }
     foreach ($beans as $listBean) {
         $listOfBeans[] = $listBean->export();
     }
     return $this->resp($listOfBeans);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:26,代码来源:BeanCanResty.php

示例2: findByPath

 /**
  * Returns the bean identified by the RESTful path.
  * For instance:
  *
  *        $user
  *        /site/1/page/3
  *
  * returns page with ID 3 in ownPage of site 1 in ownSite of
  * $user bean.
  *
  * Works with shared lists as well:
  *
  *        $user
  *        /site/1/page/3/shared-ad/4
  *
  * Note that this method will open all intermediate beans so you can
  * attach access control rules to each bean in the path.
  *
  * @param RedBean_OODBBean $bean
  * @param array            $steps  (an array representation of a REST path)
  *
  * @return RedBean_OODBBean
  *
  * @throws RedBean_Exception_Security
  */
 public function findByPath($bean, $steps)
 {
     $numberOfSteps = count($steps);
     if (!$numberOfSteps) {
         return $bean;
     }
     if ($numberOfSteps % 2) {
         throw new RedBean_Exception_Security('Invalid path: needs 1 more element.');
     }
     for ($i = 0; $i < $numberOfSteps; $i += 2) {
         $steps[$i] = trim($steps[$i]);
         if ($steps[$i] === '') {
             throw new RedBean_Exception_Security('Cannot access list.');
         }
         if (strpos($steps[$i], 'shared-') === FALSE) {
             $listName = 'own' . ucfirst($steps[$i]);
             $listType = $this->toolbox->getWriter()->esc($steps[$i]);
         } else {
             $listName = 'shared' . ucfirst(substr($steps[$i], 7));
             $listType = $this->toolbox->getWriter()->esc(substr($steps[$i], 7));
         }
         $list = $bean->withCondition(" {$listType}.id = ? ", array($steps[$i + 1]))->{$listName};
         if (!isset($list[$steps[$i + 1]])) {
             throw new RedBean_Exception_Security('Cannot access bean.');
         }
         $bean = $list[$steps[$i + 1]];
     }
     return $bean;
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:54,代码来源:Finder.php


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