Ejemplo n.º 1
0
 public function getCommentairesByContenu($contenuid, $status, $dataType)
 {
     $requete = $this->dbGateway->prepare("\r\n\t\tSELECT *\r\n\t\tFROM commentaire m\r\n\t\tWHERE m.commentaire_contenuid = :contenuid AND commentaire_status = :status\r\n\t\tORDER BY m.commentaire_contenuid, m.commentaire_date DESC\r\n                ") or die(print_r($this->dbGateway->error_info()));
     $requete->execute(array('contenuid' => $contenuid, 'status' => $status));
     $requete2 = $requete->fetchAll(\PDO::FETCH_ASSOC);
     if ($dataType == "object") {
         //Put result in an array of objects
         $arrayOfCommentairestep1 = array();
         if (is_array($requete2)) {
             $count = 0;
             foreach ($requete2 as $key => $value) {
                 $arrayOfCommentairestep1[$count] = Commentaire::fromArray($value);
                 $count++;
             }
         }
         //print_r($arrayOfCommentairestep2);
         return $arrayOfCommentairestep1;
     } elseif ($dataType == "array") {
         return $requete2;
     }
 }