From ff8bff16c9857540f47a9ed093c6c4fb7348e1ad Mon Sep 17 00:00:00 2001 From: clawoo Date: Tue, 21 Oct 2014 10:41:02 +0300 Subject: Update the change log and the documentation with the array values binding feature. --- user_guide_src/source/changelog.rst | 1 + user_guide_src/source/database/queries.rst | 6 ++++++ 2 files changed, 7 insertions(+) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 0e4930289..adb8d88ce 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -173,6 +173,7 @@ Release Date: Not Released - Added Interbase/Firebird database support via the *ibase* driver. - Added ODBC support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge `. - Added **save_queries** configuration setting to *application/config/database.php* (defaults to ``TRUE``). + - Added support for escaping arrays sent as binding values to ``query()`` - :doc:`Query Builder ` changes include: diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index 90f49afb1..b9152aac7 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -132,6 +132,12 @@ put the queries together for you. Consider the following example:: The question marks in the query are automatically replaced with the values in the array in the second parameter of the query function. +Bindings also work with array values, useful for queries involving the IN operator:: + + $sql = "SELECT * FROM some_table WHERE id IN ? AND status = ? AND author = ?"; + $this->db->query($sql, array(array(3, 6), 'live', 'Rick')); + + 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 -- cgit v1.2.3-24-g4f1b From 1db369f77a158d72fcb7fe44f84efcfe9ac2f0d7 Mon Sep 17 00:00:00 2001 From: clawoo Date: Wed, 22 Oct 2014 19:10:55 +0300 Subject: Reword change log and add the resulting query in the manual. --- user_guide_src/source/changelog.rst | 2 +- user_guide_src/source/database/queries.rst | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'user_guide_src/source') diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index adb8d88ce..99cdf4d4e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -173,7 +173,7 @@ Release Date: Not Released - Added Interbase/Firebird database support via the *ibase* driver. - Added ODBC support for ``create_database()``, ``drop_database()`` and ``drop_table()`` in :doc:`Database Forge `. - Added **save_queries** configuration setting to *application/config/database.php* (defaults to ``TRUE``). - - Added support for escaping arrays sent as binding values to ``query()`` + - Added support to binding arrays as ``IN()`` sets in ``query()``. - :doc:`Query Builder ` changes include: diff --git a/user_guide_src/source/database/queries.rst b/user_guide_src/source/database/queries.rst index b9152aac7..76ff1083f 100644 --- a/user_guide_src/source/database/queries.rst +++ b/user_guide_src/source/database/queries.rst @@ -132,11 +132,14 @@ put the queries together for you. Consider the following example:: The question marks in the query are automatically replaced with the values in the array in the second parameter of the query function. -Bindings also work with array values, useful for queries involving the IN operator:: +Binding also work with arrays, which will be transformed to IN sets:: $sql = "SELECT * FROM some_table WHERE id IN ? AND status = ? AND author = ?"; $this->db->query($sql, array(array(3, 6), 'live', 'Rick')); +The resulting query will be:: + + SELECT * FROM some_table WHERE id IN (3,6) AND status = 'live' AND author = 'Rick' The secondary benefit of using binds is that the values are automatically escaped, producing safer queries. You don't have to -- cgit v1.2.3-24-g4f1b