Skip to content

Commit 249204b

Browse files
committed
Merge branch 'develop' of git://github.com/EllisLab/CodeIgniter into errors
2 parents 97aefa5 + 1d79efe commit 249204b

File tree

5 files changed

+40
-4
lines changed

5 files changed

+40
-4
lines changed

application/config/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
|
6565
*/
6666

67-
$route['default_controller'] = "welcome";
67+
$route['default_controller'] = 'welcome';
6868
$route['404_override'] = '';
6969

7070
/* End of file routes.php */

system/core/Security.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ protected function _csrf_set_hash()
831831
// each page load since a page could contain embedded
832832
// sub-pages causing this feature to fail
833833
if (isset($_COOKIE[$this->_csrf_cookie_name]) &&
834-
$_COOKIE[$this->_csrf_cookie_name] != '')
834+
preg_match('#^[0-9a-f]{32}$#iS', $_COOKIE[$this->_csrf_cookie_name]) === 1)
835835
{
836836
return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name];
837837
}
@@ -846,4 +846,4 @@ protected function _csrf_set_hash()
846846
}
847847

848848
/* End of file Security.php */
849-
/* Location: ./system/core/Security.php */
849+
/* Location: ./system/core/Security.php */

system/database/DB_result.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,19 @@ public function previous_row($type = 'object')
370370

371371
// --------------------------------------------------------------------
372372

373+
/**
374+
* Returns an unbuffered row and move pointer to next row
375+
*
376+
* @return mixed either a result object or array
377+
*/
378+
public function unbuffered_row($type = 'object')
379+
{
380+
return ($type !== 'array') ? $this->_fetch_object() : $this->_fetch_assoc();
381+
382+
}
383+
384+
// --------------------------------------------------------------------
385+
373386
/**
374387
* The following functions are normally overloaded by the identically named
375388
* methods in the platform-specific driver -- except when query caching

user_guide_src/source/changelog.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ Release Date: Not Released
103103
- Added PDO support for create_database(), drop_database and drop_table() in :doc:`Database Forge <database/forge>`.
104104
- Added MSSQL, SQLSRV support for optimize_table() in :doc:`Database Utility <database/utilities>`.
105105
- Improved CUBRID support for list_databases() in :doc:`Database Utility <database/utilities>` (until now only the currently used database was returned).
106+
- Added unbuffered_row() function for getting a row without prefetching whole result (consume less memory)
106107

107108
- Libraries
108109

@@ -242,7 +243,9 @@ Bug fixes for 2.1.1
242243
- Fixed a bug - form_open() compared $action against site_url() instead of base_url().
243244
- Fixed a bug - CI_Upload::_file_mime_type() could've failed if mime_content_type() is used for the detection and returns FALSE.
244245
- Fixed a bug (#538) - Windows paths were ignored when using the :doc:`Image Manipulation Library <libraries/image_lib>` to create a new file.
245-
- Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found
246+
- Fixed a bug - When database caching was enabled, $this->db->query() checked the cache before binding variables which resulted in cached queries never being found.
247+
- Fixed a bug - CSRF cookie value was allowed to be any (non-empty) string before being written to the output, making code injection a risk.
248+
- Fixed a bug (#726) - PDO put a 'dbname' argument in it's connection string regardless of the database platform in use, which made it impossible to use SQLite.
246249

247250
Version 2.1.0
248251
=============

user_guide_src/source/database/results.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,26 @@ parameter:
136136
| **$row = $query->next_row('array')**
137137
| **$row = $query->previous_row('array')**
138138
139+
.. note:: all the functions above will load the whole result into memory (prefetching) use unbuffered_row() for processing large result sets.
140+
141+
unbuffered_row($type)
142+
=====
143+
144+
This function returns a single result row without prefetching the whole result in memory as row() does.
145+
If your query has more than one row, it returns the current row and moves the internal data pointer ahead.
146+
The result is returned as $type could be 'object' (default) or 'array' that will return an associative array.
147+
148+
149+
150+
$query = $this->db->query("YOUR QUERY");
151+
152+
while ($row = $query->unbuffered_row())
153+
{
154+
echo $row->title;
155+
echo $row->name;
156+
echo $row->body;
157+
}
158+
139159
***********************
140160
Result Helper Functions
141161
***********************

0 commit comments

Comments
 (0)