summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-02-19 13:44:18 +0100
committerAndrey Andreev <narf@devilix.net>2015-02-19 13:44:18 +0100
commit6c7c8917d853bcd4acdce930b9afa537b2fb8b95 (patch)
tree941174c3cefd673f9a713ac4e5773f6a1782f599
parentc545c0147636d8592fdcb7e8ec2c6df09399d485 (diff)
Remove 'autoinit' DB setting
It doesn't make sense to do a load->database() call but not connect to the database. IIRC there was more stuff in CI_DB_driver::initialize() at some point, so that was probably the reason why the setting existed in the first place. However, now it only results in users making invalid bug reports because they don't understand the feature ... Examples during just the past 2 weeks: #3571 #3601 #3607
-rw-r--r--application/config/database.php2
-rw-r--r--system/database/DB.php5
-rw-r--r--system/database/DB_driver.php10
-rw-r--r--system/database/drivers/cubrid/cubrid_driver.php4
-rw-r--r--system/database/drivers/mysql/mysql_driver.php4
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php4
-rw-r--r--system/database/drivers/oci8/oci8_driver.php4
-rw-r--r--system/database/drivers/pdo/pdo_driver.php4
-rw-r--r--system/database/drivers/postgre/postgre_driver.php4
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php4
-rw-r--r--system/libraries/Session/drivers/Session_database_driver.php2
-rw-r--r--tests/mocks/database/db.php3
-rw-r--r--user_guide_src/source/changelog.rst3
-rw-r--r--user_guide_src/source/database/configuration.rst6
14 files changed, 5 insertions, 54 deletions
diff --git a/application/config/database.php b/application/config/database.php
index 5ee2af438..925b3e504 100644
--- a/application/config/database.php
+++ b/application/config/database.php
@@ -39,7 +39,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| multi-byte character set and are running versions lower than these.
| Sites using Latin-1 or UTF-8 database character set and collation are unaffected.
| ['swap_pre'] A default table prefix that should be swapped with the dbprefix
-| ['autoinit'] Whether or not to automatically initialize the database.
| ['encrypt'] Whether or not to use an encrypted connection.
| ['compress'] Whether or not to use client compression (MySQL only)
| ['stricton'] TRUE/FALSE - forces 'Strict Mode' connections
@@ -78,7 +77,6 @@ $db['default'] = array(
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
- 'autoinit' => TRUE,
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
diff --git a/system/database/DB.php b/system/database/DB.php
index 8ea7ca6fa..c9660e4bd 100644
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -213,10 +213,5 @@ function &DB($params = '', $query_builder_override = NULL)
}
}
- if ($DB->autoinit === TRUE)
- {
- $DB->initialize();
- }
-
return $DB;
}
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index bbe65b410..68e5a2833 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -124,15 +124,6 @@ abstract class CI_DB_driver {
public $dbcollat = 'utf8_general_ci';
/**
- * Auto-init flag
- *
- * Whether to automatically initialize the DB connection.
- *
- * @var bool
- */
- public $autoinit = TRUE;
-
- /**
* Encryption flag/data
*
* @var mixed
@@ -381,6 +372,7 @@ abstract class CI_DB_driver {
}
}
+ $this->initialize();
log_message('info', 'Database Driver Class Initialized');
}
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 402117978..f80b4db54 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -163,10 +163,6 @@ class CI_DB_cubrid_driver extends CI_DB {
{
return $this->data_cache['version'];
}
- elseif ( ! $this->conn_id)
- {
- $this->initialize();
- }
return ( ! $this->conn_id OR ($version = cubrid_get_server_info($this->conn_id)) === FALSE)
? FALSE
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index f8e9b6d61..df0f24920 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -223,10 +223,6 @@ class CI_DB_mysql_driver extends CI_DB {
{
return $this->data_cache['version'];
}
- elseif ( ! $this->conn_id)
- {
- $this->initialize();
- }
if ( ! $this->conn_id OR ($version = mysql_get_server_info($this->conn_id)) === FALSE)
{
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 22a8ba678..e953db052 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -204,10 +204,6 @@ class CI_DB_mysqli_driver extends CI_DB {
{
return $this->data_cache['version'];
}
- elseif ( ! $this->conn_id)
- {
- $this->initialize();
- }
return $this->data_cache['version'] = $this->conn_id->server_info;
}
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index b87b41112..4010995a1 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -243,10 +243,6 @@ class CI_DB_oci8_driver extends CI_DB {
{
return $this->data_cache['version'];
}
- elseif ( ! $this->conn_id)
- {
- $this->initialize();
- }
if ( ! $this->conn_id OR ($version = oci_server_version($this->conn_id)) === FALSE)
{
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 68aeb0eef..cc77e9568 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -156,10 +156,6 @@ class CI_DB_pdo_driver extends CI_DB {
{
return $this->data_cache['version'];
}
- elseif ( ! $this->conn_id)
- {
- $this->initialize();
- }
// Not all subdrivers support the getAttribute() method
try
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 3f3e3f018..7be07c3bf 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -213,10 +213,6 @@ class CI_DB_postgre_driver extends CI_DB {
{
return $this->data_cache['version'];
}
- elseif ( ! $this->conn_id)
- {
- $this->initialize();
- }
if ( ! $this->conn_id OR ($pg_version = pg_version($this->conn_id)) === FALSE)
{
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 8f17c8f96..16f77fab2 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -292,10 +292,6 @@ class CI_DB_sqlsrv_driver extends CI_DB {
{
return $this->data_cache['version'];
}
- elseif ( ! $this->conn_id)
- {
- $this->initialize();
- }
if ( ! $this->conn_id OR ($info = sqlsrv_server_info($this->conn_id)) === FALSE)
{
diff --git a/system/libraries/Session/drivers/Session_database_driver.php b/system/libraries/Session/drivers/Session_database_driver.php
index 20cec00fd..f496b4fe0 100644
--- a/system/libraries/Session/drivers/Session_database_driver.php
+++ b/system/libraries/Session/drivers/Session_database_driver.php
@@ -122,7 +122,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
public function open($save_path, $name)
{
return empty($this->_db->conn_id)
- ? ( ! $this->_db->autoinit && $this->_db->db_connect())
+ ? (bool) $this->_db->db_connect()
: TRUE;
}
diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php
index 968476dea..5216be2d7 100644
--- a/tests/mocks/database/db.php
+++ b/tests/mocks/database/db.php
@@ -56,8 +56,7 @@ class Mock_Database_DB {
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
- 'autoinit' => TRUE,
- 'stricton' => FALSE,
+ 'stricton' => FALSE
);
$config = array_merge($this->config[$group], $params);
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index a904c827f..8f77f368f 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -155,6 +155,8 @@ Release Date: Not Released
- DEPRECATED the 'mysql', 'sqlite', 'mssql' and 'pdo/dblib' (also known as 'pdo/mssql' or 'pdo/sybase') drivers.
- Added **dsn** configuration setting for drivers that support DSN strings (PDO, PostgreSQL, Oracle, ODBC, CUBRID).
- Added **schema** configuration setting (defaults to *public*) for drivers that might need it (currently used by PostgreSQL and ODBC).
+ - Added **save_queries** configuration setting to *application/config/database.php* (defaults to ``TRUE``).
+ - Removed **autoinit** configuration setting as it doesn't make sense to instantiate the database class but not connect to the database.
- Added subdrivers support (currently only used by PDO).
- Added an optional database name parameter to ``db_select()``.
- Removed ``protect_identifiers()`` and renamed internal method ``_protect_identifiers()`` to it instead - it was just an alias.
@@ -173,7 +175,6 @@ Release Date: Not Released
- Added support for SQLite3 database driver.
- Added Interbase/Firebird database support via the *ibase* driver.
- Added ODBC support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge <database/forge>`.
- - Added **save_queries** configuration setting to *application/config/database.php* (defaults to ``TRUE``).
- Added support to binding arrays as ``IN()`` sets in ``query()``.
- :doc:`Query Builder <database/query_builder>` changes include:
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst
index 521eb6010..d21c79e44 100644
--- a/user_guide_src/source/database/configuration.rst
+++ b/user_guide_src/source/database/configuration.rst
@@ -27,7 +27,6 @@ prototype::
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
- 'autoinit' => TRUE,
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
@@ -70,7 +69,6 @@ These failovers can be specified by setting the failover for a connection like t
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
- 'autoinit' => TRUE,
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE
@@ -89,7 +87,6 @@ These failovers can be specified by setting the failover for a connection like t
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
- 'autoinit' => TRUE,
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE
@@ -120,7 +117,6 @@ example, to set up a "test" environment you would do this::
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
- 'autoinit' => TRUE,
'compress' => FALSE,
'encrypt' => FALSE,
'stricton' => FALSE,
@@ -181,8 +177,6 @@ Explanation of Values:
**swap_pre** A default table prefix that should be swapped with dbprefix. This is useful for distributed
applications where you might run manually written queries, and need the prefix to still be
customizable by the end user.
-**autoinit** Whether or not to automatically connect to the database when the library loads. If set to false,
- you will have to manually connect via the ``$this->db->db_connect()`` method.
**schema** The database schema, defaults to 'public'. Used by PostgreSQL and ODBC drivers.
**encrypt** Whether or not to use an encrypted connection.
**compress** Whether or not to use client compression (MySQL only).