本文整理匯總了PHP中NewsModel::findOneByPk方法的典型用法代碼示例。如果您正苦於以下問題:PHP NewsModel::findOneByPk方法的具體用法?PHP NewsModel::findOneByPk怎麽用?PHP NewsModel::findOneByPk使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類NewsModel
的用法示例。
在下文中一共展示了NewsModel::findOneByPk方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionOne
public function actionOne()
{
$id = $_GET['id'];
$news = NewsModel::findOneByPk($id);
$view = new View();
$view->items = $news;
$view->display('one.php');
}
示例2: actionOne
public function actionOne()
{
$id = $_GET['id'];
$item = NewsModel::findOneByPk($id);
if (empty($item)) {
throw new E404Exception('Нет такой новости');
}
$view = new View();
$view->item = $item;
$view->display('news/one.php');
}
示例3: actionOne
public function actionOne()
{
$id = $_GET['id'];
$item = NewsModel::findOneByPk($id);
if (!empty($item)) {
$view = new View();
$view->item = $item;
$view->display('news/one.php');
} else {
$e_message = 'Page not found: Пустой результат выборки';
$e_code = 1.1;
throw new E404Exception($e_message, $e_code);
}
}
示例4: actionDelNews
public function actionDelNews()
{
$news = new NewsModel();
$view = new View();
if (isset($_GET['id'])) {
$item = NewsModel::findOneByPk($_GET['id']);
$view->item = $item;
$view->deleted = true;
//$news->delete();
} else {
$newsTitles = NewsModel::findAll();
$view->news = $newsTitles;
}
$view->display('admin/delnews.php');
}
示例5: actionEdit
public function actionEdit()
{
$news = new NewsModel();
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$news->id = $_POST['id'];
$news->title = $_POST['title'];
$news->text = $_POST['text'];
$news->save();
header("Location: /index.php?ctrl=Admin&act=All");
}
$id = $_GET['id'];
$items = $news->findOneByPk($id);
$view = new View();
$view->item = $items;
$view->display('news/newsedit.php');
}