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


PHP MongoCollection::execute方法代码示例

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


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

示例1: execute

 /**
  * Execute
  *
  * @param  ParameterContainer|array   $parameters
  * @throws Exception\RuntimeException
  * @return mixed
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     /** START Standard ParameterContainer Merging Block */
     if (!$this->parameterContainer instanceof ParameterContainer) {
         if ($parameters instanceof ParameterContainer) {
             $this->parameterContainer = $parameters;
             $parameters = null;
         } else {
             $this->parameterContainer = new ParameterContainer();
         }
     }
     if (is_array($parameters)) {
         $this->parameterContainer->setFromArray($parameters);
     }
     if ($this->parameterContainer->count() > 0) {
         $this->bindParametersFromContainer();
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     if ($this->bufferResults === true) {
         //            $this -> resource -> store_result();
         //            $this -> isPrepared = false;
         $buffered = true;
     } else {
         $buffered = false;
     }
     if ($this->sql instanceof \MongoZend\Db\NoSql\Select) {
         $_order = $this->sql->getOrder();
         //            , $this -> sql->getColumns()
         $return = $this->resource->find($this->sql->getWhere());
         if (!empty($_order)) {
             foreach ($_order as $_k => $_v) {
                 if (strtolower($_v) == 'desc' || $_v < 0) {
                     $_order[$_k] = -1;
                 } else {
                     $_order[$_k] = 1;
                 }
             }
             $return = $return->sort($_order);
         }
         if ($this->sql->getLimit() !== null) {
             $return = $return->limit($this->sql->getLimit());
         }
         if ($this->sql->getOffset() !== null) {
             $return = $return->skip($this->sql->getOffset());
         }
     } elseif ($this->sql instanceof \MongoZend\Db\NoSql\Insert) {
         $_data = $this->sql->getValues();
         $return = $this->resource->insert($_data);
         $buffered = $this->sql->getRawState()['table'];
         $this->driver->getConnection()->storeLastGeneratedValue($buffered, $_data['_id']);
         //          $return = $this -> resource -> update( [ '_id' => $_data[ '_id' ] ], [ '$set' => array( "id" => (string) $_data[ '_id' ] ) ] );
     } elseif ($this->sql instanceof \MongoZend\Db\NoSql\Update) {
         $_data = $this->sql->getSet();
         $_where = $this->sql->getWhere();
         $return = $this->resource->update($_where, $_data);
         $buffered = $this->sql->getRawState()['table'];
         $this->driver->getConnection()->storeLastGeneratedValue($buffered, $_data['_id']);
     } elseif ($this->sql instanceof \MongoZend\Db\NoSql\Delete) {
         $_where = $this->sql->getWhere();
         $return = $this->resource->remove($_where);
         $buffered = $this->sql->getRawState()['table'];
         $this->driver->getConnection()->storeLastGeneratedValue($buffered, null);
     } else {
         $return = $this->resource->execute();
     }
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($return === false) {
         throw new Exception\RuntimeException($this->getDriver()->getConnection()->getDB()->lastError());
     }
     $result = $this->driver->createResult($return, $buffered);
     return $result;
 }
开发者ID:pasechnik,项目名称:mongozend,代码行数:87,代码来源:Statement.php


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