View Single Post
  #9  
Old 03-08-2016, 11:51 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 125,677
Kyttias is on a distinguished road
Default

No, partially because editting the adopts_pounds table won't help you, lol?

The babies are stored as an psuedo-array with the parents. You have to take the adopt, identify its parents, extract the arrays from the database for each parent, explode these arrays from a strings into an an actual arrays PHP can work with, carefully remove the id of the pet you're deleting, implode it back into a string, and reinsert it into the database.

Confirmed working (edit: Updated Mar 9 @ 2:21AM EST!):
PHP Code:
/* . . . REMOVE PET FROM FATHER'S LIST OF CHILDREN . . . */
# Find the father.
$father = new OwnedAdoptable($this->adopt->father); 
# Open the array of the father's kids.
$father_kids explode(","$father->offsprings); 
# Remove specific adoptable from the list of kids.
foreach($father_kids as $i => $kid){
  if(
$kid == $this->adopt->getAdoptID()){
    unset(
$father_kids[$i]);
  }
}
# Close the array of the father's kids.
$father_kids implode(",",$father_kids); 
# Put the updated list of kids back in the database.
$mysidia->db->update("owned_adoptables", array("offsprings" => $father_kids), "aid = '{$father->aid}'");


/* . . . REMOVE PET FROM MOTHER'S LIST OF CHILDREN . . . */
# Find the mother.
$mother = new OwnedAdoptable($this->adopt->mother); 
# Open the array of the mother's kids.
$mother_kids explode(","$mother->offsprings); 
# Remove specific adoptable from the list of kids.
foreach($mother_kids as $i => $kid){
  if(
$kid == $this->adopt->getAdoptID()){
    unset(
$mother_kids[$i]);
  }
}
# Close the array of the mother's kids.
$mother_kids implode(",",$mother_kids); 
# Put the updated list of kids back in the database.
$mysidia->db->update("owned_adoptables", array("offsprings" => $mother_kids), "aid = '{$mother->aid}'"); 
Snuggle the above code directly up to (and probably right before) where the pet itself is deleted.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 03-09-2016 at 01:32 AM.
Reply With Quote