X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=blobdiff_plain;f=user_guide%2Fdatabase%2Fconfiguration.html;fp=user_guide%2Fdatabase%2Fconfiguration.html;h=fdeae0ee2029b6c2855b7b47de25dfcc5d720c2b;hb=6d8f5b56b237767344bc4a283b4093e6d6f1a612;hp=0000000000000000000000000000000000000000;hpb=0f67329ebdddeb59a2b6b79aedb1fce421378ca8;p=living-lab-site.git diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html new file mode 100755 index 0000000..fdeae0e --- /dev/null +++ b/user_guide/database/configuration.html @@ -0,0 +1,164 @@ + + + + + +Database Configuration : CodeIgniter User Guide + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

CodeIgniter User Guide Version 2.0.2

+
+ + + + + + + + + +
+ + + +
+ + + +
+ + +

Database Configuration

+ +

CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.). +The config file is located at application/config/database.php. You can also set database connection values for specific environments by placing database.php it the respective environment config folder.

+ +

The config settings are stored in a multi-dimensional array with this prototype:

+ +$db['default']['hostname'] = "localhost";
+$db['default']['username'] = "root";
+$db['default']['password'] = "";
+$db['default']['database'] = "database_name";
+$db['default']['dbdriver'] = "mysql";
+$db['default']['dbprefix'] = "";
+$db['default']['pconnect'] = TRUE;
+$db['default']['db_debug'] = FALSE;
+$db['default']['cache_on'] = FALSE;
+$db['default']['cachedir'] = "";
+$db['default']['char_set'] = "utf8";
+$db['default']['dbcollat'] = "utf8_general_ci";
+$db['default']['swap_pre'] = "";
+$db['default']['autoinit'] = TRUE;
+$db['default']['stricton'] = FALSE;
+ +

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.) +under a single installation, you can set up a connection group for each, then switch between groups as needed. +For example, to set up a "test" environment you would do this:

+ +$db['test']['hostname'] = "localhost";
+$db['test']['username'] = "root";
+$db['test']['password'] = "";
+$db['test']['database'] = "database_name";
+$db['test']['dbdriver'] = "mysql";
+$db['test']['dbprefix'] = "";
+$db['test']['pconnect'] = TRUE;
+$db['test']['db_debug'] = FALSE;
+$db['test']['cache_on'] = FALSE;
+$db['test']['cachedir'] = "";
+$db['test']['char_set'] = "utf8";
+$db['test']['dbcollat'] = "utf8_general_ci";
+$db['test']['swap_pre'] = "";
+$db['test']['autoinit'] = TRUE;
+$db['test']['stricton'] = FALSE;
+ + +

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

+ +$active_group = "test"; + +

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:

+ + + +

Note: Depending on what database platform you are using (MySQL, Postgres, etc.) +not all values will be needed. For example, when using SQLite you will not need to supply a username or password, and +the database name will be the path to your database file. The information above assumes you are using MySQL.

+ + + +
+ + + + + + + \ No newline at end of file