From f2e6d408e3f8b4b029c8694599815047f59d3781 Mon Sep 17 00:00:00 2001 From: resurtm Date: Sat, 11 May 2013 09:40:04 +0600 Subject: [PATCH] MSSQL driver classes moved to the proper location. --- framework/db/mssql/PDO.php | 68 --------------------------- framework/db/mssql/QueryBuilder.php | 19 -------- framework/db/mssql/Schema.php | 93 ------------------------------------- framework/db/mssql/SqlsrvPDO.php | 33 ------------- 4 files changed, 213 deletions(-) delete mode 100644 framework/db/mssql/PDO.php delete mode 100644 framework/db/mssql/QueryBuilder.php delete mode 100644 framework/db/mssql/Schema.php delete mode 100644 framework/db/mssql/SqlsrvPDO.php diff --git a/framework/db/mssql/PDO.php b/framework/db/mssql/PDO.php deleted file mode 100644 index e045d68..0000000 --- a/framework/db/mssql/PDO.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @since 2.0 - */ -class PDO extends \PDO -{ - /** - * Returns last inserted ID value. - * - * @param string|null sequence the sequence name. Defaults to null. - * @return integer last inserted ID value. - */ - public function lastInsertId($sequence = null) - { - return $this->query('SELECT CAST(COALESCE(SCOPE_IDENTITY(), @@IDENTITY) AS bigint)')->fetchColumn(); - } - - /** - * Begin a transaction. - * - * Is is necessary to override PDO's method as MSSQL PDO drivers does not support transactions. - * - * @return boolean - */ - public function beginTransaction() - { - $this->exec('BEGIN TRANSACTION'); - return true; - } - - /** - * Commit a transaction. - * - * Is is necessary to override PDO's method as MSSQL PDO drivers does not support transactions. - * - * @return boolean - */ - public function commit() - { - $this->exec('COMMIT TRANSACTION'); - return true; - } - - /** - * Rollback a transaction. - * - * Is is necessary to override PDO's method as MSSQL PDO drivers does not support transaction. - * - * @return boolean - */ - public function rollBack() - { - $this->exec('ROLLBACK TRANSACTION'); - return true; - } -} diff --git a/framework/db/mssql/QueryBuilder.php b/framework/db/mssql/QueryBuilder.php deleted file mode 100644 index 988758b..0000000 --- a/framework/db/mssql/QueryBuilder.php +++ /dev/null @@ -1,19 +0,0 @@ - - * @since 2.0 - */ -class QueryBuilder extends \yii\db\QueryBuilder -{ - // TODO: mssql driver -} diff --git a/framework/db/mssql/Schema.php b/framework/db/mssql/Schema.php deleted file mode 100644 index 8fc8aea..0000000 --- a/framework/db/mssql/Schema.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @since 2.0 - */ -class Schema extends \yii\db\Schema -{ - /** - * Default schema name to be used. - */ - const DEFAULT_SCHEMA = 'dbo'; - - /** - * @var array mapping from physical column types (keys) to abstract column types (values) - */ - public $typeMap = array( - // TODO: mssql driver - ); - - /** - * @param string $name - * @return TableSchema - */ - public function loadTableSchema($name) - { - return null; - } - - /** - * Quotes a table name for use in a query. - * A simple table name has no schema prefix. - * @param string $name table name. - * @return string the properly quoted table name. - */ - public function quoteSimpleTableName($name) - { - return strpos($name, '[') !== false ? $name : '[' . $name . ']'; - } - - /** - * Quotes a column name for use in a query. - * A simple column name has no prefix. - * @param string $name column name. - * @return string the properly quoted column name. - */ - public function quoteSimpleColumnName($name) - { - return strpos($name, '[') !== false || $name === '*' ? $name : '[' . $name . ']'; - } - - /** - * Creates a query builder for the MSSQL database. - * @return QueryBuilder query builder interface. - */ - public function createQueryBuilder() - { - return new QueryBuilder($this->db); - } - - /** - * Returns all table names in the database. - * This method should be overridden by child classes in order to support this feature - * because the default implementation simply throws an exception. - * @param string $schema the schema of the tables. Defaults to empty string, meaning the current or default schema. - * @return array all table names in the database. The names have NO the schema name prefix. - */ - protected function findTableNames($schema = '') - { - if ('' === $schema) { - $schema = self::DEFAULT_SCHEMA; - } - $sql = "SELECT TABLE_NAME FROM [INFORMATION_SCHEMA].[TABLES] WHERE TABLE_SCHEMA = :schema AND TABLE_TYPE = 'BASE TABLE'"; - $names = $this->db->createCommand($sql, array(':schema' => $schema))->queryColumn(); - if (self::DEFAULT_SCHEMA !== $schema) { - foreach ($names as $index => $name) { - $names[$index] = $schema . '.' . $name; - } - } - return $names; - } -} diff --git a/framework/db/mssql/SqlsrvPDO.php b/framework/db/mssql/SqlsrvPDO.php deleted file mode 100644 index 607d0e4..0000000 --- a/framework/db/mssql/SqlsrvPDO.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @since 2.0 - */ -class SqlsrvPDO extends \PDO -{ - /** - * Returns last inserted ID value. - * - * SQLSRV driver supports PDO::lastInsertId() with one peculiarity: when $sequence value is null - * or empty string it returns empty string. But when parameter is not specified it's working - * as expected and returns actual last inserted ID (like the other PDO drivers). - * - * @param string|null $sequence the sequence name. Defaults to null. - * @return integer last inserted ID value. - */ - public function lastInsertId($sequence = null) - { - return !$sequence ? parent::lastInsertId() : parent::lastInsertId($sequence); - } -}