Beispiel #1
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;
 }
Beispiel #2
0
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * Execute
  * 
  * @param  array|ParameterContainerInterface $parameters
  * @return type 
  */
 public function execute($parameters = null)
 {
     if (!$this->isPrepared) {
         $this->prepare();
     }
     if ($parameters !== null) {
         if (is_array($parameters)) {
             $parameters = new ParameterContainer($parameters);
         }
         if (!$parameters instanceof ParameterContainerInterface) {
             throw new \InvalidArgumentException('ParameterContainer expected');
         }
         $this->parameterContainer = $parameters;
     }
     if ($this->parameterContainer) {
         $this->bindParametersFromContainer();
     }
     $resultValue = sqlsrv_execute($this->resource);
     if ($resultValue === false) {
         $errors = sqlsrv_errors();
         // ignore general warnings
         if ($errors[0]['SQLSTATE'] != '01000') {
             throw new \RuntimeException($errors[0]['message']);
         }
     }
     $result = $this->driver->createResult($this->resource);
     return $result;
 }
Beispiel #4
0
 /**
  * Execute
  * 
  * @param  string $sql
  * @return mixed 
  */
 public function execute($sql)
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     $returnValue = sqlsrv_query($this->resource, $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 \RuntimeException($errors[0]['message']);
         }
     }
     $result = $this->driver->createResult($returnValue);
     return $result;
 }