diff options
Diffstat (limited to 'user_guide_src')
-rw-r--r-- | user_guide_src/source/changelog.rst | 10 | ||||
-rw-r--r-- | user_guide_src/source/database/results.rst | 43 |
2 files changed, 41 insertions, 12 deletions
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 9b0ea53c4..daf796504 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -73,6 +73,7 @@ Release Date: Not Released - Added JS window name support to the :php:func:`anchor_popup()` function. - Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`. - Changed :php:func:`redirect()` to only choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). + - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs, such as `redirect('//ellislab.com/codeigniter')`. - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper <helpers/html_helper>`. - :doc:`Inflector Helper <helpers/inflector_helper>` changes include: - Changed :php:func:`humanize()` to allow passing an input separator as its second parameter. @@ -106,7 +107,6 @@ Release Date: Not Released - Added **schema** configuration setting (defaults to *public*) for drivers that might need it (currently used by PostgreSQL and ODBC). - Added subdrivers support (currently only used by PDO). - Added an optional database name parameter to ``db_select()``. - - Added a constructor to the ``DB_result`` class and moved all driver-specific properties and logic out of the base ``DB_driver`` class to allow better abstraction. - Removed ``protect_identifiers()`` and renamed internal method ``_protect_identifiers()`` to it instead - it was just an alias. - Renamed internal method ``_escape_identifiers()`` to ``escape_identifiers()``. - Updated ``escape_identifiers()`` to accept an array of fields as well as strings. @@ -114,8 +114,7 @@ Release Date: Not Released - ``db_set_charset()`` now only requires one parameter (collation was only needed due to legacy support for MySQL versions prior to 5.1). - Replaced the ``_error_message()`` and ``_error_number()`` methods with ``error()``, which returns an array containing the last database error code and message. - Improved ``version()`` implementation so that drivers that have a native function to get the version number don't have to be defined in the core ``DB_driver`` class. - - Added ``unbuffered_row()`` method for getting a row without prefetching whole result (consume less memory). - - Added capability for packages to hold *database.php* config files. + - Added capability for packages to hold *config/database.php* config files. - Added MySQL client compression support. - Added encrypted connections support (for *mysql*, *sqlsrv* and PDO with *sqlsrv*). - Removed :doc:`Loader Class <libraries/loader>` from Database error tracing to better find the likely culprit. @@ -133,6 +132,10 @@ Release Date: Not Released - Changed ``limit()`` to ignore NULL values instead of always casting to integer. - Changed ``offset()`` to ignore empty values instead of always casting to integer. - Methods ``insert_batch()`` and ``update_batch()`` now return an integer representing the number of rows affected by them. + - :doc:`Database Results <database/results>` changes include: + - Added a constructor to the ``DB_result`` class and moved all driver-specific properties and logic out of the base ``DB_driver`` class to allow better abstraction. + - Added method ``unbuffered_row()`` for fetching a row without prefetching the whole result (consume less memory). + - Renamed former method ``_data_seek()`` to ``data_seek()`` and made it public. - Improved support for the MySQLi driver, including: - OOP style of the PHP extension is now used, instead of the procedural aliases. - Server version checking is now done via ``mysqli::$server_info`` instead of running an SQL query. @@ -461,6 +464,7 @@ Bug fixes for 3.0 - Fixed a bug (#18) - :doc:`APC Cache <libraries/caching>` driver didn't (un)serialize data, resulting in failure to store objects. - Fixed a bug (#188) - :doc:`Unit Testing Library <libraries/unit_testing>` filled up logs with error messages for non-existing language keys. - Fixed a bug (#113) - :doc:`Form Validation Library <libraries/form_validation>` didn't properly handle empty fields that were specified as an array. +- Fixed a bug (#2061) - :doc:`Routing Class <general/routing>` didn't properly sanitize directory, controller and function triggers with **enable_query_strings** set to TRUE. Version 2.1.3 ============= diff --git a/user_guide_src/source/database/results.rst b/user_guide_src/source/database/results.rst index d032f734e..e0a87a851 100644 --- a/user_guide_src/source/database/results.rst +++ b/user_guide_src/source/database/results.rst @@ -99,7 +99,7 @@ to instantiate the row with:: echo $row->reverse_name(); // or methods defined on the 'User' class row_array() -============ +=========== Identical to the above row() function, except it returns an array. Example:: @@ -138,12 +138,12 @@ parameter: .. note:: all the functions above will load the whole result into memory (prefetching) use unbuffered_row() for processing large result sets. -unbuffered_row($type) -===================== +unbuffered_row() +================ -This function returns a single result row without prefetching the whole result in memory as row() does. -If your query has more than one row, it returns the current row and moves the internal data pointer ahead. -The result is returned as $type could be 'object' (default) or 'array' that will return an associative array. +This method returns a single result row without prefetching the whole +result in memory as ``row()`` does. If your query has more than one row, +it returns the current row and moves the internal data pointer ahead. :: @@ -156,12 +156,19 @@ The result is returned as $type could be 'object' (default) or 'array' that will echo $row->body; } +You can optionally pass 'object' (default) or 'array' in order to specify +the returned value's type:: + + $query->unbuffered_row(); // object + $query->unbuffered_row('object'); // object + $query->unbuffered_row('array'); // associative array + *********************** Result Helper Functions *********************** $query->num_rows() -=================== +================== The number of rows returned by the query. Note: In this example, $query is the variable that the query result object is assigned to:: @@ -177,7 +184,7 @@ is the variable that the query result object is assigned to:: resulting array in order to achieve the same functionality. $query->num_fields() -===================== +==================== The number of FIELDS (columns) returned by the query. Make sure to call the function using your query result object:: @@ -187,7 +194,7 @@ the function using your query result object:: echo $query->num_fields(); $query->free_result() -====================== +===================== It frees the memory associated with the result and deletes the result resource ID. Normally PHP frees its memory automatically at the end of @@ -209,3 +216,21 @@ Example:: $row = $query2->row(); echo $row->name; $query2->free_result(); // The $query2 result object will no longer be available + +data_seek() +=========== + +This method sets the internal pointer for the next result row to be +fetched. It is only useful in combination with ``unbuffered_row()``. + +It accepts a positive integer value, which defaults to 0 and returns +TRUE on success or FALSE on failure. + +:: + + $query = $this->db->query('SELECT `field_name` FROM `table_name`'); + $query->data_seek(5); // Skip the first 5 rows + $row = $query->unbuffered_row(); + +.. note:: Not all database drivers support this feature and will return FALSE. + Most notably - you won't be able to use it with PDO.
\ No newline at end of file |