diff options
author | Florian Pritz <bluewind@xinu.at> | 2014-06-06 23:08:59 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2014-06-06 23:08:59 +0200 |
commit | 77f15dc6ba5d3308d42e8f75103c3193d3796dd2 (patch) | |
tree | 7e1a86f8b0ff954780a28bdea6c956649cf36d57 /system/database/drivers/sqlsrv | |
parent | 110b467503f7a749aec685be445468c0f98b9e2a (diff) | |
parent | 916b176594bcf175417423f33711ac0cbb4082e7 (diff) |
Merge remote-tracking branch 'remotes/upstream/2.2-stable' into working
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Conflicts:
system/libraries/Session.php
user_guide/
Diffstat (limited to 'system/database/drivers/sqlsrv')
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_driver.php | 4 | ||||
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_forge.php | 23 | ||||
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_result.php | 2 | ||||
-rw-r--r-- | system/database/drivers/sqlsrv/sqlsrv_utility.php | 2 |
4 files changed, 14 insertions, 17 deletions
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 400fd31c6..328c8fe7d 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.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 @@ -536,7 +536,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ function _truncate($table) { - return "TRUNCATE ".$table; + return "TRUNCATE TABLE ".$table; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php index cc88ec5ca..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 @@ -60,7 +60,8 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge { */ function _drop_table($table) { - return "DROP TABLE ".$this->db->_escape_identifiers($table); + return "IF (EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = '" + .$table."')) DROP TABLE [dbo].[".$table."]"; } // -------------------------------------------------------------------- @@ -78,14 +79,12 @@ 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) @@ -131,7 +130,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)'; } } @@ -237,12 +236,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 diff --git a/system/database/drivers/sqlsrv/sqlsrv_result.php b/system/database/drivers/sqlsrv/sqlsrv_result.php index bf0abd1c6..a5c972669 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_result.php +++ b/system/database/drivers/sqlsrv/sqlsrv_result.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 diff --git a/system/database/drivers/sqlsrv/sqlsrv_utility.php b/system/database/drivers/sqlsrv/sqlsrv_utility.php index 13a1850c4..0004bfdd2 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_utility.php +++ b/system/database/drivers/sqlsrv/sqlsrv_utility.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 |