public function __construct($data, $searchInDB = false) { if ($searchInDB) { $this->id = $data->id_etu; $info = EtudiantDAO::getInfo($this->id); $this->construct_from($info); $this->formations = FormationsModel::findByEtudiant($this->id); foreach ($this->formations as $f) { $f->loadMatieres(); } $formation = FormationDAO::findByEtudiant($this->id); $cpt = 0; foreach ($formation as $f2) { if ($cpt == 0) { $this->dernierformation = $f2; } $cpt++; } } else { $this->construct_from($data); } }
public function test_formFindByEtu() { $db = DB::Connect(); $result = $db->query("SELECT count(*) as nombre FROM ETUDIANT_FORMATION WHERE id_etu = 2"); $result->setFetchMode(PDO::FETCH_OBJ); $result = $result->fetch(); $attendu = $result->nombre; $formations = FormationsModel::findByEtudiant(2); $this->message["form_findByEtu_mess"] = "Attendu : " . $attendu . " - Trouver : " . count($formations); return count($formations) === intval($attendu); }