DB_DataObject fetch() and delete() failure
| From: | Michael McCarthy | Date: | Thu, 15 May 2003 22:26:37 +0000 |
| Subject: | DB_DataObject fetch() and delete() failure | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5396@lists.php.net to get a copy of this message | ||
Hi there,
Just finished upgrading PEAR to the latest releases. I have noticed that
the following pieces of code started to 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() {
$sc = $this->getSubCategories();
while ($sc->fetch()) {
$sc->delete();
}
$this->delete();
}
<... snip ...>
}
The error I get is: "Fatal error: Call to a member function on a non-object
in DB/DataObject.php on line 382".
Is it no longer possible to delete within a fetch loop? Ie.
while ($sc->fetch()) {
$sc->delete();
}
What am I missing here?
Many thanks in advance,
Mike