示例#1
0
 private function insert(QCM $qcm)
 {
     $qcm_id = -1;
     try {
         $req = $this->pdo->prepare('INSERT INTO mp_qcm (name, owner, date_start, date_end, reponses, description) VALUE (:name, :owner, :date_start, :date_end, :reponses, :description);');
         $req->bindParam(':name', $qcm->getLabel());
         $req->bindParam(':owner', $qcm->getUserId());
         $req->bindParam(':date_start', $qcm->getStart());
         $req->bindParam(':date_end', $qcm->getEnd());
         $req->bindParam(':description', $qcm->getDesc());
         $req->bindParam(':reponses', $qcm->toString());
         $req->execute();
         $qcm_id = $this->pdo->lastInsertId();
     } catch (PDOException $ex) {
         echo $ex->getMessage();
     }
     return $qcm_id;
 }