diff options
Diffstat (limited to 'user_guide/database')
-rw-r--r-- | user_guide/database/active_record.html | 2 | ||||
-rw-r--r-- | user_guide/database/configuration.html | 6 | ||||
-rw-r--r-- | user_guide/database/forge.html | 2 | ||||
-rw-r--r-- | user_guide/database/results.html | 23 | ||||
-rw-r--r-- | user_guide/database/utilities.html | 6 |
5 files changed, 29 insertions, 10 deletions
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 60e920208..30c45fdde 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -736,7 +736,7 @@ $this->db->get('tablename');<br /> <br /> //Generates: SELECT `field2` FROM (`tablename`)</code></p> -<p class="important"> <strong>Note:</strong> The following statements can be cached: select, from, join, where, like, groupby, having, orderby, set</p> +<p class="important"> <strong>Note:</strong> The following statements can be cached: select, from, join, where, like, group_by, having, order_by, set</p> <p> </p> </div> <!-- END CONTENT --> diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index 8e6fe1f42..d71cd34db 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -61,9 +61,7 @@ Configuration <h1>Database Configuration</h1> <p>CodeIgniter has a config file that lets you store your database connection values (username, password, database name, etc.). -The config file is located at:</p> - -<p><kbd>application/config/database.php</kbd></p> +The config file is located at <samp>application/config/database.php</samp>. You can also set database connection values for specific <a href="../libraries/config.html">environments</a> by placing <strong>database.php</strong> it the respective environment config folder.</p> <p>The config settings are stored in a multi-dimensional array with this prototype:</p> @@ -136,7 +134,7 @@ for the primary connection, but it too can be renamed to something more relevant <li><strong>char_set</strong> - The character set used in communicating with the database.</li> <li><strong>dbcollat</strong> - The character collation used in communicating with the database.</li> <li><strong>swap_pre</strong> - A default table prefix that should be swapped with <var>dbprefix</var>. 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.</li> -<li><strong>autoinit</strong> - Whether or not to automatically initialize the database.</li> +<li><strong>autoinit</strong> - 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.</li> <li><strong>stricton</strong> - TRUE/FALSE (boolean) - Whether to force "Strict Mode" connections, good for ensuring strict SQL while developing an application.</li> <li><strong>port</strong> - The database port number. To use this value you have to add a line to the database config array.<code>$db['default']['port'] = 5432;</code> </ul> diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html index 8b59848ca..d18db5820 100644 --- a/user_guide/database/forge.html +++ b/user_guide/database/forge.html @@ -205,7 +205,7 @@ $this->dbforge->add_column('table_name', $fields);<br /> <p>Used to remove a column from a table. </p> <p><code>$this->dbforge->drop_column('table_name', 'column_to_drop');</code></p> <h2>$this->dbforge->modify_column()</h2> -<p>The usage of this function is identical to add_column(), except it alters an existing column rather than adding a new one. In order to use it you must add a "name" key into the field defining array.</p> +<p>The usage of this function is identical to add_column(), except it alters an existing column rather than adding a new one. In order to change the name you can add a "name" key into the field defining array.</p> <p><code>$fields = array(<br /> 'old_name' => array(<br /> 'name' => 'new_name',<br /> diff --git a/user_guide/database/results.html b/user_guide/database/results.html index 75cb190f9..e9a5cb4cf 100644 --- a/user_guide/database/results.html +++ b/user_guide/database/results.html @@ -98,6 +98,18 @@ Query Results } </code> + <p>You can also pass a string to result() which represents a class to instantiate for each result object (note: this class must be loaded)</p> + + <code> + $query = $this->db->query("SELECT * FROM users;");<br /> + <br /> + foreach ($query->result('User') as $user)<br /> + {<br /> + echo $row->name; // call attributes<br /> + echo $row->reverse_name(); // or methods defined on the 'User' class<br /> + } + </code> + <h2>result_array()</h2> <p>This function returns the query result as a pure array, or an empty array when no result is produced. Typically you'll use this in a foreach loop, like this:</p> @@ -133,6 +145,15 @@ Query Results <code>$row = $query->row(<dfn>5</dfn>);</code> + <p>You can also add a second String parameter, which is the name of a class to instantiate the row with:</p> + + <code> + $query = $this->db->query("SELECT * FROM users LIMIT 1;");<br /> + <br /> + $query->row(0, 'User')<br /> + echo $row->name; // call attributes<br /> + echo $row->reverse_name(); // or methods defined on the 'User' class<br /> + </code> <h2>row_array()</h2> @@ -235,4 +256,4 @@ Next Topic: <a href="helpers.html">Query Helper Functions</a> </div> </body> -</html>
\ No newline at end of file +</html> diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html index d4296fe2e..4a8b6739e 100644 --- a/user_guide/database/utilities.html +++ b/user_guide/database/utilities.html @@ -96,19 +96,19 @@ already be running, since the utilities class relies on it.</p> <code> $dbs = $this->dbutil->list_databases();<br /> <br /> -foreach($dbs as $db)<br /> +foreach ($dbs as $db)<br /> {<br /> echo $db;<br /> }</code> -<h2><a name="exists"></a>$this->db->database_exists();</h2> +<h2><a name="exists"></a>$this->dbutil->database_exists();</h2> <p>Sometimes it's helpful to know whether a particular database exists. Returns a boolean TRUE/FALSE. Usage example:</p> <code> -if ($this->db->database_exists('database_name'))<br /> +if ($this->dbutil->database_exists('database_name'))<br /> {<br /> // some code...<br /> } |