• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Topic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: topicCount

function topicCount($category_id)
{
    if ($category_id == null) {
        $topicCount = new Topic();
        return $topicCount->getTotalTopics();
    } else {
        $db = new Database();
        $db->query("SELECT * FROM topics WHERE category_id = :category_id");
        $db->bind(':category_id', $category_id);
        $row = $db->resultset();
        $count = $db->rowCount();
        return $count;
    }
}
开发者ID:GuptaAkshay,项目名称:DiscussionSpace,代码行数:14,代码来源:db_helper.php


示例17: add_post

function add_post()
{
	global $CONF;
	$user = $_SESSION['user'];

	if ($user->getBanned()>0){
		return array('ok'=>false, 'error'=>'banned '.$user->getBanned());
	}

	if (isset($_SESSION['post_last_flood_time'])){

		if ((time() - $_SESSION['post_last_flood_time']) < $CONF['post_time_to_wait_flood']){
			$time_to_wait = $CONF['post_time_to_wait_flood'] - (time() - $_SESSION['post_last_flood_time']);
			return array('ok'=>false, 'error'=>'flood '.$time_to_wait);
		}

	}

	$post = new Post();

	$topic = new Topic(); $topic->setId($_GET['topicid_add_post']);

	if (!$topic->getChannel()->canIPost())
		return array('ok'=>false, 'error'=>'you cant create post in this channel');

	$post->setTopic($topic);
	$post->setUser($user);

	$msg = unescape_ampersand($_POST['msg']);
	if (strlen(str_replace(' ', '', strip_tags($msg))) < $CONF['min_msg_chars'])
		return array('ok'=>false, 'error'=>'too short message');

	$msg = strip_tags($msg, $CONF['permitted_tags_msg']);
	//$msg = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]","<a target=\"_BLANK\" href=\"\\0\">\\0</a>", $msg); //detectando URLs
	$msg = text_linkify($msg);
	$post->setPost($msg);

	if ($post->save()=='ok'){
		$_SESSION['post_last_flood_time']=time();	

		$topic->follow();
		$topic->setId($topic->getId());	$topic->load(); //update topic->counter
		$topic->visit();
		return array('ok'=>true, 'error'=>'');
	}
	else
		return array('ok'=>false, 'error'=>'Problem with this post.');
}
开发者ID:rczeus,项目名称:Rapid-Coffee,代码行数:48,代码来源:add_post.php


示例18: get_topics

function get_topics($con, $args)
{
    $topics = array();
    if (isset($args["tid"])) {
        $tid = $args["tid"];
        $sql = $con->prepare("SELECT sid,tname,`order` FROM topic WHERE tid=?");
        $sql->bind_param("i", $tid);
        $sql->bind_result($sid, $tname, $order);
        $sql->execute();
        $sql->fetch();
        $sql->close();
        if (isset($sid) && isset($tname) && isset($order)) {
            $tmp = new Topic();
            $tmp->populate($sid, $tid, $tname, [], $order);
            $topics[] = $tmp->expose();
        }
    } else {
        if (isset($args["tname"])) {
            $tname = $args["tname"];
            $sql = $con->prepare("SELECT sid,tid,`order` FROM topic WHERE tname=?");
            $sql->bind_param("s", $tname);
            $sql->bind_result($sid, $tid, $order);
            $sql->execute();
            while ($sql->fetch()) {
                if (isset($sid) && isset($tid) && isset($order)) {
                    $tmp = new Topic();
                    $tmp->populate($sid, $tid, $tname, [], $order);
                    $topics[] = $tmp->expose();
                }
            }
            $sql->close();
        } else {
            $sql = $con->prepare("SELECT sid,tid,tname,`order` FROM topic");
            $sql->bind_result($sid, $tid, $tname, $order);
            $sql->execute();
            while ($sql->fetch()) {
                if (isset($sid) && isset($tid) && isset($tname) && isset($order)) {
                    $tmp = new Topic();
                    $tmp->populate($sid, $tid, $tname, [], $order);
                    $topic = $tmp->expose();
                    $topics[] = $topic;
                }
            }
            $sql->close();
        }
    }
    return $topics;
}
开发者ID:nathanmarianovsky,项目名称:manualmath.com,代码行数:48,代码来源:topic_functions.php


示例19: actionList

 public function actionList()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'id asc';
     $topics = Topic::model()->findAll($criteria);
     $this->render('list', array('topics' => $topics));
 }
开发者ID:jackycgq,项目名称:24beta,代码行数:7,代码来源:TopicController.php


示例20: run

 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 50; $i++) {
         $new = Topic::create(array('author' => $faker->name, 'title' => $faker->sentence(10), 'message' => $faker->paragraphs(2, true), 'place' => $faker->randomElement(array('web', 'api')), 'updated_at' => $faker->dateTime('now'), 'created_at' => $faker->dateTime('now')));
     }
 }
开发者ID:roffjump,项目名称:forum,代码行数:7,代码来源:TopicTableSeeder.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Tpl类代码示例发布时间:2022-05-23
下一篇:
PHP TooltipManager类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap