From 75d568db823b8fe7526e416f5e3f1c2c235f5473 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 30 Jan 2008 20:26:25 +0000 Subject: removed 'active_r' db config variable, replaced with global $active_record setting. (bug report #1834) --- system/application/config/database.php | 4 +++- system/database/DB.php | 8 ++++---- user_guide/database/configuration.html | 24 +++++++++++++++++------- user_guide/database/connecting.html | 1 - user_guide/installation/upgrade_160.html | 7 ++++++- 5 files changed, 30 insertions(+), 14 deletions(-) diff --git a/system/application/config/database.php b/system/application/config/database.php index 59b973981..472affbe5 100644 --- a/system/application/config/database.php +++ b/system/application/config/database.php @@ -22,7 +22,6 @@ | to the table name when using the Active Record class | ['pconnect'] TRUE/FALSE - Whether to use a persistent connection | ['db_debug'] TRUE/FALSE - Whether database errors should be displayed. -| ['active_r'] TRUE/FALSE - Whether to load the active record class | ['cache_on'] TRUE/FALSE - Enables/disables query caching | ['cachedir'] The path to the folder where cache files should be stored | ['char_set'] The character set used in communicating with the database @@ -31,9 +30,12 @@ | The $active_group variable lets you choose which connection group to | make active. By default there is only one group (the "default" group). | +| The $active_record variables lets you determine whether or not to load +| the active record class */ $active_group = "default"; +$active_record = TRUE; $db['default']['hostname'] = "localhost"; $db['default']['username'] = ""; diff --git a/system/database/DB.php b/system/database/DB.php index abd782c34..8f25e5e1a 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -22,7 +22,7 @@ * @author ExpressionEngine Dev Team * @link http://codeigniter.com/user_guide/database/ */ -function &DB($params = '', $active_record = FALSE) +function &DB($params = '', $active_record_override = FALSE) { // Load the DB config file if a DSN string wasn't passed if (is_string($params) AND strpos($params, '://') === FALSE) @@ -58,14 +58,14 @@ function &DB($params = '', $active_record = FALSE) // based on whether we're using the active record class or not. // Kudos to Paul for discovering this clever use of eval() - if ($active_record == TRUE) + if ($active_record_override == TRUE) { - $params['active_r'] = TRUE; + $active_record = TRUE; } require_once(BASEPATH.'database/DB_driver'.EXT); - if ( ! isset($params['active_r']) OR $params['active_r'] == TRUE) + if ($active_record == TRUE) { require_once(BASEPATH.'database/DB_active_rec'.EXT); diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index 1c44858f7..dafdd024f 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -75,9 +75,10 @@ $db['default']['dbdriver'] = "mysql";
$db['default']['dbprefix'] = "";
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
-$db['default']['active_r'] = TRUE;
$db['default']['cache_on'] = FALSE;
-$db['default']['cachedir'] = ""; +$db['default']['cachedir'] = "";
+$db['default']['char_set'] = "utf8";
+$db['default']['dbcollat'] = "utf8_general_ci";

The reason we use a multi-dimensional array rather than a more simple one is to permit you to optionally store multiple sets of connection values. If, for example, you run multiple environments (development, production, test, etc.) @@ -92,9 +93,10 @@ $db['test']['dbdriver'] = "mysql";
$db['test']['dbprefix'] = "";
$db['test']['pconnect'] = TRUE;
$db['test']['db_debug'] = FALSE;
-$db['test']['active_r'] = TRUE;
-$db['default']['cache_on'] = FALSE;
-$db['default']['cachedir'] = ""; +$db['test']['cache_on'] = FALSE;
+$db['test']['cachedir'] = "";
+$db['test']['char_set'] = "utf8";
+$db['test']['dbcollat'] = "utf8_general_ci";

Then, to globally tell the system to use that group you would set this variable located in the config file:

@@ -104,6 +106,14 @@ $db['default']['cachedir'] = "";

Note: The name "test" is arbitrary. It can be anything you want. By default we've used the word "default" for the primary connection, but it too can be renamed to something more relevant to your project.

+

Active Record

+ +

The Active Record Class is globally enabled or disabled by setting the $active_record variable in the database configuration file to TRUE/FALSE (boolean). If you are not using the active record class, setting it to FALSE will utilize fewer resources when the database classes are initialized.

+ +$active_record = TRUE; + +

Note: that some CodeIgniter classes such as Sessions require Active Records be enabled to access certain functionality.

+

Explanation of Values:

diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html index 98a5d3784..ea4d18904 100644 --- a/user_guide/database/connecting.html +++ b/user_guide/database/connecting.html @@ -102,7 +102,6 @@ $config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
-$config['active_r'] = TRUE;

$this->load->database($config); diff --git a/user_guide/installation/upgrade_160.html b/user_guide/installation/upgrade_160.html index 9cddf6b61..4b513d506 100644 --- a/user_guide/installation/upgrade_160.html +++ b/user_guide/installation/upgrade_160.html @@ -82,7 +82,12 @@ Upgrading from 1.5.3 to 1.5.4

$config['sess_time_to_update'] = 300;

Step 3: Add to your database.php

-

Add the following to system/application/config/database.php with the other database configuration options

+

Make the following changes to your system/application/config/database.php file:

+

Add the following variable above the database configuration options, with $active_group

+

$active_record = TRUE;

+

Remove the following from your database configuration options

+

$db['default']['active_r'] = TRUE;

+

Add the following to your database configuration options

$db['default']['char_set'] = "utf8";
$db['default']['dbcollat'] = "utf8_general_ci";

-- cgit v1.2.3-24-g4f1b