From a0424ccd3e238a46dfaa1029374455f63cc48a53 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 15 Oct 2010 03:07:22 +0000 Subject: [PATCH] MINOR: mysql_fetch_row() expects resource, this will fatal if query was e.g. UPDATE when iterating a result because MySQLQuery::nextRecord() is used by Iterator::valid() and MySQLQuery:: is bool in this case (from r106938) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112543 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/model/MySQLDatabase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/model/MySQLDatabase.php b/core/model/MySQLDatabase.php index cd4136141..b57da8dfc 100755 --- a/core/model/MySQLDatabase.php +++ b/core/model/MySQLDatabase.php @@ -1082,7 +1082,7 @@ class MySQLQuery extends SS_Query { public function nextRecord() { // Coalesce rather than replace common fields. - if($data = mysql_fetch_row($this->handle)) { + if(is_resource($this->handle) && $data = mysql_fetch_row($this->handle)) { foreach($data as $columnIdx => $value) { $columnName = mysql_field_name($this->handle, $columnIdx); // $value || !$ouput[$columnName] means that the *last* occurring value is shown