Пример #1
0
 /**
  * Execute
  *
  * @param  ParameterContainer|null $parameters
  * @throws Exception\InvalidQueryException
  * @return Result
  */
 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) {
         $parameters = $this->parameterContainer->getPositionalArray();
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     $resultResource = pg_execute($this->pgsql, $this->statementName, (array) $parameters);
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($resultResource === false) {
         throw new Exception\InvalidQueryException(pg_last_error());
     }
     $result = $this->driver->createResult($resultResource);
     return $result;
 }
Пример #2
0
 /**
  * Execute
  *
  * @param  string $sql
  * @throws Exception\RuntimeException
  * @return mixed
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     if (!$this->driver instanceof Sqlsrv) {
         throw new Exception\RuntimeException('Connection is missing an instance of Sqlsrv');
     }
     if ($this->profiler) {
         $this->profiler->profilerStart($sql);
     }
     $returnValue = sqlsrv_query($this->resource, $sql);
     if ($this->profiler) {
         $this->profiler->profilerFinish($sql);
     }
     // if the returnValue is something other than a Sqlsrv_result, bypass wrapping it
     if ($returnValue === false) {
         $errors = sqlsrv_errors();
         // ignore general warnings
         if ($errors[0]['SQLSTATE'] != '01000') {
             throw new Exception\RuntimeException('An exception occurred while trying to execute the provided $sql', null, new ErrorException($errors));
         }
     }
     $result = $this->driver->createResult($returnValue);
     return $result;
 }
Пример #3
0
 /**
  * Execute
  *
  * @param null $parameters
  * @return Result
  */
 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);
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     set_error_handler(function () {
     }, E_WARNING);
     // suppress warnings
     $response = db2_execute($this->resource, $this->parameterContainer->getPositionalArray());
     restore_error_handler();
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($response === false) {
         throw new Exception\RuntimeException(db2_stmt_errormsg($this->resource));
     }
     $result = $this->driver->createResult($this->resource);
     return $result;
 }
Пример #4
0
 /**
  * Execute
  *
  * @param $sql
  * @return Result
  * @throws Exception\InvalidQueryException
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     if ($this->profiler) {
         $this->profiler->profilerStart($sql);
     }
     $resultResource = $this->resource->query($sql);
     if ($this->profiler) {
         $this->profiler->profilerFinish($sql);
     }
     if ($resultResource === false) {
         $errorInfo = $this->resource->errorInfo();
         throw new Exception\InvalidQueryException($errorInfo[2]);
     }
     $result = $this->driver->createResult($resultResource, $sql);
     return $result;
 }
Пример #5
0
 /**
  * @param  string $sql
  * @throws Exception\InvalidQueryException
  * @return resource|\Zend\Db\ResultSet\ResultSetInterface
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     if ($this->profiler) {
         $this->profiler->profilerStart($sql);
     }
     $resultResource = pg_query($this->resource, $sql);
     if ($this->profiler) {
         $this->profiler->profilerFinish($sql);
     }
     // if the returnValue is something other than a pg result resource, bypass wrapping it
     if ($resultResource === false) {
         throw new Exception\InvalidQueryException(pg_errormessage());
     }
     $resultPrototype = $this->driver->createResult($resultResource === true ? $this->resource : $resultResource);
     return $resultPrototype;
 }
Пример #6
0
 /**
  * Execute
  *
  * @param  ParameterContainer $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);
     }
     $return = $this->resource->execute();
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($return === false) {
         throw new Exception\RuntimeException($this->resource->error);
     }
     if ($this->bufferResults === true) {
         $this->resource->store_result();
         $this->isPrepared = false;
         $buffered = true;
     } else {
         $buffered = false;
     }
     $result = $this->driver->createResult($this->resource, $buffered);
     return $result;
 }
Пример #7
0
 /**
  * @param array $fields
  * @param array $orders
  * @param null|int $limit
  * @param null|int $offset
  *
  * @return ResultSet|ResultSetInterface
  * @throws RuntimeException
  * @throws \Exception
  */
 public function find($fields = [], $orders = [], $limit = null, $offset = null)
 {
     if (!is_array($fields) || !is_array($orders)) {
         throw new \Exception("Wrong input type of parameters !");
     }
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     // apply preSelect features
     //        $this -> featureSet -> apply( 'preSelect', array( $select ) );
     $return = $this->collection->find($this->_where($fields));
     foreach ($orders as $_k => $_v) {
         if (strtolower($_v) == 'desc' || $_v < 0) {
             $orders[$_k] = -1;
         } else {
             $orders[$_k] = 1;
         }
     }
     if (!empty($orders)) {
         $return->sort($this->_orders($orders));
     }
     if ($limit !== null) {
         $return->limit($limit);
     }
     if ($offset !== null) {
         $return->skip($offset);
     }
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($return === false) {
         throw new RuntimeException($this->getDriver()->getConnection()->getDB()->lastError());
     }
     $result = $this->adapter->getDriver()->createResult($return, $this->getTable());
     $resultSet = clone $this->resultSetPrototype;
     $resultSet->initialize($result);
     // apply postSelect features
     //        $this -> featureSet -> apply( 'postSelect', array( $result, $resultSet ) );
     return $resultSet;
 }
