當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Topic::setTitle方法代碼示例

本文整理匯總了PHP中Topic::setTitle方法的典型用法代碼示例。如果您正苦於以下問題:PHP Topic::setTitle方法的具體用法?PHP Topic::setTitle怎麽用?PHP Topic::setTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Topic的用法示例。


在下文中一共展示了Topic::setTitle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create

    public function create($title, $idAuthor, SCategory $SCategory)
    {
        $topic = new Topic($this->db);
        try {
            $topic->setTitle($title);
            $topic->setIdAuthor($idAuthor);
            $topic->setSCategory($SCategory);
        } catch (Exception $e) {
            $errors = $e->getMessage();
        }
        if (!isset($err)) {
            $title = $this->db->quote($topic->getTitle());
            $idAuthor = $topic->getIdAuthor();
            $idSCategory = $topic->getidSCategory();
            $query = 'INSERT INTO topic(title, id_author, id_scategory)
						VALUE (' . $title . ',' . $idAuthor . ', ' . $idSCategory . ')';
        }
        $res = $this->db->exec($query);
        if ($res) {
            $id = $this->db->lastInsertId();
            if ($id) {
                return $this->findById($id);
            } else {
                throw new Exception('Database error');
            }
        } else {
            throw new Exception($errors);
        }
    }
開發者ID:Hollux,項目名稱:mvcBase2,代碼行數:29,代碼來源:TopicManager.class.php

示例2: create

 public function create(SousRubrique $sous_rubrique, User $user, $title)
 {
     $topic = new Topic($this->db);
     $valide = $topic->setTitle($title);
     if ($valide === true) {
         $valide = $topic->setAuthor($user);
         if ($valide === true) {
             $valide = $topic->setId_Sous_rubrique($sous_rubrique);
             if ($valide === true) {
                 $title = mysqli_real_escape_string($this->db, $topic->getTitle());
                 $id_author = $user->getId();
                 $id_sous_rubrique = $topic->getIdSousRubrique();
                 $query = "INSERT INTO topic (id_sous_rubrique, id_author, title) VALUES('" . $id_sous_rubrique . "', '" . $id_author . "', '" . $title . "')";
                 $res = mysqli_query($this->db, $query);
                 if ($res) {
                     $id = mysqli_insert_id($this->db);
                     if ($id) {
                         return $this->findById($id);
                     } else {
                         return "Internal server error";
                     }
                 } else {
                     echo 'test14';
                     exit;
                     return mysqli_error($this->db);
                 }
             } else {
                 return $valide;
             }
         } else {
             return $valide;
         }
     } else {
         return $valide;
     }
 }
開發者ID:Hollux,項目名稱:Fennec,代碼行數:36,代碼來源:TopicManager.class.php

示例3: processTopicForm

 /**
  * 
  * @param sfWebRequest $request
  * @param sfForm $form
  * @param Room $room
  * @return <bool> false if preview action
  */
 protected function processTopicForm(sfWebRequest $request, sfForm $form, Room $room, User $user)
 {
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         if ($this->getRequestParameter('submitAct')) {
             $values = $form->getValues();
             // topic saving
             $topic = new Topic();
             $topic->setTitle($values['title']);
             $topic->setIdRoom($room->getId());
             $topic->setIdUser($user->getId());
             $topic->save();
             // post saving
             $post = new Post();
             $post->setContent($values['post']['content']);
             $post->setIdTopic($topic->getId());
             $post->setIdUser($user->getId());
             $post->save();
             $this->redirect('room_topic_show', $topic);
         } else {
             if ($this->getRequestParameter('prevSubmitAct')) {
                 return;
             } else {
                 return false;
             }
         }
     }
 }
開發者ID:rollmax,項目名稱:read2read,代碼行數:35,代碼來源:actions.class.php


注:本文中的Topic::setTitle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。