Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[#2678] Sqlsrv driver incorrectly throwing exception when $sqlOrResource... #3166

Merged
merged 1 commit into from

2 participants

@TwoWholeWorms

This is a fix for issue [#2678]. The Sqlsrv driver is broken out-of-the-box at the moment as the createStatement() method erroneously throws an error when $sqlOrResource is null when it should create a statement object and return that as per the Mysqli driver's equivalent method. I suspect I'm the only person actually using this driver. :)

@TwoWholeWorms

My bad. This is actually a fix for #2885, which came up as a result of a change Ralph made re: #2678.

@ralphschindler ralphschindler merged commit 33a5ef2 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 7 deletions.
  1. +6 −7 library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php
View
13 library/Zend/Db/Adapter/Driver/Sqlsrv/Sqlsrv.php
@@ -128,22 +128,21 @@ public function getConnection()
/**
* @param string|resource $sqlOrResource
- * @throws Exception\InvalidArgumentException
* @return Statement
*/
public function createStatement($sqlOrResource = null)
{
$statement = clone $this->statementPrototype;
- if (is_string($sqlOrResource)) {
- $statement->setSql($sqlOrResource);
+ if ($sqlOrResource instanceof Statement) {
+ $statement->setResource($sqlOrResource);
+ } else {
+ if (is_string($sqlOrResource)) {
+ $statement->setSql($sqlOrResource);
+ }
if (!$this->connection->isConnected()) {
$this->connection->connect();
}
$statement->initialize($this->connection->getResource());
- } elseif (is_resource($sqlOrResource)) {
- $statement->initialize($sqlOrResource); // will check the resource type
- } else {
- throw new Exception\InvalidArgumentException('createStatement() only accepts an SQL string or a Sqlsrv resource');
}
return $statement;
}
Something went wrong with that request. Please try again.