Пример #8
0
 /**
  * Execute
  *
  * @param  ParameterContainer $parameters
  * @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->driver->getConnection()->inTransaction()) {
         $ret = @oci_execute($this->resource, OCI_NO_AUTO_COMMIT);
     } else {
         $ret = @oci_execute($this->resource, OCI_COMMIT_ON_SUCCESS);
     }
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($ret === false) {
         $e = oci_error($this->resource);
         throw new Exception\RuntimeException($e['message'], $e['code']);
     }
     $result = $this->driver->createResult($this->resource);
     return $result;
 }
Пример #9
0
 /**
  * Execute
  *
  * @param  string $sql
  * @return Result
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     if ($this->profiler) {
         $this->profiler->profilerStart($sql);
     }
     set_error_handler(function () {
     }, E_WARNING);
     // suppress warnings
     $resultResource = db2_exec($this->resource, $sql);
     restore_error_handler();
     if ($this->profiler) {
         $this->profiler->profilerFinish($sql);
     }
     // if the returnValue is something other than a pg result resource, bypass wrapping it
     if ($resultResource === false) {
         throw new Exception\InvalidQueryException(db2_stmt_errormsg());
     }
     return $this->driver->createResult($resultResource === true ? $this->resource : $resultResource);
 }
Пример #10
0
 /**
  * @param null|array|ParameterContainer $parameters
  * @throws Exception\InvalidQueryException
  * @return Result
  */
 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);
     }
     try {
         //	var_dump($this->resource);
         $this->resource->execute();
     } catch (\PDOException $e) {
         if ($this->profiler) {
             $this->profiler->profilerFinish();
         }
         throw new Exception\InvalidQueryException('Statement could not be executed (' . implode(' - ', $this->resource->errorInfo()) . ')', null, $e);
     }
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     $result = $this->driver->createResult($this->resource, $this);
     return $result;
 }
Пример #11
0
 /**
  * Execute
  *
  * @param  array|ParameterContainer $parameters
  * @throws Exception\RuntimeException
  * @return Result
  */
 public function execute($parameters = null)
 {
     /** END Standard ParameterContainer Merging Block */
     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();
     }
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     $resultValue = sqlsrv_execute($this->resource);
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($resultValue === false) {
         $errors = sqlsrv_errors();
         // ignore general warnings
         if ($errors[0]['SQLSTATE'] != '01000') {
             throw new Exception\RuntimeException($errors[0]['message']);
         }
     }
     $result = $this->driver->createResult($this->resource);
     return $result;
 }
Пример #12
0
 /**
  * Execute
  *
  * @param  string                          $sql
  * @throws Exception\InvalidQueryException
  * @return Result
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     try {
         if ($this->profiler) {
             $this->profiler->profilerStart($sql);
         }
         $resultResource = $this->db->execute($sql);
         if ($this->profiler) {
             $this->profiler->profilerFinish($sql);
         }
         // if the returnValue is something other than a mysqli_result, bypass wrapping it
         if (!$resultResource['ok']) {
             throw new Exception\InvalidQueryException($resultResource['errmsg']);
         }
     } catch (\Exception $e) {
         throw new Exception\InvalidQueryException($ex->getMessage(), $ex->getCode());
     }
     $resultPrototype = $this->driver->createResult($resultResource === true ? $this->resource : $resultResource);
     return $resultResource['retval'];
 }
Пример #13
0
 /**
  * Execute
  *
  * @param null|array|ParameterContainer $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);
     }
     /** END Standard ParameterContainer Merging Block */
     if ($this->profiler) {
         $this->profiler->profilerStart($this);
     }
     $args = $this->parameterContainer->getPositionalArray();
     $argArray = [$this->resource];
     if (!empty($args)) {
         $argArray = array_merge($argArray, $args);
     }
     //die(var_dump($argArray));
     $response = call_user_func_array('ibase_execute', $argArray);
     if ($this->profiler) {
         $this->profiler->profilerFinish();
     }
     if ($response === false) {
         throw new Exception\RuntimeException(ibase_errmsg());
     }
     $result = $this->driver->createResult($response);
     return $result;
 }
Пример #14
0
 /**
  * Execute
  *
  * @param  string $sql
  * @return Result
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     if ($this->profiler) {
         $this->profiler->profilerStart($sql);
     }
     $ociStmt = oci_parse($this->resource, $sql);
     if ($this->inTransaction) {
         $valid = @oci_execute($ociStmt, OCI_NO_AUTO_COMMIT);
     } else {
         $valid = @oci_execute($ociStmt, OCI_COMMIT_ON_SUCCESS);
     }
     if ($this->profiler) {
         $this->profiler->profilerFinish($sql);
     }
     if ($valid === false) {
         $e = oci_error($ociStmt);
         throw new Exception\InvalidQueryException($e['message'], $e['code']);
     }
     $resultPrototype = $this->driver->createResult($ociStmt);
     return $resultPrototype;
 }
Пример #15
0
 /**
  * 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;
 }
Пример #16
0
 /**
  * {@inheritdoc}
  */
 public function stopQuery()
 {
     $this->profiler->profilerFinish();
 }