本文整理汇总了PHP中Topic::createTopic方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::createTopic方法的具体用法?PHP Topic::createTopic怎么用?PHP Topic::createTopic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::createTopic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTopic
/**
* createTopics-funktio lähettää Topic-mallille kutsun luoda uusi keskustelu ja Message-mallille lisätä uusi viesti
*/
public static function createTopic()
{
$params = $_POST;
if ($params['title'] != null && $params['content'] != null && !ctype_space($params['title']) && !ctype_space($params['content'])) {
$topic = Topic::createTopic($params['title'], $params['category']);
$message = Message::createMessage($topic->id, $params['content']);
$messages = Message::all($topic->id);
View::make('keskustelu.html', array('topic' => $topic, 'messages' => $messages));
}
$categories = Category::all();
View::make('luokeskustelu.html', array('categories' => $categories, 'error' => "Otsikko tai aloitusviestisi oli tyhjä"));
}
示例2: Topic
<?php
require_once 'core/init.php';
$topic = new Topic();
$validate = new Validate();
if (isset($_POST['do_create'])) {
$data = array();
$data['title'] = $_POST['title'];
$data['body'] = $_POST['body'];
$data['category_id'] = $_POST['category'];
$data['user_id'] = getUser()['user_id'];
date_default_timezone_set('America/New_York');
$data['last_activity'] = date("Y-m-d H:i:s");
$field_array = array('title', 'body', 'category');
if ($topic->createTopic($data)) {
redirect('index.php', 'Your topic has been posted', 'success');
} else {
redirect('topic.php?id=' . $topic_id, 'something went wrong', 'error');
}
}
$template = new Template('templates/create.php');
echo $template;
?>
<!-- controller -->