public function saveCommentaire(Commentaire $commentaire) { $id = (int) $commentaire->getId(); if (!(bool) $commentaire->getRow1()) { $commentaire->setRow1(""); } if (!(bool) $commentaire->getRow2()) { $commentaire->setRow2(""); } if (!(bool) $commentaire->getRow3()) { $commentaire->setRow3(""); } if (!(bool) $commentaire->getRow4()) { $commentaire->setRow4(""); } if (!(bool) $commentaire->getMessage()) { $commentaire->setMessage(""); } if (!(bool) $commentaire->getType()) { $commentaire->setType("blog"); } if (!(bool) $commentaire->getRang()) { $commentaire->setRang(0); } if (!(bool) $commentaire->getDate()) { $commentaire->setDate(time()); } if (!(bool) $commentaire->getCommentaireStatut()) { $commentaire->setCommentaireStatut(0); } if (!(bool) $commentaire->getType()) { $commentaire->setType(""); } if (!(bool) $commentaire->getContenuId()) { $commentaire->setContenuId(0); } if (!(bool) $commentaire->getCommentaireId()) { $commentaire->setCommentaireId(0); } if ($id > 0) { $requete = $this->dbGateway->prepare("\r\n\t\t\t\tUPDATE commentaire \r\n\t\t\t\tSET commentaire_row1 = :row1, \r\n\t\t\t\tcommentaire_row2 = :row2,\r\n\t\t\t\tcommentaire_row3 = :row3,\r\n\t\t\t\tcommentaire_row4 = :row4,\r\n commentaire_msg = :msg,\r\n commentaire_status = :status,\r\n commentaire_contenuid = :contenuid,\r\n commentaire_type = :type,\r\n commentaire_date = :datemsg\r\n\t\t\t\tWHERE commentaire_id = :id\r\n\t\t\t") or die(print_r($this->dbGateway->errors_info())); $requete->execute(array('id' => $id, 'row1' => $commentaire->getRow1(), 'row2' => $commentaire->getRow2(), 'row3' => $commentaire->getRow3(), 'row4' => $commentaire->getRow4(), 'msg' => $commentaire->getMessage(), 'type' => $commentaire->getType(), 'status' => $commentaire->getCommentaireStatut(), 'contenuid' => $commentaire->getContenuId(), 'datemsg' => $commentaire->getDate())); } else { $requete = $this->dbGateway->prepare("INSERT into commentaire(" . "commentaire_row1, " . "commentaire_row2, " . "commentaire_row3, " . "commentaire_row4, " . "commentaire_msg, " . "commentaire_type, " . "commentaire_date, " . "commentaire_status, " . "commentaire_contenuid) " . "values(" . ":rowa, " . ":rowb, " . ":rowc, " . ":rowd, " . ":msg, " . ":type, " . ":datemsg, " . ":status, " . ":contenuid)") or die(print_r($this->dbGateway->error_info())); $info = $requete->execute(array('rowa' => $commentaire->getRow1(), 'rowb' => $commentaire->getRow2(), 'rowc' => $commentaire->getRow3(), 'rowd' => $commentaire->getRow4(), 'msg' => $commentaire->getMessage(), 'type' => $commentaire->getType(), 'status' => $commentaire->getCommentaireStatut(), 'contenuid' => $commentaire->getContenuId(), 'datemsg' => $commentaire->getDate())); //var_dump($info); //exit; } }