public function getBlogContentBySousrubrique($sousrubriqueid, $dataType) { $sousrubriqueid = (int) $sousrubriqueid; $result = array(); $sousrubriqueDao = new SousRubriqueDao(); $contenustep1 = array(); $requete = $this->dbGateway->prepare("\r\n\t\tSELECT *\r\n\t\tFROM contenu c\r\n\t\tWHERE c.sousrubriques_id = :id\r\n\t\t") or die(print_r($this->dbGateway->error_info())); $requete->execute(array('id' => $sousrubriqueid)); $requete2 = $requete->fetch(\PDO::FETCH_ASSOC); if ($dataType == "object") { //Put result in an array of objects $arrayOfContenustep1 = array(); $arrayOfContenustep2 = array(); if (is_array($requete2)) { foreach ($requete2 as $key => $value) { //print_r($value); //put code to define an array of objects if ($value['sousrubriques_id'] != null && $value['sousrubriques_id'] != "") { $sousrubrique = $sousrubriqueDao->getSousrubrique($value['sousrubriques_id']); $arrayOfContenustep1[$count]['id'] = $value['contenu_id']; $arrayOfContenustep1[$count]['titre'] = $value['titre']; $arrayOfContenustep1[$count]['soustitre'] = $value['soustitre']; $arrayOfContenustep1[$count]['contenu'] = $value['contenuhtml']; $arrayOfContenustep1[$count]['position'] = $value['rang']; $arrayOfContenustep1[$count]['image'] = $value['image']; $arrayOfContenustep1[$count]['image2'] = $value['image2']; $arrayOfContenustep1[$count]['sousrubrique'] = $sousrubrique; $arrayOfContenustep1[$count]['author'] = $value['author']; $arrayOfContenustep1[$count]['themes'] = $value['themes']; $arrayOfContenustep1[$count]['blogdate'] = $value['contenu_date']; $arrayOfContenustep1[$count]['text1'] = $value['othertext1']; $arrayOfContenustep1[$count]['text2'] = $value['othertext2']; $arrayOfContenustep1[$count]['text3'] = $value['othertext3']; $arrayOfContenustep2[$count] = Blogcontent::fromArray($arrayOfContenustep1[$count]); $count++; } } } return $arrayOfContenustep2; } elseif ($dataType == "array") { return $requete2; } }