示例#1
0
 public static function createInstance($parentId = NULL, $gender = NULL, $child = NULL)
 {
     $temp = Parents::getByField($parentId, $child);
     // return $temp;
     if (!$temp) {
         $init = new Parents();
         $init->id = null;
         $init->parentId = $parentId;
         if ($gender == 'male') {
             $init->gender = 'father';
         } else {
             $init->gender = 'mother';
         }
         $init->child = $child;
         return $init;
     } else {
         $temp->parentId = $parentId;
         if ($gender == 'male') {
             $temp->gender = 'father';
         } else {
             $temp->gender = 'mother';
         }
         $temp->child = $child;
     }
     $init = recast('Parents', $temp);
     return $init;
 }