当前位置: 首页>>代码示例>>PHP>>正文


PHP Topic类代码示例

本文整理汇总了PHP中Topic的典型用法代码示例。如果您正苦于以下问题:PHP Topic类的具体用法?PHP Topic怎么用?PHP Topic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Topic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeSave

 public function beforeSave($options = array())
 {
     //parent::beforeSave($options);
     //print_r($this->data);
     $loggedInUser = AuthComponent::user();
     $found = false;
     $userId = $loggedInUser['user_id'];
     $this->data['Post']['post_by'] = $userId;
     $this->data['Post']['post_date'] = (new DateTime())->format('Y-m-d');
     //format('Y-m-d H:i:s')
     if (!empty($this->data['Topic']['topic_subject'])) {
         $str = $this->data['Topic']['topic_subject'];
         $num = $this->data['Post']['post_cat'];
         $subject = new Topic();
         $found = $subject->find('first', array('conditions' => array('Topic.topic_subject LIKE' => $str, 'Topic.topic_cat =' => $num)));
         if (!$found) {
             $subject->create();
             //create topic
             $subject->save(array('topic_subject' => $this->data['Topic']['topic_subject'], 'topic_date' => (new DateTime())->format('Y-m-d'), 'topic_cat' => $this->data['Post']['post_cat'], 'topic_by' => $userId));
             //see also save associated model method cakephp
             $this->data['Post']['post_topic'] = $this->Topic->getLastInsertId();
             return true;
         }
         $this->data['Post']['post_topic'] = $found['Topic']['topic_id'];
         return true;
     }
     //nothing
     return true;
 }
开发者ID:s3116979,项目名称:BulletinBoard,代码行数:29,代码来源:Post.php

示例2: run

 public function run()
 {
     $table = $this->getTable();
     $title = 'Lorem ipsum dolor sit amet';
     $topic = new Topic(['title' => $title]);
     $topic->save();
 }
开发者ID:niclasleonbock,项目名称:eloquent-activatable,代码行数:7,代码来源:TopicTableSeeder.php

示例3: delete_category

 function delete_category($params = array(), $param_op = 'AND')
 {
     $categories = $this->select_record($params, array('id'), $param_op);
     $topic = new Topic($this->config);
     foreach ($categories as $category) {
         $topic->delete_record(array('category' => $category['id']));
     }
     $this->delete_record($params);
 }
开发者ID:dg711,项目名称:geekportal,代码行数:9,代码来源:Category.php

示例4: DropTables

 function DropTables()
 {
     $moderator = new Moderator();
     $moderator->SetDatabase($this);
     $moderator->Drop();
     $message = new Message();
     $message->SetDatabase($this);
     $message->Drop();
     $topic = new Topic();
     $topic->SetDatabase($this);
     $topic->Drop();
     $user_info = new UserInfo();
     $user_info->SetDatabase($this);
     $user_info->Drop();
     $session = new Session();
     $session->SetDatabase($this);
     $session->Drop();
     $new = new News();
     $new->SetDatabase($this);
     $new->Drop();
     $shout = new Shout();
     $shout->SetDatabase($this);
     $shout->Drop();
     $paragraph = new Paragraph();
     $paragraph->SetDatabase($this);
     $paragraph->Drop();
     $privilege = new Privilege();
     $privilege->SetDatabase($this);
     $privilege->Drop();
     $role = new Role();
     $role->SetDatabase($this);
     $role->Drop();
     $menu_item = new MenuItem();
     $menu_item->SetDatabase($this);
     $menu_item->Drop();
     $module = new Module();
     $module->SetDatabase($this);
     $module->Drop();
     $page = new Page();
     $page->SetDatabase($this);
     $page->Drop();
     $article = new Article();
     $article->SetDatabase($this);
     $article->Drop();
     $subject = new Subject();
     $subject->SetDatabase($this);
     $subject->Drop();
     $menu = new Menu();
     $menu->SetDatabase($this);
     $menu->Drop();
     $profile = new Profile();
     $profile->SetDatabase($this);
     $profile->Drop();
     $user = new User();
     $user->SetDatabase($this);
     $user->Drop();
 }
开发者ID:googlecode-mirror,项目名称:schifers,代码行数:57,代码来源:cdDatabase.php

示例5: addTopic

function addTopic($topic_ancestor_id, $topic_name)
{
    $ancestor_object = TopicQuery::create()->findOneById($topic_ancestor_id);
    $topic_object = new Topic();
    $topic_object->setName($topic_name)->insertAsLastDescendantOf($ancestor_object)->save();
    $topic_synonym_object = new TopicSynonym();
    $topic_synonym_object->setName($topic_name)->setTopic($topic_object)->save();
    return $topic_object->getId();
}
开发者ID:arneau,项目名称:defender-app,代码行数:9,代码来源:topics.php

示例6: addTopicToTest

 function addTopicToTest($id = 1)
 {
     $toc = new Topic();
     $toc->get_by_id($id);
     $t = new Test();
     $t->get_by_id(2);
     if ($t->save($toc)) {
         echo $toc->to_json();
     }
 }
开发者ID:htom78,项目名称:peersay,代码行数:10,代码来源:ormTest.php

