From 01e9fb1d6aab8e513a9ebd786e9abff74d8b63ca Mon Sep 17 00:00:00 2001 From: GDmac Date: Sat, 9 Nov 2013 08:01:52 +0100 Subject: docs: get_compile_select get_compile_select(null,false) without reset also preserves LIMIT settings --- user_guide_src/source/database/query_builder.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'user_guide_src/source/database') diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 65609c1cb..5e0dcb4be 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 @@ -1055,4 +1055,4 @@ 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; -- cgit v1.2.3-24-g4f1b From 17a0528c23c4d6cf95b03299fbfe2ff789b82249 Mon Sep 17 00:00:00 2001 From: GDmac Date: Mon, 11 Nov 2013 13:18:09 +0100 Subject: Cleanup PR #2719 for Fix #2406 query builder cache Signed-off-by: GDmac --- user_guide_src/source/database/query_builder.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'user_guide_src/source/database') diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 5e0dcb4be..480067407 100644 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1055,4 +1055,4 @@ 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; + // SELECT field1, field1 from mytable where field3 = 5; \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6bdfa428d96358787b5c1fdb05c811ab57860e16 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 19 Dec 2013 15:36:01 +0200 Subject: [ci skip] Add notes to get_compiled_insert(), get_compiled_update() docs --- user_guide_src/source/database/query_builder.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'user_guide_src/source/database') diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 480067407..9a96db003 100644 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -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 -- cgit v1.2.3-24-g4f1b From 896d3e3a973d24985b61d963c9cdb086a010a74f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Jan 2014 17:13:25 +0200 Subject: Add a more clear note about query builder caching (issue #2721) --- user_guide_src/source/database/query_builder.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'user_guide_src/source/database') diff --git a/user_guide_src/source/database/query_builder.rst b/user_guide_src/source/database/query_builder.rst index 9a96db003..5bfdfdb52 100644 --- a/user_guide_src/source/database/query_builder.rst +++ b/user_guide_src/source/database/query_builder.rst @@ -1058,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 -- cgit v1.2.3-24-g4f1b From 1c8245a22874051f5342824d5299d6ad55f4995c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 20 Jan 2014 10:28:20 +0200 Subject: Polish changes from PR #2830 --- user_guide_src/source/database/helpers.rst | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'user_guide_src/source/database') 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 -- cgit v1.2.3-24-g4f1b