con=$con; } // functions // code de retour pour les fonctions i,u,d? public function insertT(Task $t){ $query='INSERT INTO Tache VALUES (:id,:titre,:descript,NULL,NULL,:priorite,:idList,false)'; $this->con->executeQuery($query, array( ':id'=> array($t->get_id(),PDO::PARAM_STR), ':titre'=> array($t->get_titre(),PDO::PARAM_STR), ':descript'=> array($t->get_description(),PDO::PARAM_STR), ':priorite'=> array($t->get_priorite(),PDO::PARAM_STR), ':idList'=> array($t->get_idList(),PDO::PARAM_STR) )); /*Comment gerer les erreurs? * si valeur existe deja */ } public function update($table,$id,$element, $valeur){ if($table == 'task'){ $query='UPDATE Tache SET '.$element.'=:'.$element.' WHERE id=:id'; } else { $query='UPDATE uList SET '.$element.'=:'.$element.' WHERE id=:id'; } $this->con->executeQuery($query, array( ':id'=>array($id,PDO::PARAM_STR), ':'.$element =>array($valeur,PDO::PARAM_STR))); } public function delete($table,$id){ if($table == 'task'){ $query='DELETE FROM Tache WHERE id = :id'; } else { $query='DELETE FROM uList WHERE id = :id'; } $this->con->executeQuery($query, array( ':id'=>array($id,PDO::PARAM_STR))); } /*si on veut trouver une liste, juste chercher toutes les taches avec idList= id_de_la_liste*/ # pour toutes les listes d'un user specifique, appeller 2 fois la fonction: # une fois pour prendre toutes les listes qui ont l'id de l'user # pour toutes ces listes (foreach), find toutes chaque tache associƩ public function find($table, $element="", $valeur=""){ $tabResult = array(); if($table =='task'){ if(strcmp($element,"")==0) { $query='SELECT * FROM Tache'; $this->con->executeQuery($query); } else { $query='SELECT * FROM Tache WHERE '.$element.'=:'.$element; $this->con->executeQuery($query, array( ':'.$element =>array($valeur,PDO::PARAM_STR))); } $results=$this->con->getResults(); foreach($results as $row) { $tabResult[]=new Task($row['id'],$row['titre'],$row['description'],$row['priorite'], $row['idList'],$row['dateDebut'],$row['dateFin'],$row['isDone']); } return $tabResult; } else if($table == 'list'){ if(strcmp($element,"")==0) { $query='SELECT * FROM uList'; $this->con->executeQuery($query); } else { $query='SELECT * FROM uList WHERE '.$element.'=:'.$element; $this->con->executeQuery($query, array( ':'.$element =>array($valeur,PDO::PARAM_STR))); } $results=$this->con->getResults(); foreach($results as $row) { $tabResult[]=new ListTask($row['id'],$row['nom'],$row['user'],$row['dc']); } return $tabResult; } } // SELECT tache.id FROM Tache tache, Liste liste // tache.idListe = liste.id AND liste.user IS NULL; /* # LIST FUNCTIONS */ /*create, update, delete, read(select info)*/ public function insertL(ListTask $l){ $query='INSERT INTO uList VALUES (:id,:nom,:user,0)'; $this->con->executeQuery($query, array( ':id'=> array($l->get_id(),PDO::PARAM_STR), ':nom'=> array($l->get_nom(),PDO::PARAM_STR), ':user'=> array($l->get_owner(),PDO::PARAM_STR))); } } ?>