Commit 2cdb2fe8 authored by Juozas Kaziukenas's avatar Juozas Kaziukenas

Fixed temporary table name

Signed-off-by: 's avatarJuozas Kaziukenas <juozas@juokaz.com>
parent 1b0e2e50
From 1c5ad6a1165035737122b104887117ccb13e99ca Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Mon, 31 May 2010 00:50:27 +0100
Subject: [PATCH] Close connection on __destruct()
---
lib/Doctrine/DBAL/Driver/Sqlsrv/Driver.php | 3 +--
.../DBAL/Driver/Sqlsrv/SqlsrvConnection.php | 5 +++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/Doctrine/DBAL/Driver/Sqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/Sqlsrv/Driver.php
index 2e32b77..78537fb 100644
--- a/lib/Doctrine/DBAL/Driver/Sqlsrv/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/Sqlsrv/Driver.php
@@ -43,6 +43,7 @@ class Driver implements \Doctrine\DBAL\Driver
$connectionInfo = array(
'Database' => $params['dbname'],
+ 'ReturnDatesAsStrings' => true,
);
if (isset($username) && !empty($username) && isset($password) && !empty($password))
@@ -52,8 +53,6 @@ class Driver implements \Doctrine\DBAL\Driver
'PWD' => $password,
);
}
-
- $connectionInfo += array('ReturnDatesAsStrings' => true);
return new SqlsrvConnection($serverName, $connectionInfo);
}
diff --git a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvConnection.php b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvConnection.php
index 75b841a..e94d08e 100644
--- a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvConnection.php
+++ b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvConnection.php
@@ -38,6 +38,11 @@ class SqlsrvConnection implements \Doctrine\DBAL\Driver\Connection
throw SqlsrvException::fromErrorInfo($this->errorInfo());
}
}
+
+ public function __destruct()
+ {
+ sqlsrv_close($this->_dbh);
+ }
public function prepare($prepareString)
{
--
1.6.5.1.1367.gcd48
From c7dc165c2993cbd3656660c8b5484590f3667853 Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Mon, 31 May 2010 00:49:19 +0100
Subject: [PATCH] Fixed affected rows count
---
.../DBAL/Driver/Sqlsrv/SqlsrvStatement.php | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
index f219982..f99dd16 100644
--- a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
+++ b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
@@ -244,6 +244,6 @@ class SqlsrvStatement implements \Doctrine\DBAL\Driver\Statement
*/
public function rowCount()
{
- return sqlsrv_num_rows($this->_sth);
+ return sqlsrv_rows_affected($this->_sth);
}
}
\ No newline at end of file
--
1.6.5.1.1367.gcd48
From 1052b734665d3b8062d3b8cc79fc1a1baf9aae41 Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Mon, 31 May 2010 02:01:19 +0100
Subject: [PATCH] Fixed fetch() and default column values retrieval
---
.../DBAL/Driver/Sqlsrv/SqlsrvStatement.php | 8 +++++++-
lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php | 11 +++++++++--
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
index 1cc8954..92ba91d 100644
--- a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
+++ b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
@@ -211,7 +211,13 @@ class SqlsrvStatement implements \Doctrine\DBAL\Driver\Statement
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle);
}
- return sqlsrv_fetch_array($this->_sth, self::$fetchStyleMap[$fetchStyle]);
+ $result = sqlsrv_fetch_array($this->_sth, self::$fetchStyleMap[$fetchStyle]);
+
+ if (!$result) {
+ return false;
+ } else {
+ return $result;
+ }
}
/**
diff --git a/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
index 981cf2a..fd5afec 100644
--- a/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
@@ -150,17 +150,24 @@ class MsSqlSchemaManager extends AbstractSchemaManager
'unsigned' => (bool) $unsigned,
'fixed' => (bool) $fixed
);
+
+
+ $default = $tableColumn['COLUMN_DEF'];
+
+ while($default != ($default2 = preg_replace("/^\((.*)\)$/", '$1', $default))) {
+ $default = $default2;
+ }
- // @todo
$options = array(
'length' => ((int) $tableColumn['LENGTH'] == 0) ? null : (int) $tableColumn['LENGTH'],
'unsigned' => (bool)$unsigned,
'fixed' => (bool)$fixed,
- 'default' => $tableColumn['COLUMN_DEF'] !== '(NULL)' ? $tableColumn['COLUMN_DEF'] : null,
+ 'default' => $default !== 'NULL' ? $default : null,
'notnull' => (bool) ($tableColumn['IS_NULLABLE'] != 'YES'),
'scale' => $tableColumn['SCALE'],
'precision' => $tableColumn['PRECISION'],
'platformOptions' => array(
+ // @todo
'primary' => false,
'unique' => false,
'autoincrement' => false,
--
1.6.5.1.1367.gcd48
From 869e61ee8171fee90d0788cf6f780d598b26a4d5 Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Mon, 31 May 2010 00:58:05 +0100
Subject: [PATCH] Fixed fetchColumn()
---
.../DBAL/Driver/Sqlsrv/SqlsrvStatement.php | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
index f99dd16..1cc8954 100644
--- a/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
+++ b/lib/Doctrine/DBAL/Driver/Sqlsrv/SqlsrvStatement.php
@@ -236,6 +236,10 @@ class SqlsrvStatement implements \Doctrine\DBAL\Driver\Statement
*/
public function fetchColumn($columnIndex = 0)
{
+ if (sqlsrv_fetch($this->_sth) === false) {
+ throw SqlsrvException::fromErrorInfo($this->errorInfo());
+ }
+
return sqlsrv_get_field($this->_sth, $columnIndex);
}
--
1.6.5.1.1367.gcd48
From ef1c2a58c2d055d9d0845f5bb109ce8a5d0b58ee Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Tue, 8 Jun 2010 00:43:13 +0100
Subject: [PATCH] Fixed identifiers quoting
---
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php | 26 +++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
index 8404ff5..459fb70 100644
--- a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
@@ -98,6 +98,32 @@ class MsSqlPlatform extends AbstractPlatform
/**
* @override
*/
+ public function getColumnDeclarationSQL($name, array $field)
+ {
+ $declaration = parent::getColumnDeclarationSQL($name, $field);
+
+ $name = substr($declaration, 0, strpos($declaration, ' '));
+ $spec = substr($declaration, strpos($declaration, ' ')+1);
+
+ if (strpos($name, '[') === false)
+ {
+ $name = $this->quoteIdentifier($name);
+ }
+
+ return $name . ' ' . $spec;
+ }
+
+ /**
+ * @override
+ */
+ public function quoteIdentifier($str)
+ {
+ return '[' . $str . ']';
+ }
+
+ /**
+ * @override
+ */
public function getDropForeignKeySQL($foreignKey, $table)
{
if ($foreignKey instanceof \Doctrine\DBAL\Schema\ForeignKeyConstraint) {
--
1.6.5.1.1367.gcd48
From 35c662306b0e8664c733db35b1ca46267fe4ebb5 Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Mon, 7 Jun 2010 23:11:48 +0100
Subject: [PATCH] Fixed platform
---
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php | 5 -----
1 files changed, 0 insertions(+), 5 deletions(-)
diff --git a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
index cce3fa5..8404ff5 100644
--- a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
@@ -562,9 +562,4 @@ class MsSqlPlatform extends AbstractPlatform
{
}
-
- protected function initializeDoctrineTypeMappings()
- {
-
- }
}
--
1.6.5.1.1367.gcd48
From 8b59140203d6bc5cb2c877045c896cbd8e65432e Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Mon, 7 Jun 2010 22:10:19 +0100
Subject: [PATCH] Fixed temporary table name
---
lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php | 24 +++++++++++++++++-------
1 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
index 2bc57d0..8404ff5 100644
--- a/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
+++ b/lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
@@ -1,7 +1,5 @@
<?php
/*
- * $Id$
- *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -72,7 +70,7 @@ class MsSqlPlatform extends AbstractPlatform
{
return false;
}
-
+
/**
* create a new database
*
@@ -314,7 +312,7 @@ class MsSqlPlatform extends AbstractPlatform
{
return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
}
-
+
/**
* @override
*/
@@ -376,7 +374,7 @@ class MsSqlPlatform extends AbstractPlatform
return $unsigned . $autoinc;
}
-
+
/**
* @override
*/
@@ -401,7 +399,7 @@ class MsSqlPlatform extends AbstractPlatform
{
return 'TIME';
}
-
+
/**
* @override
*/
@@ -522,13 +520,20 @@ class MsSqlPlatform extends AbstractPlatform
*/
public function getCreateTemporaryTableSnippetSQL()
{
- // @todo change to be a real temporary table
return "CREATE TABLE";
}
/**
* @override
*/
+ public function getTemporaryTableName($tableName)
+ {
+ return '#' . $tableName;
+ }
+
+ /**
+ * @override
+ */
public function getDateTimeFormatString()
{
return 'Y-m-d H:i:s.u';
@@ -552,4 +557,9 @@ class MsSqlPlatform extends AbstractPlatform
{
return 'mssql';
}
+
+ protected function initializeDoctrineTypeMappings()
+ {
+
+ }
}
--
1.6.5.1.1367.gcd48
From aa2b708ed0b08f8be101705026ea449adbbb5b86 Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Tue, 8 Jun 2010 00:44:18 +0100
Subject: [PATCH] Removed PDOSqlsrv connection class
---
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php | 60 ---------------------
lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php | 2 +-
2 files changed, 1 insertions(+), 61 deletions(-)
delete mode 100644 lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
deleted file mode 100644
index 7285bb4..0000000
--- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/*
- * $Id$
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information, see
- * <http://www.doctrine-project.org>.
- */
-
-namespace Doctrine\DBAL\Driver\PDOSqlsrv;
-
-/**
- * Sqlsrv Connection implementation.
- *
- * @since 2.0
- */
-class Connection extends \PDO implements \Doctrine\DBAL\Driver\Connection
-{
- /**
- * Performs the rollback.
- *
- * @override
- */
- public function rollback()
- {
- $this->exec('ROLLBACK TRANSACTION');
- }
-
- /**
- * Performs the commit.
- *
- * @override
- */
- public function commit()
- {
- $this->exec('COMMIT TRANSACTION');
- }
-
- /**
- * Begins a database transaction.
- *
- * @override
- */
- public function beginTransaction()
- {
- $this->exec('BEGIN TRANSACTION');
- }
-}
\ No newline at end of file
diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
index 442c5c1..ea3d88b 100644
--- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
+++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php
@@ -34,7 +34,7 @@ class Driver implements \Doctrine\DBAL\Driver
$driverOptions['Database'] = $params['dbname'];
}
- return new Connection(
+ return new \Doctrine\DBAL\Driver\PDOConnection(
$this->_constructPdoDsn($params),
$username,
$password,
--
1.6.5.1.1367.gcd48
From a5f7b8ea5d1cc6e6c270779b9a7dc6fefb47de20 Mon Sep 17 00:00:00 2001
From: Juozas Kaziukenas <juozas@juokaz.com>
Date: Mon, 31 May 2010 00:23:19 +0100
Subject: [PATCH] Removed testing code for dropDatabase()
---
lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php | 15 ---------------
1 files changed, 0 insertions(+), 15 deletions(-)
diff --git a/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
index 830fb11..981cf2a 100644
--- a/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
+++ b/lib/Doctrine/DBAL/Schema/MsSqlSchemaManager.php
@@ -223,19 +223,4 @@ class MsSqlSchemaManager extends AbstractSchemaManager
{
return $table['name'];
}
-
- /**
- * @override
- */
- public function dropDatabase($name)
- {
- try
- {
- return parent::dropDatabase($name);
- }
- catch (\Exception $e)
- {
- print $e->getMessage();
- }
- }
}
\ No newline at end of file
--
1.6.5.1.1367.gcd48
......@@ -70,7 +70,7 @@ class MsSqlPlatform extends AbstractPlatform
{
return false;
}
/**
* create a new database
*
......@@ -312,7 +312,7 @@ class MsSqlPlatform extends AbstractPlatform
{
return 'SET TRANSACTION ISOLATION LEVEL ' . $this->_getTransactionIsolationLevelSQL($level);
}
/**
* @override
*/
......@@ -374,7 +374,7 @@ class MsSqlPlatform extends AbstractPlatform
return $unsigned . $autoinc;
}
/**
* @override
*/
......@@ -399,7 +399,7 @@ class MsSqlPlatform extends AbstractPlatform
{
return 'TIME';
}
/**
* @override
*/
......@@ -520,10 +520,17 @@ class MsSqlPlatform extends AbstractPlatform
*/
public function getCreateTemporaryTableSnippetSQL()
{
// @todo change to be a real temporary table
return "CREATE TABLE";
}
/**
* @override
*/
public function getTemporaryTableName($tableName)
{
return '#' . $tableName;
}
/**
* @override
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment