本文整理匯總了PHP中Topic::to_json方法的典型用法代碼示例。如果您正苦於以下問題:PHP Topic::to_json方法的具體用法?PHP Topic::to_json怎麽用?PHP Topic::to_json使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Topic
的用法示例。
在下文中一共展示了Topic::to_json方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addTopic
function addTopic($title = 'none')
{
$toc = new Topic();
$toc->tocTitle = $title;
$toc->tocMax = 4;
if ($toc->save()) {
echo $toc->to_json();
}
}
示例2: edit
public function edit($id = 0)
{
$obj = new Topic();
$obj->get_by_id((int) $id);
if (!$_POST) {
echo $obj->to_json();
} else {
if (isset($_POST['model']) and $model = $_POST['model']) {
$testid = $this->session->userdata('testid');
$topic = new Topic();
$topic->from_json($model);
$topic->test_id = $testid;
if ($topic->save()) {
echo $topic->to_json();
} else {
echo array('error' => $test->error->string);
}
} else {
if (isset($_POST['_method']) and $_POST['_method'] === 'DELETE') {
$obj->delete();
}
}
}
}
示例3: index
public function index($id)
{
$t = new Topic();
$t->get_by_id(13);
echo $t->to_json();
}