Commit f580f0a2 authored by Juozas Kaziukenas's avatar Juozas Kaziukenas

Added pdo_sqlsrv, sqlsrv drivers and mssql updates

Signed-off-by: 's avatarJuozas Kaziukenas <juozas@juokaz.com>
parent 390717ed
<?php <?php
/* /*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
...@@ -19,17 +21,17 @@ ...@@ -19,17 +21,17 @@
namespace Doctrine\DBAL\Driver\PDOMsSql; namespace Doctrine\DBAL\Driver\PDOMsSql;
use PDO, Doctrine\DBAL\Driver\Connection as DriverConnection;
/** /**
* MsSql Connection implementation. * MsSql Connection implementation.
* *
* @since 2.0 * @since 2.0
*/ */
class Connection extends PDO implements DriverConnection class Connection extends \PDO implements \Doctrine\DBAL\Driver\Connection
{ {
/** /**
* {@inheritdoc} * Performs the rollback.
*
* @override
*/ */
public function rollback() public function rollback()
{ {
...@@ -37,7 +39,9 @@ class Connection extends PDO implements DriverConnection ...@@ -37,7 +39,9 @@ class Connection extends PDO implements DriverConnection
} }
/** /**
* {@inheritdoc} * Performs the commit.
*
* @override
*/ */
public function commit() public function commit()
{ {
...@@ -45,21 +49,12 @@ class Connection extends PDO implements DriverConnection ...@@ -45,21 +49,12 @@ class Connection extends PDO implements DriverConnection
} }
/** /**
* {@inheritdoc} * Begins a database transaction.
*
* @override
*/ */
public function beginTransaction() public function beginTransaction()
{ {
$this->exec('BEGIN TRANSACTION'); $this->exec('BEGIN TRANSACTION');
} }
/**
* {@inheritdoc}
*/
public function lastInsertId($name = null)
{
$stmt = $this->query('SELECT SCOPE_IDENTITY()');
$id = $stmt->fetchColumn();
$stmt->closeCursor();
return $id;
}
} }
\ No newline at end of file
<?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
<?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;
/**
* The PDO-based Sqlsrv driver.
*
* @since 2.0
*/
class Driver implements \Doctrine\DBAL\Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
if (isset($params['dbname'])) {
$driverOptions['Database'] = $params['dbname'];
}
return new Connection(
$this->_constructPdoDsn($params),
$username,
$password,
$driverOptions
);
}
/**
* Constructs the Sqlsrv PDO DSN.
*
* @return string The DSN.
*/
private function _constructPdoDsn(array $params)
{
// TODO: This might need to be revisted once we have access to a sql server
$dsn = 'sqlsrv:(';
if (isset($params['host'])) {
$dsn .= $params['host'];
}
$dsn .= ')';
if (stripos($dsn, '\sqlexpress') !== false)
{
$dsn = str_ireplace('\sqlexpress', '', $dsn);
$dsn .= '\sqlexpress';
}
$dsn = str_ireplace('localhost', 'local', $dsn);
if (isset($params['port']) && !empty($params['port'])) {
$dsn .= ',' . $params['port'];
}
return $dsn;
}
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\SqlsrvPlatform();
}
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\SqlsrvSchemaManager($conn);
}
public function getName()
{
return 'pdo_sqlsrv';
}
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
\ No newline at end of file
<?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\Sqlsrv;
use Doctrine\DBAL\Platforms;
/**
* A Doctrine DBAL driver for the Microsoft SQL Native Client PHP extension.
*
* @since 2.0
* @author Juozas Kaziukenas <juozas@juokaz.com>
*/
class Driver implements \Doctrine\DBAL\Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
$serverName = '';
// construct server name
$serverName = $params['host'];
if (isset($params['port']) && !empty($params['port'])) {
$port = (integer) $params['port'];
$serverName .= ', ' . $port;
}
$connectionInfo = array(
'Database' => $params['dbname'],
);
if (isset($username) && !empty($username) && isset($password) && !empty($password))
{
$connectionInfo += array(
'UID' => $username,
'PWD' => $password,
);
}
$connectionInfo += array('ReturnDatesAsStrings' => true);
return new SqlsrvConnection($serverName, $connectionInfo);
}
public function getDatabasePlatform()
{
return new \Doctrine\DBAL\Platforms\SqlsrvPlatform();
}
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
{
return new \Doctrine\DBAL\Schema\SqlsrvSchemaManager($conn);
}
public function getName()
{
return 'sqlsrv';
}
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
$params = $conn->getParams();
return $params['dbname'];
}
}
\ No newline at end of file
<?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\Sqlsrv;
/**
* Sqlsrv implementation of the Connection interface.
*
* @since 2.0
* @author Juozas Kaziukenas <juozas@juokaz.com>
*/
class SqlsrvConnection implements \Doctrine\DBAL\Driver\Connection
{
private $_dbh;
public function __construct($serverName, array $connectionInfo)
{
$this->_dbh = @sqlsrv_connect($serverName, $connectionInfo);
if (!is_resource($this->_dbh)) {
throw SqlsrvException::fromErrorInfo($this->errorInfo());
}
}
public function prepare($prepareString)
{
return new SqlsrvStatement($this->_dbh, $prepareString);
}
public function query()
{
$args = func_get_args();
$sql = $args[0];
//$fetchMode = $args[1];
$stmt = $this->prepare($sql);
$stmt->execute();
return $stmt;
}
public function quote($input, $type=\PDO::PARAM_STR)
{
return is_numeric($input) ? $input : "'" . str_replace("'", "''", $input) . "'";
}
public function exec($statement)
{
$stmt = $this->prepare($statement);
$stmt->execute();
return $stmt->rowCount();
}
public function lastInsertId($name = null)
{
$id = $this->query('SELECT @@IDENTITY')->fetchColumn();
if (!$id) {
return 1;
}
return $id;
}
public function beginTransaction()
{
if (!sqlsrv_begin_transaction($this->_dbh)) {
throw SqlsrvException::fromErrorInfo($this->errorInfo());
}
return true;
}
public function commit()
{
if (!sqlsrv_commit($this->_dbh)) {
throw SqlsrvException::fromErrorInfo($this->errorInfo());
}
return true;
}
public function rollBack()
{
if (!sqlsrv_rollback($this->_dbh)) {
throw SqlsrvException::fromErrorInfo($this->errorInfo());
}
return true;
}
public function errorCode()
{
$errors = sqlsrv_errors();
if (false === isset($errors[0]['code']))
{
return null;
}
$error = $errors[0];
return $error['code'];
}
public function errorInfo()
{
$errors = sqlsrv_errors();
if (false === isset($errors[0]['message']))
{
return null;
}
return $errors[0];
}
}
\ No newline at end of file
<?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\Sqlsrv;
class SqlsrvException extends \Exception
{
static public function fromErrorInfo($error)
{
return new self($error['message'], $error['code']);
}
}
<?php
/*
* $Id: Interface.php 3882 2008-02-22 18:11:35Z jwage $
*
* 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\Sqlsrv;
use \PDO;
/**
* The Sql server implementation of the Statement interface.
*
* @since 2.0
* @author Juozas Kaziukenas <juozas@juokaz.com>
*/
class SqlsrvStatement implements \Doctrine\DBAL\Driver\Statement
{
/** Statement handle. */
private $_sth;
private $_dbh = null;
private $_query = null;
private static $fetchStyleMap = array(
PDO::FETCH_BOTH => SQLSRV_FETCH_BOTH,
PDO::FETCH_ASSOC => SQLSRV_FETCH_ASSOC,
PDO::FETCH_NUM => SQLSRV_FETCH_NUMERIC
);
private $_paramMap = array();
private $_bindParams = array();
/**
* Creates a new SqlsrvStatement that uses the given connection handle and SQL statement.
*
* @param resource $dbh The connection handle.
* @param string $statement The SQL statement.
*/
public function __construct($dbh, $statement)
{
$this->_dbh = $dbh;
$this->_query = $this->_convertPositionalToNamedPlaceholders($statement);
}
/**
* Sqlsrv doesnt support bamed params and these should be replaced
* to question marks
*
* @param string $statement The SQL statement to convert.
*/
private function _convertPositionalToNamedPlaceholders($statement)
{
// reset bind params
$this->bindParams = array();
// get params count
$param_count = substr_count($statement,'?');
// prepare bind params
if($param_count > 0) {
for ($i = 0; $i < $param_count; $i++)
{
// preapre bind param for later usage
$this->_bindParams[$i] = null;
}
}
else
{
// parse statement and get named bind params
if(preg_match_all('/[= ]:([a-z]+)\b/', $statement, $matches))
{
for($i=0, $c = count($matches[1]); $i < $c; $i++)
{
// preapre bind param for later usage
$this->_bindParams[$i] = null;
// save name for later usage
$this->_paramMap[$matches[1][$i]] = $i + 1;
// replace to question mark (:name => ?)
$statement = str_replace(':' . $matches[1][$i], '?',$statement);
}
}
}
return $statement;
}
/**
* {@inheritdoc}
*/
public function bindValue($param, $value, $type = null)
{
return $this->bindParam($param, $value, $type);
}
/**
* {@inheritdoc}
*/
public function bindParam($column, &$variable, $type = null)
{
$column = isset($this->_paramMap[$column]) ? $this->_paramMap[$column] : $column;
if($column > 0 && $column <= count($this->_bindParams)) {
$this->_bindParams[$column-1] = &$variable;
} else {
throw SqlsrvException::fromErrorInfo(array('message' => "Parameter out of bounds"));
}
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
* @return boolean Returns TRUE on success or FALSE on failure.
*/
public function closeCursor()
{
return sqlsrv_free_stmt($this->_sth);
}
/**
* {@inheritdoc}
*/
public function columnCount()
{
return sqlsrv_num_fields($this->_sth);
}
/**
* {@inheritdoc}
*/
public function errorCode()
{
$errors = sqlsrv_errors();
if (false === isset($errors[0]['code']))
{
return null;
}
$error = $errors[0];
return $error['code'];
}
/**
* {@inheritdoc}
*/
public function errorInfo()
{
$errors = sqlsrv_errors();
if (false === isset($errors[0]['message']))
{
return null;
}
return $errors[0];
}
/**
* {@inheritdoc}
*/
public function execute($params = null)
{
if ($params) {
$hasZeroIndex = isset($params[0]);
foreach ($params as $key => $val) {
if ($hasZeroIndex && is_numeric($key)) {
$this->bindValue($key + 1, $val);
} else {
$this->bindValue($key, $val);
}
}
}
// prepare statement
$this->_sth = sqlsrv_prepare($this->_dbh, $this->_query, $this->_bindParams);
if ( ! $this->_sth) {
throw SqlsrvException::fromErrorInfo($this->errorInfo());
}
$ret = @sqlsrv_execute($this->_sth);
if ( ! $ret) {
throw SqlsrvException::fromErrorInfo($this->errorInfo());
}
return $ret;
}
/**
* {@inheritdoc}
*/
public function fetch($fetchStyle = PDO::FETCH_BOTH)
{
if ( ! isset(self::$fetchStyleMap[$fetchStyle])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle);
}
return sqlsrv_fetch_array($this->_sth, self::$fetchStyleMap[$fetchStyle]);
}
/**
* {@inheritdoc}
*/
public function fetchAll($fetchStyle = PDO::FETCH_BOTH)
{
if ( ! isset(self::$fetchStyleMap[$fetchStyle])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle);
}
$result = array();
while ($row = $this->fetch($fetchStyle)) {
$result[] = $row;
}
return $result;
}
/**
* {@inheritdoc}
*/
public function fetchColumn($columnIndex = 0)
{
return sqlsrv_get_field($this->_sth, $columnIndex);
}
/**
* {@inheritdoc}
*/
public function rowCount()
{
return sqlsrv_num_rows($this->_sth);
}
}
\ No newline at end of file
...@@ -44,6 +44,8 @@ final class DriverManager ...@@ -44,6 +44,8 @@ final class DriverManager
'oci8' => 'Doctrine\DBAL\Driver\OCI8\Driver', 'oci8' => 'Doctrine\DBAL\Driver\OCI8\Driver',
'ibm_db2' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver', 'ibm_db2' => 'Doctrine\DBAL\Driver\IBMDB2\DB2Driver',
'pdo_ibm' => 'Doctrine\DBAL\Driver\PDOIbm\Driver', 'pdo_ibm' => 'Doctrine\DBAL\Driver\PDOIbm\Driver',
'pdo_sqlsrv' => 'Doctrine\DBAL\Driver\PDOSqlsrv\Driver',
'sqlsrv' => 'Doctrine\DBAL\Driver\Sqlsrv\Driver',
); );
/** Private constructor. This class cannot be instantiated. */ /** Private constructor. This class cannot be instantiated. */
......
<?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\Platforms;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\DBALException;
/**
* The SqlsrvPlatform provides the behavior, features and SQL dialect of the
* Microsoft SQL database platform.
*
* @since 2.0
* @author Juozas Kaziukenas <juozas@juokaz.com>
*/
class SqlsrvPlatform extends MsSqlPlatform
{
/**
* Get the platform name for this instance
*
* @return string
*/
public function getName()
{
return 'sqlsrv';
}
}
<?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.phpdoctrine.org>.
*/
namespace Doctrine\DBAL\Schema;
/**
* xxx
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Juozas Kaziukenas <juozas@juokaz.com>
* @version $Revision$
* @since 2.0
*/
class SqlsrvSchemaManager extends MsSqlSchemaManager
{
}
\ No newline at end of file
...@@ -16,13 +16,13 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase ...@@ -16,13 +16,13 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
public function getGenerateTableSql() public function getGenerateTableSql()
{ {
return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
} }
public function getGenerateTableWithMultiColumnUniqueIndexSql() public function getGenerateTableWithMultiColumnUniqueIndexSql()
{ {
return array( return array(
'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX test_foo_bar_uniq (foo, bar))' 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, CONSTRAINT test_foo_bar_uniq UNIQUE (foo, bar))'
); );
} }
...@@ -75,11 +75,11 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase ...@@ -75,11 +75,11 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
$this->_platform->getIntegerTypeDeclarationSQL(array()) $this->_platform->getIntegerTypeDeclarationSQL(array())
); );
$this->assertEquals( $this->assertEquals(
'INT AUTO_INCREMENT', 'INT IDENTITY',
$this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true) $this->_platform->getIntegerTypeDeclarationSQL(array('autoincrement' => true)
)); ));
$this->assertEquals( $this->assertEquals(
'INT AUTO_INCREMENT', 'INT IDENTITY',
$this->_platform->getIntegerTypeDeclarationSQL( $this->_platform->getIntegerTypeDeclarationSQL(
array('autoincrement' => true, 'primary' => true) array('autoincrement' => true, 'primary' => true)
)); ));
......
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