From e4c30195c5f6dc7a144cfe4ee160b18626626612 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Jun 2012 15:08:24 +0300 Subject: Revert/optimize some changes from 48a2baf0e288accd206f5da5031d29076e130792 --- system/database/DB.php | 4 ++-- system/database/DB_cache.php | 12 ++++++------ system/database/DB_query_builder.php | 6 +++--- system/database/drivers/cubrid/cubrid_driver.php | 2 +- system/database/drivers/mssql/mssql_driver.php | 4 ++-- system/database/drivers/mysql/mysql_driver.php | 2 +- system/database/drivers/mysqli/mysqli_driver.php | 12 ++++++------ system/database/drivers/odbc/odbc_driver.php | 6 +++--- system/database/drivers/sqlite/sqlite_driver.php | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) (limited to 'system/database') diff --git a/system/database/DB.php b/system/database/DB.php index b0113b6f4..00d14b43e 100755 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -106,7 +106,7 @@ function &DB($params = '', $query_builder_override = NULL) } // No DB specified yet? Beat them senseless... - if ( ! isset($params['dbdriver']) OR $params['dbdriver'] === '') + if (empty($params['dbdriver'])) { show_error('You have not selected a database type to connect to.'); } @@ -157,7 +157,7 @@ function &DB($params = '', $query_builder_override = NULL) $DB->initialize(); } - if (isset($params['stricton']) && $params['stricton'] === TRUE) + if ( ! empty($params['stricton'])) { $DB->query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); } diff --git a/system/database/DB_cache.php b/system/database/DB_cache.php index 443bbce5f..14f3c21bc 100644 --- a/system/database/DB_cache.php +++ b/system/database/DB_cache.php @@ -95,8 +95,8 @@ class CI_DB_Cache { return $this->db->cache_off(); } - $segment_one = ($this->CI->uri->segment(1) === FALSE) ? 'default' : $this->CI->uri->segment(1); - $segment_two = ($this->CI->uri->segment(2) === FALSE) ? 'index' : $this->CI->uri->segment(2); + $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); if (FALSE === ($cachedata = read_file($filepath))) @@ -121,8 +121,8 @@ class CI_DB_Cache { return $this->db->cache_off(); } - $segment_one = ($this->CI->uri->segment(1) === FALSE) ? 'default' : $this->CI->uri->segment(1); - $segment_two = ($this->CI->uri->segment(2) === FALSE) ? 'index' : $this->CI->uri->segment(2); + $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; $filename = md5($sql); @@ -156,12 +156,12 @@ class CI_DB_Cache { { if ($segment_one === '') { - $segment_one = ($this->CI->uri->segment(1) === FALSE) ? 'default' : $this->CI->uri->segment(1); + $segment_one = ($this->CI->uri->segment(1) == FALSE) ? 'default' : $this->CI->uri->segment(1); } if ($segment_two === '') { - $segment_two = ($this->CI->uri->segment(2) === FALSE) ? 'index' : $this->CI->uri->segment(2); + $segment_two = ($this->CI->uri->segment(2) == FALSE) ? 'index' : $this->CI->uri->segment(2); } $dir_path = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'; diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index ccfd9bfc6..c8a161929 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1535,7 +1535,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->where($where); } - if ($limit !== NULL) + if ($limit != NULL) { $this->limit($limit); } @@ -1856,7 +1856,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->where($where); } - if ($limit !== NULL) + if ($limit != NULL) { $this->limit($limit); } @@ -2336,4 +2336,4 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } /* End of file DB_query_builder.php */ -/* Location: ./system/database/DB_query_builder.php */ +/* Location: ./system/database/DB_query_builder.php */ \ No newline at end of file diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php index b7763d90f..971f1ea7b 100644 --- a/system/database/drivers/cubrid/cubrid_driver.php +++ b/system/database/drivers/cubrid/cubrid_driver.php @@ -74,7 +74,7 @@ class CI_DB_cubrid_driver extends CI_DB { else { // If no port is defined by the user, use the default value - $this->port === '' OR $this->port = 33000; + empty($this->port) OR $this->port = 33000; } } diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php index 5bd666960..697b2fd28 100644 --- a/system/database/drivers/mssql/mssql_driver.php +++ b/system/database/drivers/mssql/mssql_driver.php @@ -64,7 +64,7 @@ class CI_DB_mssql_driver extends CI_DB { */ public function db_connect() { - if ($this->port !== '') + if ( ! empty($this->port)) { $this->hostname .= ','.$this->port; } @@ -81,7 +81,7 @@ class CI_DB_mssql_driver extends CI_DB { */ public function db_pconnect() { - if ($this->port !== '') + if ( ! empty($this->port)) { $this->hostname .= ','.$this->port; } diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index fc9bbdc4e..5937b223b 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -68,7 +68,7 @@ class CI_DB_mysql_driver extends CI_DB { { parent::__construct($params); - if ($this->port !== '') + if ( ! empty($this->port)) { $this->hostname .= ':'.$this->port; } diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 5814aceb9..02f893755 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -71,9 +71,9 @@ class CI_DB_mysqli_driver extends CI_DB { */ public function db_connect() { - return ($this->port !== '') - ? @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port) - : @new mysqli($this->hostname, $this->username, $this->password, $this->database); + return empty($this->port) + ? @new mysqli($this->hostname, $this->username, $this->password, $this->database) + : @new mysqli($this->hostname, $this->username, $this->password, $this->database, $this->port); } // -------------------------------------------------------------------- @@ -91,9 +91,9 @@ class CI_DB_mysqli_driver extends CI_DB { return $this->db_connect(); } - return ($this->port !== '') - ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port) - : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database); + return empty($this->port) + ? @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database) + : @new mysqli('p:'.$this->hostname, $this->username, $this->password, $this->database, $this->port); } // -------------------------------------------------------------------- diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index b493e9335..c3735da05 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -64,7 +64,7 @@ class CI_DB_odbc_driver extends CI_DB { $this->_random_keyword = ' RND('.time().')'; // database specific random keyword // Legacy support for DSN in the hostname field - if ($this->dsn === '') + if (empty($this->dsn)) { $this->dsn = $this->hostname; } @@ -254,9 +254,9 @@ class CI_DB_odbc_driver extends CI_DB { */ protected function _list_tables($prefix_limit = FALSE) { - $sql = "SHOW TABLES FROM `".$this->database."`"; + $sql = 'SHOW TABLES FROM '.$this->database; - if ($prefix_limit !== FALSE AND $this->dbprefix !== '') + if ($prefix_limit !== FALSE && $this->dbprefix !== '') { //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); return FALSE; // not currently supported diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php index c87a16ba8..d9820e1b3 100644 --- a/system/database/drivers/sqlite/sqlite_driver.php +++ b/system/database/drivers/sqlite/sqlite_driver.php @@ -279,7 +279,7 @@ class CI_DB_sqlite_driver extends CI_DB { { $sql = "SELECT name from sqlite_master WHERE type='table'"; - if ($prefix_limit !== FALSE AND $this->dbprefix != '') + if ($prefix_limit !== FALSE && $this->dbprefix != '') { $sql .= " AND 'name' LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr); } -- cgit v1.2.3-24-g4f1b