diff options
-rw-r--r-- | user_guide_src/source/database/configuration.rst | 121 | ||||
-rw-r--r-- | user_guide_src/source/documentation/index.rst | 12 |
2 files changed, 75 insertions, 58 deletions
diff --git a/user_guide_src/source/database/configuration.rst b/user_guide_src/source/database/configuration.rst index c2c5a33ab..687f0d920 100644 --- a/user_guide_src/source/database/configuration.rst +++ b/user_guide_src/source/database/configuration.rst @@ -12,7 +12,21 @@ 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; + $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 @@ -21,7 +35,21 @@ 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; + $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:: @@ -51,56 +79,45 @@ when the database classes are initialized. Explanation of Values: ---------------------- -- **hostname** - The hostname of your database server. Often this is - "localhost". -- **username** - The username used to connect to the database. -- **password** - The password used to connect to the database. -- **database** - The name of the database you want to connect to. -- **dbdriver** - The database type. ie: mysql, postgres, odbc, etc. - Must be specified in lower case. -- **dbprefix** - An optional table prefix which will added to the table - name when running :doc:`Active Record <active_record>` queries. This - permits multiple CodeIgniter installations to share one database. -- **pconnect** - TRUE/FALSE (boolean) - Whether to use a persistent - connection. -- **db_debug** - TRUE/FALSE (boolean) - Whether database errors should - be displayed. -- **cache_on** - TRUE/FALSE (boolean) - Whether database query caching - is enabled, see also :doc:`Database Caching Class <caching>`. -- **cachedir** - The absolute server path to your database query cache - directory. -- **char_set** - The character set used in communicating with the - database. -- **dbcollat** - The character collation used in communicating with the - database. - -.. note:: For MySQL and MySQLi databases, this setting is only used - as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7 - (and in table creation queries made with DB Forge). There is an - incompatibility in PHP with mysql_real_escape_string() which can - make your site vulnerable to SQL injection if you are using a - 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 - 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, the connection will - take place prior to executing the first query. -- **stricton** - TRUE/FALSE (boolean) - Whether to force "Strict Mode" - connections, good for ensuring strict SQL while developing an - application. -- **port** - The database port number. To use this value you have to - add a line to the database config - array. - -:: - - $db['default']['port'] = 5432; - +====================== ================================================================================================== + Name Config Description +====================== ================================================================================================== +**hostname** The hostname of your database server. Often this is "localhost". +**username** The username used to connect to the database. +**password** The password used to connect to the database. +**database** The name of the database you want to connect to. +**dbdriver** The database type. ie: mysql, postgres, odbc, etc. Must be specified in lower case. +**dbprefix** An optional table prefix which will added to the table name when running :doc: + `Active Record <active_record>` queries. This permits multiple CodeIgniter installations + to share one database. +**pconnect** TRUE/FALSE (boolean) - Whether to use a persistent connection. +**db_debug** TRUE/FALSE (boolean) - Whether database errors should be displayed. +**cache_on** TRUE/FALSE (boolean) - Whether database query caching is enabled, + see also :doc:`Database Caching Class <caching>`. +**cachedir** The absolute server path to your database query cache directory. +**char_set** The character set used in communicating with the database. +**dbcollat** The character collation used in communicating with the database + + .. note:: For MySQL and MySQLi databases, this setting is only used + as a backup if your server is running PHP < 5.2.3 or MySQL < 5.0.7 + (and in table creation queries made with DB Forge). There is an + incompatibility in PHP with mysql_real_escape_string() which can + make your site vulnerable to SQL injection if you are using a + 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 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, + the connection will take place prior to executing the first query. +**stricton** TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL + while developing an application. +**port** The database port number. To use this value you have to add a line to the database config array. + :: + $db['default']['port'] = 5432; +====================== ================================================================================================== .. note:: Depending on what database platform you are using (MySQL, Postgres, etc.) not all values will be needed. For example, when using diff --git a/user_guide_src/source/documentation/index.rst b/user_guide_src/source/documentation/index.rst index d62920f74..e977566d2 100644 --- a/user_guide_src/source/documentation/index.rst +++ b/user_guide_src/source/documentation/index.rst @@ -118,16 +118,16 @@ ReST: :: - $this->EE->load->library('some_class'); + $this->load->library('some_class'); $bar = array( 'something' => 'Here is this parameter!', 'something_else' => 42 ); - $bat = $this->EE->some_class->should_do_something(); + $bat = $this->some_class->should_do_something(); - if ($this->EE->some_class->some_method(4, $bar, $bat) === FALSE) + if ($this->some_class->some_method(4, $bar, $bat) === FALSE) { show_error('An Error Occurred Doing Some Method'); } @@ -167,16 +167,16 @@ some_method() :: - $this->EE->load->library('some_class'); + $this->load->library('some_class'); $bar = array( 'something' => 'Here is this parameter!', 'something_else' => 42 ); - $bat = $this->EE->some_class->should_do_something(); + $bat = $this->some_class->should_do_something(); - if ($this->EE->some_class->some_method(4, $bar, $bat) === FALSE) + if ($this->some_class->some_method(4, $bar, $bat) === FALSE) { show_error('An Error Occurred Doing Some Method'); } |