|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-05-20 07:58 UTC] alan_k@php.net
[2003-05-20 07:59 UTC] alan_k@php.net
[2003-05-21 06:14 UTC] mccarthy at ee dot ualberta dot ca
[2003-05-21 06:22 UTC] mccarthy at ee dot ualberta dot ca
[2003-05-21 20:02 UTC] alan_k@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 05:00:01 2025 UTC |
The following pieces of code fail in all of my projects: $ca = new DataObjects_Categories; $ca->get(<some id>); $ca->deleteAll(); Where the class DataObjects_Categories is defined as: class DataObjects_Categories extends DB_DataObject { <... snip ...> function &getSubCategories() { $scs = new DataObjects_Sub_categories; $scs->ca_id = $this->id; $scs->find(); return $scs; } function deleteAll() { DB_DataObject::debugLevel(1); $sc = $this->getSubCategories(); while ($sc->fetch()) { $sc->delete(); } $this->delete(); DB_DataObject::debugLevel(); } <... snip ...> } The script, with debugLevel(1), returns: *--* __find sql QUERYSELECT * FROM sub_categories WHERE sub_categories.ca_id = 33 query DONE QUERY __find CHECK autofetchd __find DONE fetchrow sub_categories DONE sql QUERYDELETE FROM sub_categories WHERE sub_categories.id = 132 query DONE QUERY Fatal error: Call to a member function on a non-object in pear/lib/php/DB/DataObject.php on line 385 *--* There were three sub_categories in the database that should have been deleted during this execution. However, the fetch() loop only gets executed once before the fatal error. Two sub_categories and their parent category remain. I believe the bug lies in the fetch() statement of: while ($sc->fetch()) { $sc->delete(); } where it appears to fail after the first loop.