I have inherited a vo/dao setup (there's just one model class that has all the DAO functions for every class, though), but it's getting odd with recursion.
Every user has posts, each post can have a video, but videos also have users, and sometimes a video hasn't been set for a post.
getPost looks (partially) like this:
function getPostById($id) {
$post->name = $row['name'];
$post->video = $this->getVideoById($row['video_id']);
}
video has a similar function to get its user, the problem is if a video is not set within the post (id=0), then the getUser function for it fails, logically, with mysql_fetch_array() expects parameter 1 to be resource, boolean given
. Now I could put conditionals on all those commands that refer to other objects, but is there some other way to deal with potentially null values in linking V0 objects like this?