public static function getSkillsForProject($id) { $pdo = PDO2::getInstance(); $requete = $pdo->prepare("SELECT s.*, case when m.id_skill is not null then 1 else 0 end as isActive\n\t\t\t\tFROM skills s LEFT JOIN asso_projects_skills m\n\t\t\t\tON (s.id = m.id_skill and m.id_project = :id_project)\n\t\t\t\t"); $requete->bindValue(':id_project', $id, PDO::PARAM_STR); $requete->execute(); $final_objects = null; if ($objects = $requete->fetchAll(PDO::FETCH_ASSOC)) { if (count($objects)) { $type = get_called_class(); foreach ($objects as $object) { $entity = new Skill(); $final_objects[] = $entity->fetchEntity($object); } } return $final_objects; } else { return false; //print_r($requete->errorInfo()); } }