本文整理匯總了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 -->