public function inserir(Forum $forum)
 {
     //Objetivo deste metodo é inserir um objeto no banco, fazendo-o ter persistencia.
     //utilizaremos a abstracao do SQL da classe TsqlInstruction
     //1. Foreach dos atributos . PRa cada existencia de atributo é um valor a ser adicionado.
     $instrucao = new TSqlInsert();
     $instrucao->setEntity("forum");
     if ($forum->getId() != null) {
         $instrucao->setRowData("id", $forum->getId());
     }
     if ($forum->getTitulo() != null) {
         $instrucao->setRowData("titulo", $forum->getTitulo());
     }
     if ($forum->getCorpo() != null) {
         $instrucao->setRowData("corpo", $forum->getCorpo());
     }
     if ($forum->getUsuario() != null) {
         $instrucao->setRowData("usuario", $forum->getUsuario());
     }
     echo $instrucao->getInstruction();
     if ($this->Conexao->query($instrucao->getInstruction())) {
         return true;
     } else {
         return false;
     }
 }
Exemple #2
0
 /**
  * Permet de Charger tout les topics d'un forum
  * @param forum Forum dont on doit charger les topics
  * @since 1.0.0
  */
 public function bindTopic(Forum $forum)
 {
     $sql = "SELECT topic_id id, topic_titre titre, topic_vu vu, topic_genre genre\n\t\t\t\tFROM topic\n\t\t\t\tWHERE id_forum = :id";
     $id_forum = $forum->getId();
     $req = $this->bdd->prepare($sql);
     $req->bindParam(":id", $id_forum);
     $res = $req->execute();
     if (!$res) {
         return false;
     }
     $topics = $req->fetchAll(PDO::FETCH_OBJ);
     foreach ($topics as $topic) {
         $forum->addTopic(new Topic($topic->id, $topic->titre, NULL, $topic->vu, $topic->genre));
     }
 }
Exemple #3
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Forum $value A Forum object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Forum $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }