本文整理汇总了PHP中Topic::get_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Topic::get_by_id方法的具体用法?PHP Topic::get_by_id怎么用?PHP Topic::get_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topic
的用法示例。
在下文中一共展示了Topic::get_by_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTopicToTest
function addTopicToTest($id = 1)
{
$toc = new Topic();
$toc->get_by_id($id);
$t = new Test();
$t->get_by_id(2);
if ($t->save($toc)) {
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();
}