示例7: PostTopic

 /**
  * This will post a new Topic for this forum along with the topic's first / initial message.
  * 
  * @param string $strTitle
  * @param string $strMessageText
  * @param Person $objPerson
  * @param QDateTime $dttPostDate
  * @return Topic
  */
 public function PostTopic($strTitle, $strFirstMessageText, Person $objPerson, QDateTime $dttPostDate = null)
 {
     $objTopic = new Topic();
     $objTopic->TopicLink = $this->TopicLink;
     $objTopic->Name = $strTitle;
     $objTopic->Person = $objPerson;
     $objTopic->Save();
     $objTopic->PostMessage($strFirstMessageText, $objPerson, $dttPostDate);
     return $objTopic;
 }
开发者ID:qcodo,项目名称:qcodo-website,代码行数:19,代码来源:Forum.class.php

示例8: delete

 public function delete(Topic $topic)
 {
     $id = $topic->getId();
     $query = "DELETE FROM topic WHERE id='" . $id . "'";
     $res = mysqli_query($this->db, $query);
     if ($res) {
         return true;
     } else {
         return "Internal Server Error";
     }
 }
开发者ID:Hollux,项目名称:Fennec,代码行数:11,代码来源:TopicManager.class.php

示例9: unfollowtopic

function unfollowtopic(){

	$topic = new Topic();
	if (!isset($_GET['topicid_unfollowtopic']))
		return array("ok"=>false, "error"=>"no id");
	$topic->setId($_GET['topicid_unfollowtopic']);
	if ($topic->unfollow())
		return array("ok"=>true, "error"=>"");
	else
		return array("ok"=>false, "error"=>"cant unfollow");

}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:12,代码来源:unfollowtopic.php

示例10: create

 public function create($titre)
 {
     $topic = new Topic($this->link);
     $topic->setTitre($titre);
     $titre = mysqli_real_escape_string($this->link, $titre);
     $request = "INSERT INTO topics (titre, id_auteur, id_category) VALUES ('" . $titre . "', '" . $_SESSION['id'] . "', '" . $this->id . "')";
     $res = mysqli_query($this->link, $request);
     if ($res) {
         return $this->select(mysqli_insert_id($this->link));
     } else {
         throw new Exception("Internal server error");
     }
 }
开发者ID:jmgerber,项目名称:forum,代码行数:13,代码来源:Categorie.class.php

示例11: getTopicStartTest

function getTopicStartTest($t_id)
{
    // Wertprüfung
    $t_id = abs(intval($t_id));
    echo '<form action="index.php?site=start_test&amp;action=getQuestions" method="post">';
    $button = Function_getTopic_03;
    $topic = new Topic();
    $topic->getActiveTopic();
    $arrayTopic = $topic->getTopicArray();
    echo " <div id=\"inner_box_top\">\n";
    // In der Mitte der Inhalt
    showForm($t_id, $button, $arrayTopic);
}
开发者ID:eruedin,项目名称:cats,代码行数:13,代码来源:getTopic.php

示例12: CreateTopicAndTopicLink

 /**
  * Creates the Topic and TopicLink for this Package object.
  * @param Person $objPerson person who created this package who will be credited with creating the linked topic
  * @return Topic
  */
 public function CreateTopicAndTopicLink(Person $objPerson)
 {
     $objTopicLink = new TopicLink();
     $objTopicLink->TopicLinkTypeId = TopicLinkType::Package;
     $objTopicLink->Package = $this;
     $objTopicLink->Save();
     $objTopic = new Topic();
     $objTopic->TopicLink = $objTopicLink;
     $objTopic->Name = $this->strName;
     $objTopic->Person = $objPerson;
     $objTopic->Save();
     return $objTopic;
 }
开发者ID:klucznik,项目名称:qcodo-website,代码行数:18,代码来源:Package.class.php

示例13: create

 public function create()
 {
     foreach ($this->required as $required => $strlen) {
         if (!Input::has($required) || strlen(Input::get($required)) < $strlen) {
             return Response::make(['error' => 'You must introduce a ' . $required . ' with ' . $strlen . ' of length...'], 404);
         }
     }
     $new = new Topic();
     $new->fill(Input::only(['title', 'author', 'message']));
     $new->place = $this->place;
     $new->save();
     return Response::make(['success' => 'You just created a new topic!', 'topic' => $new->toArray()], 404);
 }
开发者ID:roffjump,项目名称:forum,代码行数:13,代码来源:TopicRestApiController.php

示例14: idsFromNames

 /**
  * Given a list of topic names, return the list of topic ids
  */
 public static function idsFromNames(array $names)
 {
     $ids = [];
     foreach ($names as $name) {
         $topic = static::whereName($name)->first();
         if (!$topic) {
             $topic = new Topic();
             $topic->name = $name;
             $topic->save();
         }
         $ids[] = $topic->id;
     }
     return $ids;
 }
开发者ID:binondord,项目名称:laravel-recipes,代码行数:17,代码来源:Topic.php

示例15: downVote

 public function downVote(Topic $topic)
 {
     if (Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('downvote')->count()) {
         Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('downvote')->delete();
         $topic->increment('recommend_add', 1);
     } elseif (Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('upvote')->count()) {
         Recomment::user(Auth::user()->user_id)->topic($topic->topic_id)->type('upvote')->delete();
         Recomment::create(['user_id' => Auth::user()->user_id, 'topic_id' => $topic->topic_id, 'status' => '0', 'types' => 'downvote']);
         $topic->decrement('recommend_add', 2);
     } else {
         Recomment::create(['user_id' => Auth::user()->user_id, 'topic_id' => $topic->topic_id, 'status' => '0', 'types' => 'downvote']);
         $topic->decrement('recommend_add', 1);
     }
 }
开发者ID:331164885,项目名称:Laravel-Project,代码行数:14,代码来源:Recomment.php


注:本文中的Topic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。