public static function getModels($res) { $result = array(); foreach ($res as $element) { $model = ProfessionalExperience::getModel($element); array_push($result, $model); } return $result; }
public function get($educationId) { // we make sure $id is an integer $id = intval($educationId); $req = $this->db->prepare('SELECT * FROM professionalexperiences WHERE id = :id'); $req->execute(array('id' => $id)); $res = $req->fetch(); var_dump($res); $user = ProfessionalExperience::getModel($res); return $user; }
public function getCandidateByUserId($userId) { $id = intval($userId); $req = $this->db->prepare('SELECT * FROM candidates WHERE userId = :id'); $req->execute(array('id' => $id)); $res = $req->fetch(); $candidate = Candidate::getModel($res); $req = $this->db->prepare('SELECT * FROM educations WHERE cvId = :id'); $req->execute(array('id' => $candidate->cv->id)); $res = $req->fetchAll(); $candidate->cv->educations = Education::getModels($res); $req = $this->db->prepare('SELECT * FROM professionalexperiences WHERE cvId = :id'); $req->execute(array('id' => $candidate->cv->id)); $res = $req->fetchAll(); $candidate->cv->professional_experiences = ProfessionalExperience::getModels($res); return $candidate; }