Oh, woops! You do need it after {$this->aid}, good job catching that!
PHP Code:
$mysidia->db->delete("owned_adoptables", "aid='{$this->aid}' AND owner ='{$this->owner}'");
You really really shouldn't still have the pet after that, though. =/ You sure? There is another way to write this, hang on...
PHP Code:
$mysidia->db->query("DELETE FROM adopts_owned_adoptables WHERE aid='{$this->aid}' AND owner ='{$this->owner}'");
edit:
However, the problem is where you're putting it. It can't find the data you're telling it to find because you can't call
$this->aid inside
myadopts.php, because that file does not have a variable set at the top called
$aid. You'd have to use
$this->adopt->getAdoptID() instead (this file has a variable called $adopt which is a reference to the
class_ownedadoptables.php where
getAdoptID() exists, possibly even
$this->adopt->aid would work with the proper permissions).
I was thinking you'd put this inside
doReleasePet(), since you were calling with
$this->adopt->doReleasePet(); but left it empty inside
class_ownedadoptables.php? I used
aid='{$this->aid}' assuming it'd be there (because $aid exists in the context of this file) if you don't want to do that, then I suggest just inside
myadopts.php:
PHP Code:
public function releasepet(){
$mysidia = Registry::get("mysidia");
if($mysidia->input->post("submit")){
$mysidia->db->delete("owned_adoptables", "aid='{$this->adopt->getAdoptID()}'");
}
$this->setField("adopt", $this->adopt);
$this->setField("image", $this->image);
}
The point of having it in the class file, as a function, instead of in the myadopts file is reusability. If you plan on needing an adopt delete function elsewhere on the site, this would be good to have as a function in the class instead. For example, if you're still using the pound at all, you could technically write in a feature that would automatically delete pets that have been in the pound longer than a month. However, if you can't think of another use for that line of code, then it's fine not needing to be inside a function at all.