本文整理匯總了PHP中Topic::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Topic::get方法的具體用法?PHP Topic::get怎麽用?PHP Topic::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Topic
的用法示例。
在下文中一共展示了Topic::get方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionPlus
public function actionPlus()
{
if (Rays::isAjax()) {
$result = ["result" => false];
if (isset($_POST['plusId']) && isset($_POST['plusType'])) {
if (is_numeric($_POST['plusId'])) {
$plusId = $_POST['plusId'];
$userId = 0;
if (Rays::isLogin()) {
$userId = Rays::user()->id;
}
$host = Rays::app()->request()->getUserHostAddress();
switch ($_POST['plusType']) {
case Topic::ENTITY_TYPE:
if (Topic::get($plusId) !== null) {
$plus = new RatingPlus(Topic::ENTITY_TYPE, $plusId, $userId, $host);
if ($plus->rate()) {
$result = ["result" => true, "counter" => $plus->getCounter()->value];
}
}
break;
case Group::ENTITY_TYPE:
if (Group::get($plusId) !== null) {
$plus = new RatingPlus(Group::ENTITY_TYPE, $plusId, $userId, $host);
if ($plus->rate()) {
$result = ["result" => true, "counter" => $plus->getCounter()->value];
}
}
break;
}
}
}
echo json_encode($result);
exit;
}
}
示例2: actionDelete
public function actionDelete($topicId)
{
$topic = Topic::get($topicId);
if ($topic === null) {
$this->flash("message", "No such topic!");
} else {
$topic->delete();
$this->flash("message", "Post " . $topic->title . " was deleted.");
}
if ($url = Rays::getParam("returnUrl", null)) {
$this->redirect($url);
} else {
$this->redirect(Rays::referrerUri());
}
}
示例3: lists
function lists()
{
$t = new Topic();
$t->get();
//datamapper的json擴展真是強大
echo $t->all_to_json();
}