From 6f52325abecad238b4c0a3097b0d849bf685adce Mon Sep 17 00:00:00 2001 From: tino Date: Fri, 18 Oct 2013 11:21:47 +0200 Subject: Fix on sqlsrv_forge drop_table --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system/database/drivers/sqlsrv/sqlsrv_forge.php') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index cc88ec5ca..d800c5074 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -60,7 +60,14 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _drop_table($table) { - return "DROP TABLE ".$this->db->_escape_identifiers($table); + $sql = ''; + $sql = "IF (EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = '"; + $sql .= $this->db->_escape_identifiers($table)."')) DROP TABLE [dbo].["; + $sql .= $this->db->_escape_identifiers($table).']'; + return $sql; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 1f71da710a84e6bf2d348bd17ffcc7b5023f13c9 Mon Sep 17 00:00:00 2001 From: blowdoof Date: Fri, 18 Oct 2013 15:58:04 +0200 Subject: Style correction --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'system/database/drivers/sqlsrv/sqlsrv_forge.php') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index d800c5074..2940beb9b 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -61,12 +61,12 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { function _drop_table($table) { $sql = ''; - $sql = "IF (EXISTS (SELECT * - FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_SCHEMA = 'dbo' - AND TABLE_NAME = '"; - $sql .= $this->db->_escape_identifiers($table)."')) DROP TABLE [dbo].["; - $sql .= $this->db->_escape_identifiers($table).']'; + $sql = "IF (EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = '"; + $sql .= $this->db->_escape_identifiers($table)."')) DROP TABLE [dbo].["; + $sql .= $this->db->_escape_identifiers($table).']'; return $sql; } -- cgit v1.2.3-24-g4f1b From 898683f95b1b1344a9475647cfe2af285af5f163 Mon Sep 17 00:00:00 2001 From: blowdoof Date: Fri, 18 Oct 2013 16:08:08 +0200 Subject: removed unnecessary assignment --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system/database/drivers/sqlsrv/sqlsrv_forge.php') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 2940beb9b..a5adcbe95 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -60,7 +60,6 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _drop_table($table) { - $sql = ''; $sql = "IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' -- cgit v1.2.3-24-g4f1b From 84b053906da253dbe2fa63a409c2559f3af8ef69 Mon Sep 17 00:00:00 2001 From: blowdoof Date: Fri, 18 Oct 2013 16:39:58 +0200 Subject: Bugfix on the sqlsrv forge driver create_table function --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'system/database/drivers/sqlsrv/sqlsrv_forge.php') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index a5adcbe95..289dfa6ab 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -60,13 +60,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _drop_table($table) { - $sql = "IF (EXISTS (SELECT * + return = "IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' - AND TABLE_NAME = '"; - $sql .= $this->db->_escape_identifiers($table)."')) DROP TABLE [dbo].["; - $sql .= $this->db->_escape_identifiers($table).']'; - return $sql; + AND TABLE_NAME = '".$table."')) DROP TABLE [dbo].[".$table."]"; } // -------------------------------------------------------------------- @@ -84,14 +81,15 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { - $sql = 'CREATE TABLE '; - + $sql = ''; if ($if_not_exists === TRUE) { - $sql .= 'IF NOT EXISTS '; + $sql = "IF (NOT EXISTS (SELECT * + FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA = 'dbo' + AND TABLE_NAME = "; } - - $sql .= $this->db->_escape_identifiers($table)." ("; + $sql .= $this->db->_escape_identifiers($table).")) CREATE TABLE ".$this->db->_escape_identifiers($table)." ("; $current_field_count = 0; foreach ($fields as $field=>$attributes) @@ -137,7 +135,7 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { if (array_key_exists('AUTO_INCREMENT', $attributes) && $attributes['AUTO_INCREMENT'] === TRUE) { - $sql .= ' AUTO_INCREMENT'; + $sql .= ' IDENTITY(1,1)'; } } -- cgit v1.2.3-24-g4f1b From 18d6090a7ead8c93d2513e3b034cd1a994ed3c2f Mon Sep 17 00:00:00 2001 From: blowdoof Date: Fri, 18 Oct 2013 16:42:53 +0200 Subject: Bugfix on the sqlsrv forge driver rename_table function --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'system/database/drivers/sqlsrv/sqlsrv_forge.php') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 289dfa6ab..e65e46116 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -241,12 +241,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _rename_table($table_name, $new_table_name) { - // I think this syntax will work, but can find little documentation on renaming tables in MSSQL - $sql = 'ALTER TABLE '.$this->db->_protect_identifiers($table_name)." RENAME TO ".$this->db->_protect_identifiers($new_table_name); - return $sql; + return 'EXEC sp_rename '.$this->db->_protect_identifiers($table_name).", ".$this->db->_protect_identifiers($new_table_name); } } -/* End of file mssql_forge.php */ -/* Location: ./system/database/drivers/mssql/mssql_forge.php */ \ No newline at end of file +/* End of file sqlsrv_forge.php */ +/* Location: ./system/database/drivers/sqlsrv/sqlsrv_forge.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 9c5c490bdc61ebd27593577480ec484f0b0f6367 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Dec 2013 12:51:42 +0200 Subject: Fix some spacing issues from PR #2689 --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'system/database/drivers/sqlsrv/sqlsrv_forge.php') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index e65e46116..286977c52 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -60,10 +60,8 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _drop_table($table) { - return = "IF (EXISTS (SELECT * - FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_SCHEMA = 'dbo' - AND TABLE_NAME = '".$table."')) DROP TABLE [dbo].[".$table."]"; + return "IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = '" + .$table."')) DROP TABLE [dbo].[".$table."]"; } // -------------------------------------------------------------------- @@ -81,13 +79,10 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _create_table($table, $fields, $primary_keys, $keys, $if_not_exists) { - $sql = ''; + $sql = ''; if ($if_not_exists === TRUE) { - $sql = "IF (NOT EXISTS (SELECT * - FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_SCHEMA = 'dbo' - AND TABLE_NAME = "; + $sql = "IF (NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = "; } $sql .= $this->db->_escape_identifiers($table).")) CREATE TABLE ".$this->db->_escape_identifiers($table)." ("; $current_field_count = 0; -- cgit v1.2.3-24-g4f1b From 0b18634e32efbafb83746c123b7d058b1570a01d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 31 May 2014 20:29:09 +0300 Subject: Changelog messages, bump year in copyright notices --- system/database/drivers/sqlsrv/sqlsrv_forge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/sqlsrv/sqlsrv_forge.php') diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index 286977c52..8f879d2f6 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_forge.php +++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b