New version submitted by TomB
[carbonphp.git] / Documentation / database / configuration.html
blobe21d081f8e6c4d00bab898e5aca9ac017091403f
1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
2 <head>
3 <title>CarbonPHP Documentation</title>
4 <style type="text/css">
5 * {
6 margin: 0;
7 padding: 0;
10 html {
11 font-family: "Lucida Sans Unicode", "Lucida Grande";
12 font-size: 12px;
15 body {
16 background: #fff;
17 color: #666;
20 h1 {
21 font-size: 15px;
22 font-weight: bold;
23 margin: 0 0 5px 0;
26 h2 {
27 font-size: 13px;
28 font-weight: bold;
29 margin: 5px 0 5px 0;
32 ol, ul {
33 margin: 10px 0 10px 0;
34 list-style-position: inside;
37 p {
38 margin: 5px 0 5px 0;
41 .content {
42 border: 1px dotted #444;
43 margin: 10px;
44 padding: 10px;
45 text-align: justify;
46 width: 700px;
49 .example {
50 border: 1px solid #ccc;
51 background: #eee;
52 margin: 10px;
53 padding: 10px;
54 text-align: left;
56 </style>
57 </head>
59 <body>
60 <div class="content">
61 <h1>Database Configuration</h1>
63 <p>There is a configuration file that lets you store your database connection details. The configuration file
64 is in the <b>application/config/database.php</b> file.</p>
66 <p>The configuration settings are stored in a multi-dimensional array with the following prototype.</p>
68 <div class="example">
69 $database['default']['hostname'] = 'localhost';<br />
70 $database['default']['username'] = 'root';<br />
71 $database['default']['password'] = '';<br />
72 $database['default']['database'] = 'database_name';<br />
73 $database['default']['dbdriver'] = 'mysql';<br />
74 $database['default']['dbprefix'] = '';<br />
75 $database['default']['pconnect'] = true;<br />
76 $database['default']['db_debug'] = false;<br />
77 $database['default']['cache_on'] = false;<br />
78 $database['default']['cachedir'] = '';<br />
79 $database['default']['char_set'] = 'utf8';<br />
80 $database['default']['dbcollat'] = 'utf8_general_ci';<br />
81 </div>
83 <p>The reason a multi-dimensional array is used is that it allows more than one set of database connection
84 settings to be stored. Below is an example second set of connection details.</p>
86 <div class="example">
87 $database['test']['hostname'] = 'localhost';<br />
88 $database['test']['username'] = 'root';<br />
89 $database['test']['password'] = '';<br />
90 $database['test']['database'] = 'database_name';<br />
91 $database['test']['dbdriver'] = 'mysql';<br />
92 $database['test']['dbprefix'] = '';<br />
93 $database['test']['pconnect'] = true;<br />
94 $database['test']['db_debug'] = false;<br />
95 $database['test']['cache_on'] = false;<br />
96 $database['test']['cachedir'] = '';<br />
97 $database['test']['char_set'] = 'utf8';<br />
98 $database['test']['dbcollat'] = 'utf8_general_ci';<br />
99 </div>
101 <p>To globally tell CarbonPHP which connection settings to use you just set the <b>$active_group</b>
102 variable.</p>
104 <div class="example">
105 $active_group = 'test';
106 </div>
107 </div>
109 <div class="content">
110 <h1>Active Record</h1>
112 <p>The Active Record class is globally enabled or disabled by setting the <b>$active_record</b> variable in the database
113 configuration file to true or false. If you are not using the active record class, setting it to false will use fewer resources
114 when the database classes are initialised.</p>
116 <div class="example">
117 $active_record = true;
118 </div>
119 </div>
121 <div class="content">
122 <h1>Configuration Options</h1>
124 <ul>
125 <li><b>hostname</b> - the hostname of the database server.</li>
126 <li><b>username</b> - the username used to connect to the database.</li>
127 <li><b>password</b> - the password used to connect to the database.</li>
128 <li><b>database</b> - the name of the database you want to connect to.</li>
129 <li><b>dbdriver</b> - the type of database i.e. mysql, postgre, mssql.</li>
130 <li><b>dbpreifx</b> - the optional table prefix which will be added when running active record queries.</li>
131 <li><b>pconnect</b> - the option to use a persistant database connection.</li>
132 <li><b>db_debug</b> - the option to show database errors or not.</li>
133 <li><b>cache_on</b> - the option whether database query caching is enabled.</li>
134 <li><b>cachedir</b> - the absolute path to the directory to use for query caching.</li>
135 <li><b>char_set</b> - the character set used in communicating with the database.</li>
136 <li><b>dbcollat</b> - the character collation used in communication with the database.</li>
137 <li><b>port</b> - the database port number, only used for the postgre driver.</li>
138 </ul>
140 <p><i>Note</i>: depending on which database driver you are using not all values will be needed. For example
141 when you are using the SQLite driver you will not need to supply a username or password, and the database
142 name will be the path to the database file.</p>
143 </div>
144 </body>
146 </html>