summaryrefslogtreecommitdiffstats
path: root/user_guide
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-24 05:04:10 +0200
committeradmin <devnull@localhost>2006-09-24 05:04:10 +0200
commit3c023b12c3d27f0e2773e671b854e52e2dc0d1d6 (patch)
treefa8f9c716ed8d81ddadcbcb6e64ffa0cc7adabbd /user_guide
parent6bc014118c087c1c29ec0c1e509598218e3b5bc0 (diff)
Diffstat (limited to 'user_guide')
-rw-r--r--user_guide/libraries/database/index.html7
-rw-r--r--user_guide/libraries/database/queries.html62
-rw-r--r--user_guide/libraries/database/results.html36
3 files changed, 17 insertions, 88 deletions
diff --git a/user_guide/libraries/database/index.html b/user_guide/libraries/database/index.html
index d50ff9292..0d45e1a4f 100644
--- a/user_guide/libraries/database/index.html
+++ b/user_guide/libraries/database/index.html
@@ -70,9 +70,10 @@ structures and Active Record patterns. The database functions offer clear, simpl
<ul>
<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 Your Database</a></li>
- <li><a href="queries.html">Queries</a></li>
- <li><a href="results.html">Query Results</a></li>
+ <li><a href="connecting.html">Connecting to a Database</a></li>
+ <li><a href="queries.html">Running Queries</a></li>
+ <li><a href="results.html">Generating Query Results</a></li>
+ <li><a href="helpers.html">Query Helper Functions</a></li>
<li><a href="active_record.html">Active Record Class</a></li>
<li><a href="transactions.html">Transactions</a></li>
<li><a href="fields.html">Field MetaData</a></li>
diff --git a/user_guide/libraries/database/queries.html b/user_guide/libraries/database/queries.html
index bfba04700..f5a06e3a9 100644
--- a/user_guide/libraries/database/queries.html
+++ b/user_guide/libraries/database/queries.html
@@ -66,17 +66,26 @@ Queries
<h1>Queries</h1>
+<h2>$this->db->query();</h2>
+
<p>To submit a query, use the following function:</p>
<code>$this->db->query('YOUR QUERY HERE');</code>
-<p>The <dfn>query()</dfn> function returns a database result <strong>object</strong>
-which you can use to <a href="results.html">show your results</a>. You will typically assign the query to your own variable, like this:</p>
+<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>
<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.
+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>
-<h2>Escaping Queries</h2>
+
+<h1><br />Escaping Queries</h1>
<p>It's a very good security practice to escape your data before sumbiting it into your database.
Code Igniter has two functions that help you do this:</p>
@@ -94,12 +103,10 @@ Most of the time you'll use the above function rather then this one. Use the fun
<code>$sql = "INSERT INTO table (title) VALUES('".$this->db->escape_str($title)."')";</code>
-
</li>
</ol>
-
<h1><br />Query Bindings</h1>
@@ -114,51 +121,6 @@ $this->db->query($sql, array(3, 'live', 'Rick'));
<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>
-
-
-<h1><br />Query Helper Functions</h1>
-
-
-<h2>$this->db->last_query();</h2>
-
-<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....
-</code>
-
-
-<p>The following two functions help simplify the process of writing database INSERTs and UPDATEs.</p>
-
-
-<h2>$this->db->insert_string(); </h2>
-<p>This function simplifies the process of writing database inserts. It returns a correctly formatted SQL insert string. Example:</p>
-
-<code>$data = array('name' => $name, 'email' => $email, 'url' => $url);<br />
-<br />
-$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>
-<code>INSERT INTO table_name (name, email, url) VALUES ('Rick', 'rick@your-site.com', 'www.your-site.com')</code>
-
-
-
-<h2>$this->db->update_string(); </h2>
-<p>This function simplifies the process of writing database updates. It returns a correctly formatted SQL update string. Example:</p>
-
-<code>$data = array('name' => $name, 'email' => $email, 'url' => $url);<br />
-<br />
-$where = "author_id = 1 AND status = 'active'";
-<br /><br />
-$str = $this->db->update_string('table_name', $data, $where);
-</code>
-
-<p>The first parameter is the table name, the second is an associative array with the data to be inserted, and the third parameter is the "where" clause. The above example produces:</p>
-<code> UPDATE exp_weblog SET name = 'Rick', email = 'rick@your-site.com', url = 'www.your-site.com' WHERE author_id = 1 AND status = 'active'</code>
-
-
</div>
diff --git a/user_guide/libraries/database/results.html b/user_guide/libraries/database/results.html
index a9377764e..342e7e4b4 100644
--- a/user_guide/libraries/database/results.html
+++ b/user_guide/libraries/database/results.html
@@ -64,7 +64,7 @@ Query Results
-<h1>Query Results</h1>
+<h1>Generating Query Results</h1>
<p>There are several ways to generate query results:</p>
@@ -179,40 +179,6 @@ Query Results
</p>
-<h1><br />Query Result Helpers</h1>
-
-<p>The following functions provide useful information when dealing with query results.</p>
-
-<h2>$query->num_rows()</h2>
-<p>The number of rows returned by the query. Note: <dfn>$query</dfn> is the variable that the query was assigned to:</p>
-
-<code>$query = $this->db->query('SELECT * FROM my_table');<br /><br />
-echo $query->num_rows();
-</code>
-
-<h2>$query->num_fields()</h2>
-<p>The number of FIELDS 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();
-</code>
-
-
-<h2>$this->db->insert_id()</h2>
-<p>The insert ID number when performing database inserts.</p>
-
-<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>
-
-
-<h2>$this->db->version()</h2>
-<p>Outputs the database version you are running:</p>
-
-<code>echo $this->db->version();</code>
-
-