/** * Execute * * @param array|ParameterContainer $parameters * @throws Exception\RuntimeException * @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 */ $resultValue = sqlsrv_execute($this->resource); 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; }
/** * 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; }
/** * @param mixed $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 */ try { $this->resource->execute(); } catch (\PDOException $e) { throw new Exception\InvalidQueryException('Statement could not be executed', null, $e); } $result = $this->driver->createResult($this->resource, $this); return $result; }
/** * 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->resource->execute() === 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; }
/** * 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; }
/** * @testdox unit test: Test count() returns the proper count * @covers Zend\Db\Adapter\ParameterContainer::count */ public function testCount() { $this->assertEquals(1, $this->parameterContainer->count()); }
/** * 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; }