diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 02aad8be9..edef55065 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -427,6 +427,9 @@ class DboMysql extends DboSource { * @param unknown_type $results */ function resultSet(&$results) { + if (isset($this->results) && is_resource($this->results) && $this->results != $results) { + mysql_free_result($this->results); + } $this->results =& $results; $this->map = array(); $num_fields = mysql_num_fields($results); diff --git a/cake/libs/model/datasources/dbo/dbo_mysqli.php b/cake/libs/model/datasources/dbo/dbo_mysqli.php index 1c86366fe..d8e9af0f0 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysqli.php +++ b/cake/libs/model/datasources/dbo/dbo_mysqli.php @@ -405,6 +405,9 @@ class DboMysqli extends DboSource { * @param unknown_type $results */ function resultSet(&$results) { + if (isset($this->results) && is_resource($this->results) && $this->results != $results) { + mysqli_free_result($this->results); + } $this->results =& $results; $this->map = array(); $num_fields = mysqli_num_fields($results);