本文整理汇总了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();
}