View Single Post
  #8  
Old 03-16-2016, 02:53 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 135,882
Kyttias is on a distinguished road
Default

The best thing to do will be just to make a try/catch as we did before, actually, with the children. Telling you where to make edits is a little harder, so, from the thread where the family tree was made, post number four, the first bit of code. That. Where-ever you put that, no matter how you designed it within, it'll be easiest just to put this above it, so we have both:

PHP Code:
if ($adopt->mother != NULL){ try { $mother = new OwnedAdoptable($adopt->mother); } catch (AdoptNotfoundException $anfe){ $adopt->mother NULL; } }
if (
$adopt->father != NULL){ try { $father = new OwnedAdoptable($adopt->father); } catch (AdoptNotfoundException $anfe){ $adopt->father NULL; } }
if (
$adopt->grandmotherA != NULL){ try { $grandmotherA = new OwnedAdoptable($adopt->grandmotherA); } catch (AdoptNotfoundException $anfe){ $adopt->grandmotherA NULL; } }
if (
$adopt->grandmotherB != NULL){ try { $grandmotherB = new OwnedAdoptable($adopt->grandmotherB); } catch (AdoptNotfoundException $anfe){ $adopt->grandmotherB NULL; } }
if (
$adopt->grandfatherA != NULL){ try { $grandfatherA = new OwnedAdoptable($adopt->grandfatherA); } catch (AdoptNotfoundException $anfe){ $adopt->grandfatherA NULL; } }
if (
$adopt->grandfatherB != NULL){ try { $grandfatherB = new OwnedAdoptable($adopt->grandfatherB); } catch (AdoptNotfoundException $anfe){ $adopt->grandfatherB NULL; } } 
And you may not need the grandparent bits, of course.

So why do we need this code first?

Basically, the code from the post I referred to is checking whether or not the current adoptable has a parent held in its database column (it's checking for NULL, so, so long as something there, it should try to render something). Well, we're backing up a step. First we're checking if the field is not NULL - okay, something is there? Okay, but does that pet actually exist? We check that. And if doesn't exist? We inform the code it is NULL, therefore stopping the original code.

If something about this goes strangely, go ahead and send me the file via PM.
__________________
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.
Reply With Quote