From 508aa787c1203a42d1103617bba122e312bd5088 Mon Sep 17 00:00:00 2001 From: tino Date: Fri, 18 Oct 2013 10:26:05 +0200 Subject: Bugfix on truncate command --- system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database') diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php index 400fd31c6..e6f37778c 100644 --- a/system/database/drivers/sqlsrv/sqlsrv_driver.php +++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php @@ -536,7 +536,7 @@ class CI_DB_sqlsrv_driver extends CI_DB { */ function _truncate($table) { - return "TRUNCATE ".$table; + return "TRUNCATE TABLE ".$table; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b 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') 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') 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') 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') 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') 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 2cfbfc54dc68d9e7ed7c20af4cf7693736bbd447 Mon Sep 17 00:00:00 2001 From: blowdoof Date: Fri, 18 Oct 2013 16:46:09 +0200 Subject: Bugfix on the active record join statement with empty conditions --- system/database/DB_active_rec.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system/database') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 129eaa7b6..5bf0d8f1d 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -336,8 +336,12 @@ class CI_DB_active_record extends CI_DB_driver { $cond = $match[1].$match[2].$match[3]; } - // Assemble the JOIN statement - $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond; + // Assemble the JOIN statement: only use ON if a condition was passed + $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE); + if ($cond) + { + $join .= ' ON '.$cond; + } $this->ar_join[] = $join; if ($this->ar_caching === TRUE) -- cgit v1.2.3-24-g4f1b From 149412915c0ab247cbe84420d52940b1c6b0df7a Mon Sep 17 00:00:00 2001 From: blowdoof Date: Fri, 18 Oct 2013 20:14:09 +0200 Subject: Revert "Bugfix on the active record join statement with empty conditions" This reverts commit 2cfbfc54dc68d9e7ed7c20af4cf7693736bbd447. --- system/database/DB_active_rec.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'system/database') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 5bf0d8f1d..129eaa7b6 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -336,12 +336,8 @@ class CI_DB_active_record extends CI_DB_driver { $cond = $match[1].$match[2].$match[3]; } - // Assemble the JOIN statement: only use ON if a condition was passed - $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE); - if ($cond) - { - $join .= ' ON '.$cond; - } + // Assemble the JOIN statement + $join = $type.'JOIN '.$this->_protect_identifiers($table, TRUE, NULL, FALSE).' ON '.$cond; $this->ar_join[] = $join; if ($this->ar_caching === TRUE) -- 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') 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 0433431188b9e71841ae292cb218ca89ded58b87 Mon Sep 17 00:00:00 2001 From: Aaron Krebs Date: Wed, 11 Dec 2013 12:32:23 -0700 Subject: Make oci_execute() calls inside num_rows() non-committing. Fixes #696. Fixes bug in Oracle driver. Calls to oci_execute() inside num_rows() of the Oracle driver can be made non-committing to fix bug with transactions. Since calls to oci_execute are only there to reset which row is next in line for oci_fetch() calls, it's fine to not commit. --- system/database/drivers/oci8/oci8_result.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/database') diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php index 3421278a5..f6138c014 100644 --- a/system/database/drivers/oci8/oci8_result.php +++ b/system/database/drivers/oci8/oci8_result.php @@ -43,11 +43,11 @@ class CI_DB_oci8_result extends CI_DB_result { if ($this->num_rows === 0 && count($this->result_array()) > 0) { $this->num_rows = count($this->result_array()); - @oci_execute($this->stmt_id); + @oci_execute($this->stmt_id, OCI_DEFAULT); if ($this->curs_id) { - @oci_execute($this->curs_id); + @oci_execute($this->curs_id, OCI_DEFAULT); } } -- cgit v1.2.3-24-g4f1b From 92f62b03812c6079fc5e73d865d727627e533e63 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Jan 2014 15:44:00 +0200 Subject: Manually apply an improved version of PR #2427 --- system/database/drivers/pdo/pdo_driver.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'system/database') diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 1ecc90a82..d153af2e7 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -190,14 +190,12 @@ class CI_DB_pdo_driver extends CI_DB { { $sql = $this->_prep_query($sql); $result_id = $this->conn_id->prepare($sql); - $result_id->execute(); - - if (is_object($result_id)) + + if (is_object($result_id) && ($result = $result_id->execute())) { if (is_numeric(stripos($sql, 'SELECT'))) { $this->affect_rows = count($result_id->fetchAll()); - $result_id->execute(); } else { @@ -207,9 +205,10 @@ class CI_DB_pdo_driver extends CI_DB { else { $this->affect_rows = 0; + $result = FALSE; } - - return $result_id; + + return $result; } // -------------------------------------------------------------------- -- 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/DB.php | 2 +- system/database/DB_active_rec.php | 2 +- system/database/DB_cache.php | 2 +- system/database/DB_driver.php | 2 +- system/database/DB_forge.php | 2 +- system/database/DB_result.php | 2 +- system/database/DB_utility.php | 4 ++-- system/database/drivers/cubrid/cubrid_driver.php | 2 +- system/database/drivers/cubrid/cubrid_forge.php | 2 +- system/database/drivers/cubrid/cubrid_result.php | 2 +- system/database/drivers/cubrid/cubrid_utility.php | 2 +- system/database/drivers/mssql/mssql_driver.php | 2 +- system/database/drivers/mssql/mssql_forge.php | 2 +- system/database/drivers/mssql/mssql_result.php | 2 +- system/database/drivers/mssql/mssql_utility.php | 2 +- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/mysql/mysql_forge.php | 2 +- system/database/drivers/mysql/mysql_result.php | 2 +- system/database/drivers/mysql/mysql_utility.php | 2 +- system/database/drivers/mysqli/mysqli_driver.php | 2 +- system/database/drivers/mysqli/mysqli_forge.php | 2 +- system/database/drivers/mysqli/mysqli_result.php | 2 +- system/database/drivers/mysqli/mysqli_utility.php | 2 +- system/database/drivers/oci8/oci8_driver.php | 2 +- system/database/drivers/oci8/oci8_forge.php | 2 +- system/database/drivers/oci8/oci8_result.php | 2 +- system/database/drivers/oci8/oci8_utility.php | 2 +- system/database/drivers/odbc/odbc_driver.php | 2 +- system/database/drivers/odbc/odbc_forge.php | 2 +- system/database/drivers/odbc/odbc_result.php | 2 +- system/database/drivers/odbc/odbc_utility.php | 2 +- system/database/drivers/pdo/pdo_driver.php | 6 +++--- system/database/drivers/pdo/pdo_forge.php | 2 +- system/database/drivers/pdo/pdo_result.php | 2 +- system/database/drivers/pdo/pdo_utility.php | 2 +- system/database/drivers/postgre/postgre_driver.php | 2 +- system/database/drivers/postgre/postgre_forge.php | 2 +- system/database/drivers/postgre/postgre_result.php | 2 +- system/database/drivers/postgre/postgre_utility.php | 2 +- system/database/drivers/sqlite/sqlite_driver.php | 2 +- system/database/drivers/sqlite/sqlite_forge.php | 2 +- system/database/drivers/sqlite/sqlite_result.php | 2 +- system/database/drivers/sqlite/sqlite_utility.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_driver.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_forge.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_result.php | 2 +- system/database/drivers/sqlsrv/sqlsrv_utility.php | 2 +- 47 files changed, 50 insertions(+), 50 deletions(-) (limited to 'system/database') diff --git a/system/database/DB.php b/system/database/DB.php index 8314d3b97..d74738a03 100755 --- a/system/database/DB.php +++ b/system/database/DB.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/DB_active_rec.php b/system/database/DB_active_rec.php index 129eaa7b6..85faa555d 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.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/DB_cache.php b/system/database/DB_cache.php index ad1c28d72..e6945950b 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.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/DB_driver.php b/system/database/DB_driver.php index 775fd3354..c342aacbd 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_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 diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php index 6bc40411b..b92069bbc 100644 --- a/system/database/DB_forge.php +++ b/system/database/DB_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 diff --git a/system/database/DB_result.php b/system/database/DB_result.php index 48d66c8e4..5b4f60e4b 100644 --- a/system/database/DB_result.php +++ b/system/database/DB_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/DB_utility.php b/system/database/DB_utility.php index 52196b7ce..6a9d8cc59 100644 --- a/system/database/DB_utility.php +++ b/system/database/DB_utility.php @@ -1,12 +1,12 @@