diff options
Diffstat (limited to 'user_guide/database')
-rw-r--r-- | user_guide/database/active_record.html | 68 | ||||
-rw-r--r-- | user_guide/database/caching.html | 34 | ||||
-rw-r--r-- | user_guide/database/call_function.html | 8 | ||||
-rw-r--r-- | user_guide/database/configuration.html | 14 | ||||
-rw-r--r-- | user_guide/database/connecting.html | 6 | ||||
-rw-r--r-- | user_guide/database/examples.html | 12 | ||||
-rw-r--r-- | user_guide/database/fields.html | 4 | ||||
-rw-r--r-- | user_guide/database/forge.html | 10 | ||||
-rw-r--r-- | user_guide/database/helpers.html | 12 | ||||
-rw-r--r-- | user_guide/database/index.html | 2 | ||||
-rw-r--r-- | user_guide/database/queries.html | 14 | ||||
-rw-r--r-- | user_guide/database/results.html | 20 | ||||
-rw-r--r-- | user_guide/database/table_data.html | 6 | ||||
-rw-r--r-- | user_guide/database/transactions.html | 14 | ||||
-rw-r--r-- | user_guide/database/utilities.html | 18 |
15 files changed, 121 insertions, 121 deletions
diff --git a/user_guide/database/active_record.html b/user_guide/database/active_record.html index 566b260c9..62833813c 100644 --- a/user_guide/database/active_record.html +++ b/user_guide/database/active_record.html @@ -59,12 +59,12 @@ Active Record <p>CodeIgniter uses a modified version of the Active Record Database Pattern. This pattern allows information to be retrieved, inserted, and updated in your database with minimal scripting. In some cases only one or two lines of code are necessary to perform a database action. -CodeIgniter does not require that each database table be its own class file. It instead provides a more simplified interface.</p> +CodeIgniter does not require that each database table be its own class file. It instead provides a more simplified interface.</p> <p>Beyond simplicity, a major benefit to using the Active Record features is that it allows you to create database independent applications, since the query syntax -is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.</p> +is generated by each database adapter. It also allows for safer queries, since the values are escaped automatically by the system.</p> -<p class="important"><strong>Note:</strong> If you intend to write your own queries you can disable this class in your database config file, allowing the core database library and adapter to utilize fewer resources.<br /></p> +<p class="important"><strong>Note:</strong> If you intend to write your own queries you can disable this class in your database config file, allowing the core database library and adapter to utilize fewer resources.<br /></p> <ul> <li><a href="#select">Selecting Data</a></li> @@ -84,7 +84,7 @@ is generated by each database adapter. It also allows for safer queries, since t <h2>$this->db->get();</h2> -<p>Runs the selection query and returns the result. Can be used by itself to retrieve all records from a table:</p> +<p>Runs the selection query and returns the result. Can be used by itself to retrieve all records from a table:</p> <code>$query = $this->db->get('mytable');<br /> <br /> @@ -126,7 +126,7 @@ $this->db->select('title, content, date');<br /> $query = $this->db->get('mytable');<br /> <br /> // Produces: SELECT title, content, date FROM mytable</code></p> -<p class="important"><strong>Note:</strong> If you are selecting all (*) from a table you do not need to use this function. When omitted, CodeIgniter assumes you wish to SELECT *</p> +<p class="important"><strong>Note:</strong> If you are selecting all (*) from a table you do not need to use this function. When omitted, CodeIgniter assumes you wish to SELECT *</p> <p>$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.</p> <p><code>$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE); <br /> @@ -278,7 +278,7 @@ $this->db->or_where('id >', $id); <h2>$this->db->where_in();</h2> -<p>Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate</p> +<p>Generates a WHERE field IN ('item', 'item') SQL query joined with AND if appropriate</p> <p><code> $names = array('Frank', 'Todd', 'James');<br /> $this->db->where_in('username', $names);<br /> @@ -322,7 +322,7 @@ $this->db->or_where('id >', $id); <code>$this->db->like('title', 'match');<br /> $this->db->like('body', 'match'); <br /><br /> - // WHERE title LIKE '%match%' AND body LIKE '%match%</code> + // WHERE title LIKE '%match%' AND body LIKE '%match%</code> If you want to control where the wildcard (%) is placed, you can use an optional third argument. Your options are 'before', 'after' and 'both' (which is the default). <code>$this->db->like('title', 'match', 'before'); <br /> @@ -340,7 +340,7 @@ $this->db->or_where('id >', $id); $array = array('title' => $match, 'page1' => $match, 'page2' => $match);<br /><br /> $this->db->like($array); - <br /><br />// WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'</code></li> + <br /><br />// WHERE title LIKE '%match%' AND page1 LIKE '%match%' AND page2 LIKE '%match%'</code></li> </ol> @@ -351,7 +351,7 @@ $this->db->or_where('id >', $id); $this->db->like('title', 'match');<br /> $this->db->or_like('body', $match); <br /> -<br />// WHERE title LIKE '%match%' OR body LIKE '%match%'</code> +<br />// WHERE title LIKE '%match%' OR body LIKE '%match%'</code> @@ -367,7 +367,7 @@ $this->db->or_like('body', $match); <code> $this->db->like('title', 'match');<br /> $this->db->or_not_like('body', 'match'); <br /> <br /> -// WHERE title LIKE '%match% OR body NOT LIKE '%match%'</code> +// WHERE title LIKE '%match% OR body NOT LIKE '%match%'</code> <h2>$this->db->group_by();</h2> <p>Permits you to write the GROUP BY portion of your query:</p> @@ -385,7 +385,7 @@ $this->db->or_not_like('body', 'match'); <br /> <h2> $this->db->distinct();<br /> </h2> -<p>Adds the "DISTINCT" keyword to a query</p> +<p>Adds the "DISTINCT" keyword to a query</p> <p><code>$this->db->distinct();<br /> $this->db->get('table');<br /> <br /> @@ -397,7 +397,7 @@ $this->db->or_not_like('body', 'match'); <br /> <br /> // Produces: HAVING user_id = 45<br /> <br /> -$this->db->having('user_id', 45); <br /> +$this->db->having('user_id', 45); <br /> // Produces: HAVING user_id = 45<br /> <br /> </code> @@ -409,16 +409,16 @@ $this->db->having('user_id', 45); <br /> <br /> // Produces: HAVING title = 'My Title', id < 45</code></p> <p>If you are using a database that CodeIgniter escapes queries for, you can prevent escaping content by passing an optional third argument, and setting it to FALSE.</p> -<p><code>$this->db->having('user_id', 45); <br /> +<p><code>$this->db->having('user_id', 45); <br /> // Produces: HAVING `user_id` = 45 in some databases such as MySQL <br /> - $this->db->having('user_id', 45, FALSE); <br /> + $this->db->having('user_id', 45, FALSE); <br /> // Produces: HAVING user_id = 45</code></p> <h2>$this->db->or_having();</h2> <p>Identical to having(), only separates multiple clauses with "OR".</p> <h2>$this->db->order_by();</h2> <p>Lets you set an ORDER BY clause. The first parameter contains the name of the column you would like to order by. -The second parameter lets you set the direction of the result. Options are <kbd>asc</kbd> or <kbd>desc</kbd>, or <kbd>random</kbd>. </p> +The second parameter lets you set the direction of the result. Options are <kbd>asc</kbd> or <kbd>desc</kbd>, or <kbd>random</kbd>. </p> <code>$this->db->order_by("title", "desc"); <br /> @@ -455,12 +455,12 @@ $this->db->limit(10);<br /> <code> $this->db->limit(10, 20);<br /> <br /> -// Produces: LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)</code> +// Produces: LIMIT 20, 10 (in MySQL. Other databases have slightly different syntax)</code> <h2>$this->db->count_all_results();</h2> -<p>Permits you to determine the number of rows in a particular Active Record query. Queries will accept Active Record restrictors such as where(), or_where(), like(), or_like(), etc. Example:</p> +<p>Permits you to determine the number of rows in a particular Active Record query. Queries will accept Active Record restrictors such as where(), or_where(), like(), or_like(), etc. Example:</p> <code>echo $this->db->count_all_results('<var>my_table</var>');<br /> // Produces an integer, like 25<br /> @@ -472,7 +472,7 @@ echo $this->db->count_all_results();<br /> <h2>$this->db->count_all();</h2> -<p>Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:</p> +<p>Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:</p> <code>echo $this->db->count_all('<var>my_table</var>');<br /> <br /> @@ -485,7 +485,7 @@ echo $this->db->count_all_results();<br /> <h2>$this->db->insert();</h2> <p>Generates an insert string based on the data you supply, and runs the query. You can either pass an -<strong>array</strong> or an <strong>object</strong> to the function. Here is an example using an array:</p> +<strong>array</strong> or an <strong>object</strong> to the function. Here is an example using an array:</p> <code> $data = array(<br /> @@ -505,9 +505,9 @@ $this->db->insert('mytable', $data); <code> /*<br /> class Myclass {<br /> - var $title = 'My Title';<br /> - var $content = 'My Content';<br /> - var $date = 'My Date';<br /> + var $title = 'My Title';<br /> + var $content = 'My Content';<br /> + var $date = 'My Date';<br /> }<br /> */<br /> <br /> @@ -523,7 +523,7 @@ $this->db->insert('mytable', $object); <h2>$this->db->insert_batch();</h2> <p>Generates an insert string based on the data you supply, and runs the query. You can either pass an -<strong>array</strong> or an <strong>object</strong> to the function. Here is an example using an array:</p> +<strong>array</strong> or an <strong>object</strong> to the function. Here is an example using an array:</p> <code> $data = array(<br/> @@ -541,7 +541,7 @@ $data = array(<br/> <br /> $this->db->update_batch('mytable', $data); <br /><br /> -// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')</code> +// Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date'), ('Another title', 'Another name', 'Another date')</code> <p>The first parameter will contain the table name, the second is an associative array of values.</p> @@ -588,9 +588,9 @@ $this->db->insert('mytable'); <code> /*<br /> class Myclass {<br /> - var $title = 'My Title';<br /> - var $content = 'My Content';<br /> - var $date = 'My Date';<br /> + var $title = 'My Title';<br /> + var $content = 'My Content';<br /> + var $date = 'My Date';<br /> }<br /> */<br /> <br /> @@ -606,7 +606,7 @@ $this->db->insert('mytable'); <h1>Updating Data</h1> <h2>$this->db->update();</h2> -<p>Generates an update string and runs the query based on the data you supply. You can pass an +<p>Generates an update string and runs the query based on the data you supply. You can pass an <strong>array</strong> or an <strong>object</strong> to the function. Here is an example using an array:</p> @@ -630,9 +630,9 @@ $this->db->update('mytable', $data); <code> /*<br /> class Myclass {<br /> - var $title = 'My Title';<br /> - var $content = 'My Content';<br /> - var $date = 'My Date';<br /> + var $title = 'My Title';<br /> + var $content = 'My Content';<br /> + var $date = 'My Date';<br /> }<br /> */<br /> <br /> @@ -711,7 +711,7 @@ $this->db->truncate('mytable'); <br /> <h1><a name="chaining"> </a>Method Chaining</h1> -<p>Method chaining allows you to simplify your syntax by connecting multiple functions. Consider this example:</p> +<p>Method chaining allows you to simplify your syntax by connecting multiple functions. Consider this example:</p> <code> <dfn>$this->db</dfn><kbd>-></kbd><var>select</var>('title')<kbd>-></kbd><var>from</var>('mytable')<kbd>-></kbd><var>where</var>('id', $id)<kbd>-></kbd><var>limit</var>(10, 20);<br /> @@ -752,14 +752,14 @@ $this->db->get('tablename');<br /> $this->db->select('field2');<br /> $this->db->get('tablename');<br /> <br /> -//Generates: SELECT `field1`, `field2` FROM (`tablename`)<br /> +//Generates: SELECT `field1`, `field2` FROM (`tablename`)<br /> <br /> $this->db->flush_cache();<br /> <br /> $this->db->select('field2');<br /> $this->db->get('tablename');<br /> <br /> -//Generates: SELECT `field2` FROM (`tablename`)</code></p> +//Generates: SELECT `field2` FROM (`tablename`)</code></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> diff --git a/user_guide/database/caching.html b/user_guide/database/caching.html index 76a91216d..3f4ef2bc3 100644 --- a/user_guide/database/caching.html +++ b/user_guide/database/caching.html @@ -62,7 +62,7 @@ Database Caching Class <p>The Database Caching Class permits you to cache your queries as text files for reduced database load.</p> <p class="important"><strong>Important:</strong> This class is initialized automatically by the database driver -when caching is enabled. Do NOT load this class manually.<br /><br /> +when caching is enabled. Do NOT load this class manually.<br /><br /> <strong>Also note:</strong> Not all query result functions are available when you use caching. Please read this page carefully.</p> @@ -84,12 +84,12 @@ when caching is enabled. Do NOT load this class manually.<br /><br /> <p>CodeIgniter's query caching system happens dynamically when your pages are viewed. When caching is enabled, the first time a web page is loaded, the query result object will be serialized and stored in a text file on your server. The next time the page is loaded the cache file will be used instead of -accessing your database. Your database usage can effectively be reduced to zero for any pages that have been cached.</p> +accessing your database. Your database usage can effectively be reduced to zero for any pages that have been cached.</p> <p>Only <dfn>read-type</dfn> (SELECT) queries can be cached, since these are the only type of queries that produce a result. <dfn>Write-type</dfn> (INSERT, UPDATE, etc.) queries, since they don't generate a result, will not be cached by the system.</p> -<p>Cache files DO NOT expire. Any queries that have been cached will remain cached until you delete them. The caching system +<p>Cache files DO NOT expire. Any queries that have been cached will remain cached until you delete them. The caching system permits you clear caches associated with individual pages, or you can delete the entire collection of cache files. Typically you'll want to use the housekeeping functions described below to delete cache files after certain events take place, like when you've added new information to your database.</p> @@ -99,33 +99,33 @@ events take place, like when you've added new information to your database.</p> <p>Getting a performance gain as a result of caching depends on many factors. If you have a highly optimized database under very little load, you probably won't see a performance boost. If your database is under heavy use you probably will see an improved response, assuming your file-system is not -overly taxed. Remember that caching simply changes how your information is retrieved, shifting it from being a database +overly taxed. Remember that caching simply changes how your information is retrieved, shifting it from being a database operation to a file-system one.</p> <p>In some clustered server environments, for example, caching may be detrimental since file-system operations are so intense. On single servers in shared environments, caching will probably be beneficial. Unfortunately there is no -single answer to the question of whether you should cache your database. It really depends on your situation.</p> +single answer to the question of whether you should cache your database. It really depends on your situation.</p> <h2>How are Cache Files Stored?</h2> -<p>CodeIgniter places the result of EACH query into its own cache file. Sets of cache files are further organized into -sub-folders corresponding to your controller functions. To be precise, the sub-folders are named identically to the +<p>CodeIgniter places the result of EACH query into its own cache file. Sets of cache files are further organized into +sub-folders corresponding to your controller functions. To be precise, the sub-folders are named identically to the first two segments of your URI (the controller class name and function name).</p> <p>For example, let's say you have a controller called <dfn>blog</dfn> with a function called <dfn>comments</dfn> that -contains three queries. The caching system will create a cache folder +contains three queries. The caching system will create a cache folder called <kbd>blog+comments</kbd>, into which it will write three cache files.</p> <p>If you use dynamic queries that change based on information in your URI (when using pagination, for example), each instance of -the query will produce its own cache file. It's possible, therefore, to end up with many times more cache files than you have +the query will produce its own cache file. It's possible, therefore, to end up with many times more cache files than you have queries.</p> <h2>Managing your Cache Files</h2> -<p>Since cache files do not expire, you'll need to build deletion routines into your application. For example, let's say you have a blog -that allows user commenting. Whenever a new comment is submitted you'll want to delete the cache files associated with the -controller function that serves up your comments. You'll find two delete functions described below that help you +<p>Since cache files do not expire, you'll need to build deletion routines into your application. For example, let's say you have a blog +that allows user commenting. Whenever a new comment is submitted you'll want to delete the cache files associated with the +controller function that serves up your comments. You'll find two delete functions described below that help you clear data.</p> @@ -155,8 +155,8 @@ pertain to run-time operations.</p> <h2>$this->db->cache_on() / $this->db->cache_off()</h2> -<p>Manually enables/disables caching. This can be useful if you want to -keep certain queries from being cached. Example:</p> +<p>Manually enables/disables caching. This can be useful if you want to +keep certain queries from being cached. Example:</p> <code> // Turn caching on<br /> @@ -177,9 +177,9 @@ $query = $this->db->query("SELECT * FROM another_table"); <p>Deletes the cache files associated with a particular page. This is useful if you need to clear caching after you update your database.</p> -<p>The caching system saves your cache files to folders that correspond to the URI of the page you are viewing. For example, if you are viewing +<p>The caching system saves your cache files to folders that correspond to the URI of the page you are viewing. For example, if you are viewing a page at <dfn>example.com/index.php/blog/comments</dfn>, the caching system will put all cache files associated with it in a folder -called <dfn>blog+comments</dfn>. To delete those particular cache files you will use:</p> +called <dfn>blog+comments</dfn>. To delete those particular cache files you will use:</p> <code>$this->db->cache_delete('blog', 'comments');</code> @@ -188,7 +188,7 @@ called <dfn>blog+comments</dfn>. To delete those particular cache files you will <h2>$this->db->cache_delete_all()</h2> -<p>Clears all existing cache files. Example:</p> +<p>Clears all existing cache files. Example:</p> <code>$this->db->cache_delete_all();</code> diff --git a/user_guide/database/call_function.html b/user_guide/database/call_function.html index 7f294401e..3e0c78d3d 100644 --- a/user_guide/database/call_function.html +++ b/user_guide/database/call_function.html @@ -63,13 +63,13 @@ Custom Function Calls <p>This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner. For example, lets say you want to call the <dfn>mysql_get_client_info()</dfn> function, which is <strong>not</strong> natively supported -by CodeIgniter. You could do so like this: +by CodeIgniter. You could do so like this: </p> <code>$this->db->call_function('<var>get_client_info</var>');</code> -<p>You must supply the name of the function, <strong>without</strong> the <var>mysql_</var> prefix, in the first parameter. The prefix is added -automatically based on which database driver is currently being used. This permits you to run the same function on different database platforms. +<p>You must supply the name of the function, <strong>without</strong> the <var>mysql_</var> prefix, in the first parameter. The prefix is added +automatically based on which database driver is currently being used. This permits you to run the same function on different database platforms. Obviously not all function calls are identical between platforms, so there are limits to how useful this function can be in terms of portability.</p> <p>Any parameters needed by the function you are calling will be added to the second parameter.</p> @@ -77,7 +77,7 @@ Obviously not all function calls are identical between platforms, so there are l <code>$this->db->call_function('<var>some_function</var>', $param1, $param2, etc..);</code> -<p>Often, you will either need to supply a database connection ID or a database result ID. The connection ID can be accessed using:</p> +<p>Often, you will either need to supply a database connection ID or a database result ID. The connection ID can be accessed using:</p> <code>$this->db->conn_id;</code> diff --git a/user_guide/database/configuration.html b/user_guide/database/configuration.html index 439717748..4ea2e6b3d 100644 --- a/user_guide/database/configuration.html +++ b/user_guide/database/configuration.html @@ -74,7 +74,7 @@ $db['default']['dbprefix'] = "";<br /> $db['default']['pconnect'] = TRUE;<br /> $db['default']['db_debug'] = FALSE;<br /> $db['default']['cache_on'] = FALSE;<br /> -$db['default']['cachedir'] = "";<br /> +$db['default']['cachedir'] = "";<br /> $db['default']['char_set'] = "utf8";<br /> $db['default']['dbcollat'] = "utf8_general_ci";<br /> $db['default']['swap_pre'] = "";<br /> @@ -82,7 +82,7 @@ $db['default']['autoinit'] = TRUE;<br /> $db['default']['stricton'] = FALSE;</code> <p>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.) +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:</p> @@ -95,7 +95,7 @@ $db['test']['dbprefix'] = "";<br /> $db['test']['pconnect'] = TRUE;<br /> $db['test']['db_debug'] = FALSE;<br /> $db['test']['cache_on'] = FALSE;<br /> -$db['test']['cachedir'] = "";<br /> +$db['test']['cachedir'] = "";<br /> $db['test']['char_set'] = "utf8";<br /> $db['test']['dbcollat'] = "utf8_general_ci";<br /> $db['test']['swap_pre'] = "";<br /> @@ -107,7 +107,7 @@ $db['test']['stricton'] = FALSE;</code> <code>$active_group = "test";</code> -<p>Note: The name "test" is arbitrary. It can be anything you want. By default we've used the word "default" +<p>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.</p> <h3>Active Record</h3> @@ -126,7 +126,7 @@ for the primary connection, but it too can be renamed to something more relevant <li><strong>password</strong> - The password used to connect to the database.</li> <li><strong>database</strong> - The name of the database you want to connect to.</li> <li><strong>dbdriver</strong> - The database type. ie: mysql, postgres, odbc, etc. Must be specified in lower case.</li> -<li><strong>dbprefix</strong> - An optional table prefix which will added to the table name when running <a href="active_record.html">Active Record</a> queries. This permits multiple CodeIgniter installations to share one database.</li> +<li><strong>dbprefix</strong> - An optional table prefix which will added to the table name when running <a href="active_record.html">Active Record</a> queries. This permits multiple CodeIgniter installations to share one database.</li> <li><strong>pconnect</strong> - TRUE/FALSE (boolean) - Whether to use a persistent connection.</li> <li><strong>db_debug</strong> - TRUE/FALSE (boolean) - Whether database errors should be displayed.</li> <li><strong>cache_on</strong> - TRUE/FALSE (boolean) - Whether database query caching is enabled, see also <a href="caching.html">Database Caching Class</a>.</li> @@ -136,11 +136,11 @@ for the primary connection, but it too can be renamed to something more relevant <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 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> +<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> <p class="important"><strong>Note:</strong> 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 +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.</p> diff --git a/user_guide/database/connecting.html b/user_guide/database/connecting.html index 1a74f5571..bb1b401f9 100644 --- a/user_guide/database/connecting.html +++ b/user_guide/database/connecting.html @@ -84,8 +84,8 @@ to the group specified in your database config file. For most people, this is th <ol> <li>The database connection values, passed either as an array or a DSN string.</li> - <li>TRUE/FALSE (boolean). Whether to return the connection ID (see Connecting to Multiple Databases below).</li> - <li>TRUE/FALSE (boolean). Whether to enable the Active Record class. Set to TRUE by default.</li> + <li>TRUE/FALSE (boolean). Whether to return the connection ID (see Connecting to Multiple Databases below).</li> + <li>TRUE/FALSE (boolean). Whether to enable the Active Record class. Set to TRUE by default.</li> </ol> @@ -148,7 +148,7 @@ you can pass the connection values as indicated above).</p> <p>By setting the second parameter to TRUE (boolean) the function will return the database object.</p> <div class="important"> -<p>When you connect this way, you will use your object name to issue commands rather than the syntax used throughout this guide. In other words, rather than issuing commands with:</p> +<p>When you connect this way, you will use your object name to issue commands rather than the syntax used throughout this guide. In other words, rather than issuing commands with:</p> <p>$this->db->query();<br />$this->db->result();<br /> etc...</p> diff --git a/user_guide/database/examples.html b/user_guide/database/examples.html index 6bb8beb32..535fa3177 100644 --- a/user_guide/database/examples.html +++ b/user_guide/database/examples.html @@ -61,7 +61,7 @@ Database Example Code <h1>Database Quick Start: Example Code</h1> -<p>The following page contains example code showing how the database class is used. For complete details please +<p>The following page contains example code showing how the database class is used. For complete details please read the individual pages describing each function.</p> @@ -73,7 +73,7 @@ read the individual pages describing each function.</p> <p>Once loaded the class is ready to be used as described below.</p> -<p>Note: If all your pages require database access you can connect automatically. See the <a href="connecting.html">connecting</a> page for details.</p> +<p>Note: If all your pages require database access you can connect automatically. See the <a href="connecting.html">connecting</a> page for details.</p> <h2>Standard Query With Multiple Results (Object Version)</h2> @@ -90,7 +90,7 @@ foreach ($query->result() as $row)<br /> echo 'Total Results: ' . $query->num_rows(); </code> -<p>The above <dfn>result()</dfn> function returns an array of <strong>objects</strong>. Example: $row->title</p> +<p>The above <dfn>result()</dfn> function returns an array of <strong>objects</strong>. Example: $row->title</p> <h2>Standard Query With Multiple Results (Array Version)</h2> @@ -104,7 +104,7 @@ foreach ($query->result_array() as $row)<br /> echo $row['email'];<br /> }</code> -<p>The above <dfn>result_array()</dfn> function returns an array of standard array indexes. Example: $row['title']</p> +<p>The above <dfn>result_array()</dfn> function returns an array of standard array indexes. Example: $row['title']</p> <h2>Testing for Results</h2> @@ -137,7 +137,7 @@ $row = $query->row();<br /> echo $row->name;<br /> </code> -<p>The above <dfn>row()</dfn> function returns an <strong>object</strong>. Example: $row->name</p> +<p>The above <dfn>row()</dfn> function returns an <strong>object</strong>. Example: $row->name</p> <h2>Standard Query With Single Result (Array version)</h2> @@ -148,7 +148,7 @@ $row = $query->row_array();<br /> echo $row['name'];<br /> </code> -<p>The above <dfn>row_array()</dfn> function returns an <strong>array</strong>. Example: $row['name']</p> +<p>The above <dfn>row_array()</dfn> function returns an <strong>array</strong>. Example: $row['name']</p> <h2>Standard Insert</h2> diff --git a/user_guide/database/fields.html b/user_guide/database/fields.html index b20436129..04d8b8096 100644 --- a/user_guide/database/fields.html +++ b/user_guide/database/fields.html @@ -92,7 +92,7 @@ foreach ($query->list_fields() as $field)<br /> <h2>$this->db->field_exists()</h2> <p>Sometimes it's helpful to know whether a particular field exists before performing an action. -Returns a boolean TRUE/FALSE. Usage example:</p> +Returns a boolean TRUE/FALSE. Usage example:</p> <code> if ($this->db->field_exists('field_name', 'table_name'))<br /> @@ -101,7 +101,7 @@ if ($this->db->field_exists('field_name', 'table_name'))<br /> } </code> -<p>Note: Replace <em>field_name</em> with the name of the column you are looking for, and replace +<p>Note: Replace <em>field_name</em> with the name of the column you are looking for, and replace <em>table_name</em> with the name of the table you are looking for.</p> diff --git a/user_guide/database/forge.html b/user_guide/database/forge.html index bbef053e4..cad2cf26f 100644 --- a/user_guide/database/forge.html +++ b/user_guide/database/forge.html @@ -151,7 +151,7 @@ already be running, since the forge class relies on it.</p> ),<br /> );<br /> </code></p> -<p>After the fields have been defined, they can be added using <dfn>$this->dbforge->add_field($fields);</dfn> followed by a call to the <dfn>create_table()</dfn> function.</p> +<p>After the fields have been defined, they can be added using <dfn>$this->dbforge->add_field($fields);</dfn> followed by a call to the <dfn>create_table()</dfn> function.</p> <h3>$this->dbforge->add_field()</h3> <p>The add fields function will accept the above array.</p> <h3>Passing strings as fields</h3> @@ -164,7 +164,7 @@ already be running, since the forge class relies on it.</p> // gives id INT(9) NOT NULL AUTO_INCREMENT</code></p> <h2><a name="add_key" id="add_key"></a>Adding Keys</h2> <p>Generally speaking, you'll want your table to have Keys. This is accomplished with <dfn>$this->dbforge->add_key('field')</dfn>. An optional second parameter set to TRUE will make it a primary key. Note that <dfn>add_key()</dfn> must be followed by a call to <dfn>create_table()</dfn>.</p> -<p>Multiple column non-primary keys must be sent as an array. Sample output below is for MySQL.</p> +<p>Multiple column non-primary keys must be sent as an array. Sample output below is for MySQL.</p> <p><code>$this->dbforge->add_key('blog_id', TRUE);<br /> // gives PRIMARY KEY `blog_id` (`blog_id`)<br /> <br /> @@ -187,7 +187,7 @@ already be running, since the forge class relies on it.</p> <h2><a name="drop_table" id="drop_table"></a>Dropping a table</h2> <p>Executes a DROP TABLE sql</p> <p><code>$this->dbforge->drop_table('table_name');<br /> - // gives DROP TABLE IF EXISTS table_name</code></p> + // gives DROP TABLE IF EXISTS table_name</code></p> <h2><a name="rename_table" id="rename_table"></a>Renaming a table</h2> <p>Executes a TABLE rename</p> <p><code>$this->dbforge->rename_table('old_table_name', 'new_table_name');<br /> @@ -200,7 +200,7 @@ already be running, since the forge class relies on it.</p> );<br /> $this->dbforge->add_column('table_name', $fields);<br /> <br /> -// gives ALTER TABLE table_name ADD preferences TEXT</code></p> +// gives ALTER TABLE table_name ADD preferences TEXT</code></p> <h2>$this->dbforge->drop_column()</h2> <p>Used to remove a column from a table. </p> <p><code>$this->dbforge->drop_column('table_name', 'column_to_drop');</code></p> @@ -214,7 +214,7 @@ $this->dbforge->add_column('table_name', $fields);<br /> );<br /> $this->dbforge->modify_column('table_name', $fields);<br /> <br /> - // gives ALTER TABLE table_name CHANGE old_name new_name TEXT </code></p> + // gives ALTER TABLE table_name CHANGE old_name new_name TEXT </code></p> <p> </p> </div> <!-- END CONTENT --> diff --git a/user_guide/database/helpers.html b/user_guide/database/helpers.html index 650dd7a0b..107d2ed85 100644 --- a/user_guide/database/helpers.html +++ b/user_guide/database/helpers.html @@ -67,12 +67,12 @@ Query Helpers <h2>$this->db->affected_rows()</h2> <p>Displays the number of affected rows, when doing "write" type queries (insert, update, etc.).</p> -<p>Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the -correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.</p> +<p>Note: In MySQL "DELETE FROM TABLE" returns 0 affected rows. The database class has a small hack that allows it to return the +correct number of affected rows. By default this hack is enabled but it can be turned off in the database driver file.</p> <h2>$this->db->count_all();</h2> -<p>Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:</p> +<p>Permits you to determine the number of rows in a particular table. Submit the table name in the first parameter. Example:</p> <code>echo $this->db->count_all('<var>my_table</var>');<br /> <br /> // Produces an integer, like 25 @@ -90,11 +90,11 @@ correct number of affected rows. By default this hack is enabled but it can be t <h2>$this->db->last_query();</h2> -<p>Returns the last query that was run (the query string, not the result). Example:</p> +<p>Returns the last query that was run (the query string, not the result). Example:</p> <code>$str = $this->db->last_query();<br /> <br /> -// Produces: SELECT * FROM sometable.... +// Produces: SELECT * FROM sometable.... </code> @@ -109,7 +109,7 @@ correct number of affected rows. By default this hack is enabled but it can be t $str = $this->db->insert_string('table_name', $data); </code> -<p>The first parameter is the table name, the second is an associative array with the data to be inserted. The above example produces:</p> +<p>The first parameter is the table name, the second is an associative array with the data to be inserted. The above example produces:</p> <code>INSERT INTO table_name (name, email, url) VALUES ('Rick', 'rick@example.com', 'example.com')</code> <p class="important">Note: Values are automatically escaped, producing safer queries.</p> diff --git a/user_guide/database/index.html b/user_guide/database/index.html index 1f0a1da7d..9c67e3b79 100644 --- a/user_guide/database/index.html +++ b/user_guide/database/index.html @@ -63,7 +63,7 @@ Database Library structures and Active Record patterns. The database functions offer clear, simple syntax.</p> <ul> - <li><a href="examples.html">Quick Start: Usage Examples</a></li> + <li><a href="examples.html">Quick Start: Usage Examples</a></li> <li><a href="configuration.html">Database Configuration</a></li> <li><a href="connecting.html">Connecting to a Database</a></li> <li><a href="queries.html">Running Queries</a></li> diff --git a/user_guide/database/queries.html b/user_guide/database/queries.html index 685da43dc..f9f96803f 100644 --- a/user_guide/database/queries.html +++ b/user_guide/database/queries.html @@ -68,14 +68,14 @@ Queries <code>$this->db->query('YOUR QUERY HERE');</code> <p>The <dfn>query()</dfn> function returns a database result <strong>object</strong> when "read" type queries are run, -which you can use to <a href="results.html">show your results</a>. When "write" type queries are run it simply returns TRUE or FALSE -depending on success or failure. When retrieving data you will typically assign the query to your own variable, like this:</p> +which you can use to <a href="results.html">show your results</a>. When "write" type queries are run it simply returns TRUE or FALSE +depending on success or failure. When retrieving data you will typically assign the query to your own variable, like this:</p> <code><var>$query</var> = $this->db->query('YOUR QUERY HERE');</code> <h2>$this->db->simple_query();</h2> -<p>This is a simplified version of the <dfn>$this->db->query()</dfn> function. It ONLY returns TRUE/FALSE on success or failure. +<p>This is a simplified version of the <dfn>$this->db->query()</dfn> function. It ONLY returns TRUE/FALSE on success or failure. It DOES NOT return a database result set, nor does it set the query timer, or compile bind data, or store your query for debugging. It simply lets you submit a query. Most users will rarely use this function.</p> @@ -100,16 +100,16 @@ CodeIgniter has three methods that help you do this:</p> <ol> <li><strong>$this->db->escape()</strong> This function determines the data type so that it -can escape only string data. It also automatically adds single quotes around the data so you don't have to: +can escape only string data. It also automatically adds single quotes around the data so you don't have to: <code>$sql = "INSERT INTO table (title) VALUES(".$this->db->escape($title).")";</code></li> -<li><strong>$this->db->escape_str()</strong> This function escapes the data passed to it, regardless of type. +<li><strong>$this->db->escape_str()</strong> This function escapes the data passed to it, regardless of type. Most of the time you'll use the above function rather than this one. Use the function like this: <code>$sql = "INSERT INTO table (title) VALUES('".$this->db->escape_str($title)."')";</code></li> -<li><strong>$this->db->escape_like_str()</strong> This method should be used when strings are to be used in LIKE +<li><strong>$this->db->escape_like_str()</strong> This method should be used when strings are to be used in LIKE conditions so that LIKE wildcards ('%', '_') in the string are also properly escaped. <code>$search = '20% raise';<br /> @@ -130,7 +130,7 @@ $this->db->query($sql, array(3, 'live', 'Rick')); </code> <p>The question marks in the query are automatically replaced with the values in the array in the second parameter of the query function.</p> -<p class="important">The secondary benefit of using binds is that the values are automatically escaped, producing safer queries. You don't have to remember to manually escape data; the engine does it automatically for you.</p> +<p class="important">The secondary benefit of using binds is that the values are automatically escaped, producing safer queries. You don't have to remember to manually escape data; the engine does it automatically for you.</p> diff --git a/user_guide/database/results.html b/user_guide/database/results.html index 0b82752a7..8ad6a1986 100644 --- a/user_guide/database/results.html +++ b/user_guide/database/results.html @@ -112,7 +112,7 @@ Query Results <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> + <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> <code> $query = $this->db->query("YOUR QUERY");<br /> <br /> @@ -126,8 +126,8 @@ Query Results <h2>row()</h2> - <p>This function returns a single result row. If your query has more than one row, it returns only the first row. - The result is returned as an <strong>object</strong>. Here's a usage example:</p> + <p>This function returns a single result row. If your query has more than one row, it returns only the first row. + The result is returned as an <strong>object</strong>. Here's a usage example:</p> <code> $query = $this->db->query("YOUR QUERY");<br /> <br /> @@ -157,7 +157,7 @@ Query Results <h2>row_array()</h2> - <p>Identical to the above <var>row()</var> function, except it returns an array. Example:</p> + <p>Identical to the above <var>row()</var> function, except it returns an array. Example:</p> <code> $query = $this->db->query("YOUR QUERY");<br /> @@ -209,7 +209,7 @@ echo $query->num_rows(); </code> <h2>$query->num_fields()</h2> -<p>The number of FIELDS (columns) returned by the query. Make sure to call the function using your query result object:</p> +<p>The number of FIELDS (columns) returned by the query. Make sure to call the function using your query result object:</p> <code>$query = $this->db->query('SELECT * FROM my_table');<br /><br /> echo $query->num_fields(); @@ -218,9 +218,9 @@ echo $query->num_fields(); <h2>$query->free_result()</h2> -<p>It frees the memory associated with the result and deletes the result resource ID. Normally PHP frees its memory automatically at the end of script -execution. However, if you are running a lot of queries in a particular script you might want to free the result after each query result has been -generated in order to cut down on memory consumptions. Example: +<p>It frees the memory associated with the result and deletes the result resource ID. Normally PHP frees its memory automatically at the end of script +execution. However, if you are running a lot of queries in a particular script you might want to free the result after each query result has been +generated in order to cut down on memory consumptions. Example: </p> <code>$query = $this->db->query('SELECT title FROM my_table');<br /><br /> @@ -228,12 +228,12 @@ foreach ($query->result() as $row)<br /> {<br /> echo $row->title;<br /> }<br /> -$query->free_result(); // The $query result object will no longer be available<br /> +$query->free_result(); // The $query result object will no longer be available<br /> <br /> $query2 = $this->db->query('SELECT name FROM some_table');<br /><br /> $row = $query2->row();<br /> echo $row->name;<br /> -$query2->free_result(); // The $query2 result object will no longer be available +$query2->free_result(); // The $query2 result object will no longer be available </code> diff --git a/user_guide/database/table_data.html b/user_guide/database/table_data.html index 631e3b9d1..a2aaa99a8 100644 --- a/user_guide/database/table_data.html +++ b/user_guide/database/table_data.html @@ -65,7 +65,7 @@ Table Data <h2>$this->db->list_tables();</h2> -<p>Returns an array containing the names of all the tables in the database you are currently connected to. Example:</p> +<p>Returns an array containing the names of all the tables in the database you are currently connected to. Example:</p> <code>$tables = $this->db->list_tables();<br /> <br /> @@ -79,7 +79,7 @@ foreach ($tables as $table)<br /> <h2>$this->db->table_exists();</h2> <p>Sometimes it's helpful to know whether a particular table exists before running an operation on it. -Returns a boolean TRUE/FALSE. Usage example:</p> +Returns a boolean TRUE/FALSE. Usage example:</p> <code> if ($this->db->table_exists('table_name'))<br /> @@ -88,7 +88,7 @@ if ($this->db->table_exists('table_name'))<br /> } </code> -<p>Note: Replace <em>table_name</em> with the name of the table you are looking for.</p> +<p>Note: Replace <em>table_name</em> with the name of the table you are looking for.</p> diff --git a/user_guide/database/transactions.html b/user_guide/database/transactions.html index 68d76dff6..74945d434 100644 --- a/user_guide/database/transactions.html +++ b/user_guide/database/transactions.html @@ -61,18 +61,18 @@ Transactions <h1>Transactions</h1> -<p>CodeIgniter's database abstraction allows you to use <dfn>transactions</dfn> with databases that support transaction-safe table types. In MySQL, you'll need -to be running InnoDB or BDB table types rather than the more common MyISAM. Most other database platforms support transactions natively.</p> +<p>CodeIgniter's database abstraction allows you to use <dfn>transactions</dfn> with databases that support transaction-safe table types. In MySQL, you'll need +to be running InnoDB or BDB table types rather than the more common MyISAM. Most other database platforms support transactions natively.</p> <p>If you are not familiar with -transactions we recommend you find a good online resource to learn about them for your particular database. The information below assumes you +transactions we recommend you find a good online resource to learn about them for your particular database. The information below assumes you have a basic understanding of transactions. </p> <h2>CodeIgniter's Approach to Transactions</h2> -<p>CodeIgniter utilizes an approach to transactions that is very similar to the process used by the popular database class ADODB. We've chosen that approach -because it greatly simplifies the process of running transactions. In most cases all that is required are two lines of code.</p> +<p>CodeIgniter utilizes an approach to transactions that is very similar to the process used by the popular database class ADODB. We've chosen that approach +because it greatly simplifies the process of running transactions. In most cases all that is required are two lines of code.</p> <p>Traditionally, transactions have required a fair amount of work to implement since they demand that you to keep track of your queries and determine whether to <dfn>commit</dfn> or <dfn>rollback</dfn> based on the success or failure of your queries. This is particularly cumbersome with @@ -98,7 +98,7 @@ of any given query.</p> <h2>Strict Mode</h2> -<p>By default CodeIgniter runs all transactions in <dfn>Strict Mode</dfn>. When strict mode is enabled, if you are running multiple groups of +<p>By default CodeIgniter runs all transactions in <dfn>Strict Mode</dfn>. When strict mode is enabled, if you are running multiple groups of transactions, if one group fails all groups will be rolled back. If strict mode is disabled, each group is treated independently, meaning a failure of one group will not affect any others.</p> @@ -127,7 +127,7 @@ if (<kbd>$this->db->trans_status()</kbd> === FALSE)<br /> <h2>Enabling Transactions</h2> -<p>Transactions are enabled automatically the moment you use <dfn>$this->db->trans_start()</dfn>. If you would like to disable transactions you +<p>Transactions are enabled automatically the moment you use <dfn>$this->db->trans_start()</dfn>. If you would like to disable transactions you can do so using <dfn>$this->db->trans_off()</dfn>:</p> <code> diff --git a/user_guide/database/utilities.html b/user_guide/database/utilities.html index 64343cc01..582ea2ce4 100644 --- a/user_guide/database/utilities.html +++ b/user_guide/database/utilities.html @@ -105,7 +105,7 @@ foreach ($dbs as $db)<br /> <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> +Returns a boolean TRUE/FALSE. Usage example:</p> <code> if ($this->dbutil->database_exists('database_name'))<br /> @@ -114,7 +114,7 @@ if ($this->dbutil->database_exists('database_name'))<br /> } </code> -<p>Note: Replace <em>database_name</em> with the name of the table you are looking for. This function is case sensitive.</p> +<p>Note: Replace <em>database_name</em> with the name of the table you are looking for. This function is case sensitive.</p> @@ -184,7 +184,7 @@ echo $this->dbutil->csv_from_result($query); </code> <p>The second and third parameters allows you to -set the delimiter and newline character. By default tabs are used as the delimiter and "\n" is used as a new line. Example:</p> +set the delimiter and newline character. By default tabs are used as the delimiter and "\n" is used as a new line. Example:</p> <code> $delimiter = ",";<br /> @@ -193,14 +193,14 @@ $newline = "\r\n";<br /> echo $this->dbutil->csv_from_result($query, $delimiter, $newline); </code> -<p><strong>Important:</strong> This function will NOT write the CSV file for you. It simply creates the CSV layout. +<p><strong>Important:</strong> This function will NOT write the CSV file for you. It simply creates the CSV layout. If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p> <h2><a name="xml"></a>$this->dbutil->xml_from_result($db_result)</h2> <p>Permits you to generate an XML file from a query result. The first parameter expects a query result object, the second -may contain an optional array of config parameters. Example:</p> +may contain an optional array of config parameters. Example:</p> <code> $this->load->dbutil();<br /> @@ -217,18 +217,18 @@ $config = array (<br /> echo $this->dbutil->xml_from_result($query, $config); </code> -<p><strong>Important:</strong> This function will NOT write the XML file for you. It simply creates the XML layout. +<p><strong>Important:</strong> This function will NOT write the XML file for you. It simply creates the XML layout. If you need to write the file use the <a href="../helpers/file_helper.html">File Helper</a>.</p> <h2><a name="backup"></a>$this->dbutil->backup()</h2> -<p>Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format.</p> +<p>Permits you to backup your full database or individual tables. The backup data can be compressed in either Zip or Gzip format.</p> <p class="important"><strong>Note:</strong> This features is only available for MySQL databases.</p> <p>Note: Due to the limited execution time and memory available to PHP, backing up very large -databases may not be possible. If your database is very large you might need to backup directly from your SQL server +databases may not be possible. If your database is very large you might need to backup directly from your SQL server via the command line, or have your server admin do it for you if you do not have root privileges.</p> <h3>Usage Example</h3> @@ -278,7 +278,7 @@ $this->dbutil->backup($prefs); <th>Options</th> <th>Description</th> </tr><tr> -<td class="td"><strong>tables</strong></td><td class="td">empty array</td><td class="td">None</td><td class="td">An array of tables you want backed up. If left blank all tables will be exported.</td> +<td class="td"><strong>tables</strong></td><td class="td">empty array</td><td class="td">None</td><td class="td">An array of tables you want backed up. If left blank all tables will be exported.</td> </tr><tr> <td class="td"><strong>ignore</strong></td><td class="td">empty array</td><td class="td">None</td><td class="td">An array of tables you want the backup routine to ignore.</td> </tr><tr> |