本文整理匯總了PHP中app\models\News::GetOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::GetOne方法的具體用法?PHP News::GetOne怎麽用?PHP News::GetOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\News
的用法示例。
在下文中一共展示了News::GetOne方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionUpdate
public function actionUpdate()
{
if (isset($_POST['submit'])) {
if (empty($_POST['title']) || empty($_POST['text'])) {
echo 'Title or text could not be empty';
echo '<br><a href="/home2/admin">Back to admin panel</a>';
exit;
}
$article = News::GetOne($_POST['id']);
$article->title = $_POST['title'];
$article->text = $_POST['text'];
if (true === $article->Save()) {
echo 'Article was updated';
echo '<br><a href="/home2/admin">Back to admin panel</a>';
exit;
} else {
echo 'Error updateing database';
echo '<br><a href="/home2/admin">Back to admin panel</a>';
exit;
}
}
if (!isset($_GET['id'])) {
echo 'Could not found the article';
echo '<br><a href="/home2/admin">Back to admin panel</a>';
exit;
}
$view = new ViewConstuctor();
$view->article = News::GetOne($_GET['id']);
$view->Display('Admin/Update');
}
示例2: actionGetOne
public function actionGetOne()
{
if (empty($_GET['id'])) {
throw new \E404Exception('Could not find the page');
}
try {
$view = new ViewConstuctor();
$view->article = NewsModel::GetOne($_GET['id']);
$view->Display('News/DisplayArticle');
} catch (\E404Exception $e) {
header('HTTP/1.0 404 Not Found');
include __DIR__ . '/../content/NotFound.php';
}
}