summaryrefslogtreecommitdiffstats
path: root/user_guide_src/source/database
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide_src/source/database')
-rw-r--r--user_guide_src/source/database/helpers.rst27
-rw-r--r--user_guide_src/source/database/query_builder.rst22
2 files changed, 29 insertions, 20 deletions
diff --git a/user_guide_src/source/database/helpers.rst b/user_guide_src/source/database/helpers.rst
index e8a5ac801..77bf1b5d2 100644
--- a/user_guide_src/source/database/helpers.rst
+++ b/user_guide_src/source/database/helpers.rst
@@ -3,7 +3,7 @@ Query Helper Functions
######################
$this->db->insert_id()
-=======================
+======================
The insert ID number when performing database inserts.
@@ -12,7 +12,7 @@ The insert ID number when performing database inserts.
appropriate sequence to check for the insert id.
$this->db->affected_rows()
-===========================
+==========================
Displays the number of affected rows, when doing "write" type queries
(insert, update, etc.).
@@ -22,8 +22,8 @@ Displays the number of affected rows, when doing "write" type queries
affected rows. By default this hack is enabled but it can be turned off
in the database driver file.
-$this->db->count_all();
-========================
+$this->db->count_all()
+======================
Permits you to determine the number of rows in a particular table.
Submit the table name in the first parameter. Example::
@@ -47,8 +47,8 @@ Outputs the database version you are running::
echo $this->db->version();
-$this->db->last_query();
-=========================
+$this->db->last_query()
+=======================
Returns the last query that was run (the query string, not the result).
Example::
@@ -57,11 +57,12 @@ Example::
// Produces: SELECT * FROM sometable....
-The following two functions help simplify the process of writing
-database INSERTs and UPDATEs.
-$this->db->insert_string();
-============================
+.. note:: Disabling the **save_queries** setting in your database
+ configuration will render this function useless.
+
+$this->db->insert_string()
+==========================
This function simplifies the process of writing database inserts. It
returns a correctly formatted SQL insert string. Example::
@@ -77,8 +78,8 @@ array with the data to be inserted. The above example produces::
.. note:: Values are automatically escaped, producing safer queries.
-$this->db->update_string();
-============================
+$this->db->update_string()
+==========================
This function simplifies the process of writing database updates. It
returns a correctly formatted SQL update string. Example::
@@ -95,4 +96,4 @@ array with the data to be updated, and the third parameter is the
UPDATE table_name SET name = 'Rick', email = 'rick@example.com', url = 'example.com' WHERE author_id = 1 AND status = 'active'
-.. note:: Values are automatically escaped, producing safer queries.
+.. note:: Values are automatically escaped, producing safer queries. \ No newline at end of file
diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst
index 65609c1cb..5bfdfdb52 100644
--- a/user_guide_src/source/database/query_builder.rst
+++ b/user_guide_src/source/database/query_builder.rst
@@ -68,7 +68,7 @@ Example::
// Produces string: SELECT * FROM mytable
The second parameter enables you to set whether or not the query builder query
-will be reset (by default it will be—just like `$this->db->get()`)::
+will be reset (by default it will be reset, just like when using `$this->db->get()`)::
echo $this->db->limit(10,20)->get_compiled_select('mytable', FALSE);
// Produces string: SELECT * FROM mytable LIMIT 20, 10
@@ -76,7 +76,7 @@ will be reset (by default it will be—just like `$this->db->get()`)::
echo $this->db->select('title, content, date')->get_compiled_select();
- // Produces string: SELECT title, content, date FROM mytable
+ // Produces string: SELECT title, content, date FROM mytable LIMIT 20, 10
The key thing to notice in the above example is that the second query did not
utilize `$this->db->from()`_ and did not pass a table name into the first
@@ -665,10 +665,12 @@ will be reset (by default it will be--just like `$this->db->insert()`_)::
// Produces string: INSERT INTO mytable (title, content) VALUES ('My Title', 'My Content')
The key thing to notice in the above example is that the second query did not
-utlize `$this->db->from()`_ nor did it pass a table name into the first
+utlize `$this->db->from()` nor did it pass a table name into the first
parameter. The reason this worked is because the query has not been executed
-using `$this->db->insert()`_ which resets values or reset directly using
-`$this->db->reset_query()`_.
+using `$this->db->insert()` which resets values or reset directly using
+`$this->db->reset_query()`.
+
+.. note:: This method doesn't work for batched inserts.
$this->db->insert_batch()
=========================
@@ -886,8 +888,9 @@ $this->db->get_compiled_update()
This works exactly the same way as ``$this->db->get_compiled_insert()`` except
that it produces an UPDATE SQL string instead of an INSERT SQL string.
-For more information view documentation for `$this->db->get_compiled_insert()`_.
+For more information view documentation for `$this->db->get_compiled_insert()`.
+.. note:: This method doesn't work for batched updates.
*************
Deleting Data
@@ -1055,4 +1058,9 @@ run the query::
$data = $this->db->get()->result_array();
// Would execute and return an array of results of the following query:
- // SELECT field1, field1 from mytable where field3 = 5; \ No newline at end of file
+ // SELECT field1, field1 from mytable where field3 = 5;
+
+.. note:: Double calls to ``get_compiled_select()`` while you're using the
+ Query Builder Caching functionality and NOT resetting your queries
+ will results in the cache being merged twice. That in turn will
+ i.e. if you're caching a ``select()`` - select the same field twice. \ No newline at end of file