本文整理匯總了PHP中News::findAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP News::findAll方法的具體用法?PHP News::findAll怎麽用?PHP News::findAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類News
的用法示例。
在下文中一共展示了News::findAll方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionAll
public function actionAll()
{
$items = News::findAll();
/*echo '<pre>';
print_r($items);
echo '</pre>';*/
$view = new View();
$view->assign('items', $items);
$template = 'news/news_view.php';
$view->display($template);
}
示例2: actionAll
public function actionAll()
{
$items = News::findAll();
if ($items == false) {
header("HTTP/1.0 404 Not Found");
throw new E404Exception('News cannot be found');
}
$view = new View();
$view->assign('items', $items);
$template = 'news/news_view.php';
$view->display($template);
}
示例3: actionAll
public function actionAll()
{
/* $art = NewsModel::findOneByColumn('title', 'Today in the world ');
$art->title = 'New heading';
$art->update(); */
/* $art->insert();
$art->update();
var_dump($art->id); */
/*
$article =News::findall();
$article->title = 'lorem';
$article->text = 'Hello, World';
// $article->insert();
$article->getAll();
var_dump($article);
// var_dump(isset($article->title));
// var_dump(NewsModel::findOneByPk(3));
/*
$db = new DB();
$res = $db->query('SELECT * FROM news where id =:id',
[':id' => 2]
);
var_dump($res);
die;
*/
echo 'actionAll';
$items = News::findAll();
echo json_encode($items);
die;
$view = new View();
$view->items = $items;
$view->display('news/all.php');
$view->display('contact_us.php');
echo count($view);
die;
// include __DIR__. '/../views/news/all.php';
}
示例4: foreach
?>
</a>
</li>
<?php
}
?>
</ul>
</div>
</aside>
</div>
<div class="widgets widgets-3 one-fourth">
<aside class="widget widget_recent_entries" id="recent-posts-4"> <h3 class="widget-title">News</h3>
<ul>
<?php
foreach (News::findAll(3) as $news) {
?>
<li>
<a href="<?php
echo uri('news/' . $news->getId());
?>
"><?php
echo $news->getTitle();
?>
</a>
</li>
<?php
}
?>
</ul>
</aside>
示例5: isset
<?php
require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/News.php";
$page_name = isset($_GET['p']) && $_GET['p'] ? $_GET['p'] : null;
try {
ensure_page_name_safe($page_name);
if (!$page_name) {
$view_path = TEMPLATE_PATH . '/news/list.php';
$params = array('news_array' => News::findAll(), 'title' => '新聞');
} else {
$view_path = NEWS_ROOT_PATH . "/{$page_name}." . MarkdownPage::extension;
$news_page = new News($page_name);
$params = array('news' => $news_page, 'title' => $news_page->getTitle() . " - 新聞");
}
$params = array_merge($params, array('current_page' => 'news'));
$view = new SimpieView($view_path, "../templates/layout/common_page.php");
$view->render($params);
} catch (PageNotFoundException $e) {
$view = new SimpieView("../templates/book_page_404.php", "../templates/layout/book.php");
$view->render(array('book_page' => $page_name));
}
示例6: if
<div class="col-sm-offset-1 col-sm-10">
<button type="submit" class="btn btn-default" name="submit">Добавить</button>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="panel">
<div class="panel-body">
<!--/stories-->
<?php if(!empty($_SESSION['error'])):?>
<?php echo '<p style="text-align: center;">'.$_SESSION['error'].'</p>'?>
<?php unset($_SESSION['error']); ?>
<?php endif;?>
<?php $newses = News::findAll();?>
<?php foreach ($newses as $key): ?>
<?php $news_avtor = $key->avtor; ?>
<?php $id = $key->id?>
<?php $avtors = Login::findAll(); ?>
<?php foreach ($avtors as $rey): ?>
<?php $login_name = $rey->login; ?>
<?php if ($news_avtor == $login_name): ?>
<?php $img_src = $rey->img; ?>
<?php endif; ?>
<?php endforeach; ?>
示例7: _sort_pages
<?php
require_once "../lib/common.inc.php";
require_once "../lib/FeedWriter/FeedItem.php";
require_once "../lib/FeedWriter/FeedWriter.php";
require_once "../lib/SimpieView.php";
require_once "../models/News.php";
require_once "../models/BookPage.php";
$news = News::findAll();
$book_pages = BookPage::getFlatPagesArray();
/** Merge the pages **/
$pages = array_merge($news, $book_pages);
/** Sort Desc **/
function _sort_pages($page1, $page2)
{
if ($page1->getLastUpdatedAt() == $page2->getLastUpdatedAt()) {
return 0;
}
// Desc
return $page1->getLastUpdatedAt() > $page2->getLastUpdatedAt() ? -1 : 1;
}
usort($pages, '_sort_pages');
/** Start Feed Output **/
$last_updated_at = null;
$feed = new FeedWriter(RSS2);
$feed->setTitle(SITE_NAME);
$feed->setLink(url_for("/", IS_ABSOLUTE_URL));
$feed->setDescription(SITE_DESC);
$feed->setChannelElement('language', 'zh-cn');
// get flat pages
foreach ($pages as $page) {
示例8: Pagination
</tr>
</thead>
<tbody id="alter_rows">
<?php
$count_record = News::countNews();
if (!isset($_REQUEST['page'])) {
$page = 1;
} else {
$page = $_GET[page];
}
$pagination = new Pagination();
//for display
$pg = $pagination->page_pagination(20, $count_record, $page, 20);
//$result_prod = mysql_query($query_Recordset2.$pg[1]);
$news = News::findAll($pg[1]);
?>
<? if($count_record == 0) { ?>
<tr>
<td colspan="6" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#F00; font-weight:bold">No Record Found</td>
</tr>
<? } else {
foreach($news as $newss) {
?>
<tr>
<td> <?php
echo $newss->fldNewsID;
?>
</td>
<td><?php
示例9: isset
<?php
$page = isset($_GET['page']) ? $_GET['page'] : 1;
if (!preg_match('/^\\d+$/', $page)) {
dispatch('core/backend/404');
exit;
}
$objects = News::findAll();
$html = new HTML();
$html->renderOut('core/backend/html_header', array('title' => i18n(array('en' => 'News', 'zh' => 'News'))), true);
$html->output('<div id="wrapper">');
$html->renderOut('core/backend/header');
$perpage = 50;
$total = News::countAll();
$total_page = ceil($total / $perpage);
$html->renderOut('news/backend/news_list', array('objects' => News::findAllWithPage($page, $perpage), 'current_page' => $page, 'total_page' => $total_page, 'total' => $total, 'pager' => $html->render('core/components/pagination', array('total' => $total_page, 'page' => $page)), 'start_entry' => ($page - 1) * $perpage + 1, 'end_entry' => min(array($total, $page * $perpage))), true);
$html->output('</div>');
$html->renderOut('core/backend/html_footer');
exit;
示例10: actionAll
protected function actionAll()
{
$view = new View('view/indexv.php');
$view->news = News::findAll();
$view->display();
}
示例11: sizeof
<section style="background-color:#f5f5f5;" class="section-content section-bg"><div class="container clearfix">
<div class="entry-content">
<div class="dm3-one-half">
<h2>Latest news</h2>
<?php
$i = 0;
$allnews = News::findAll(3);
foreach ($allnews as $news) {
$i++;
?>
<div class="news <?php
echo $i == 1 ? 'first' : ($i == sizeof($allnews) ? 'last' : '');
?>
">
<div class="left"><img src="<?php
echo $news->getThumbnail();
?>
"></div>
<div class="right">
<p><?php
echo date('jS M Y', $news->getDate());
?>
</p>
<h3><a href="<?php
echo uri('news/' . $news->getId());
?>
"><?php
echo $news->getTitle();
?>
</a></h3>
</div>
示例12: session_start
<?php
session_start();
require __DIR__ . '/../function.php';
require_once __DIR__ . '/../autoload.php';
$images = News::findAll();
$files = __DIR__ . '/../img/';
$nazva = $_POST['foto_name'];
$cook = getUser();
if (upload_file_cabinet($files, $cook) == true) {
$_SESSION['error'] = 'Файл загружен!';
} else {
$_SESSION['error'] = 'Файл не загружен, попробуйте переименовать!';
}
//upload_file_cabinet($files ,$cook);
header('location: /../views/cabinet.php');
示例13: getUser
<li>
<a href="#"></a>
</li>
<li>
<a href="#"></a>
</li>
<li>
<a href="#"></a>
</li>
</ul>
<ul class="nav navbar-right navbar-nav">
<li >
<a href="cabinet.php"><?php echo getUser(); ?>
<?php $col = News::findAll();?>
<?php $i = 0;?>
<?php foreach($col as $val):?>
<?php if($val->ispoln == getUser()|| $val->ispoln2 == getUser() || $val->ispoln3 == getUser()
|| $val->ispoln4 == getUser()|| $val->ispoln5 == getUser() || $val->otvets == getUser()): ?>
<?php $i++;?>
<?php endif;?>
<?endforeach;?>
<span class=" glyphicon glyphicon-user" aria-hidden="true"></span>
<span style="color:red;"><?php if ($i>0){echo $i;};?></span>
</a>
</li>
<li> <a href="/logout.php">Выход</a></li>
示例14: array
<?php
require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/News.php";
$page_name = (isset($_GET['p']) && $_GET['p']) ? $_GET['p'] : null;
try
{
ensure_page_name_safe($page_name);
if(!$page_name) {
$view_path = TEMPLATE_PATH . '/news/list.php';
$params = array(
'news_array' => News::findAll()
);
}
else {
$view_path = NEWS_ROOT_PATH . "/{$page_name}." . MarkdownPage::extension;
$params = array(
'news' => new News($page_name)
);
}
$params = array_merge($params, array('current_page' => 'news', 'title' => '新聞'));
$view = new SimpieView($view_path, "../templates/layout/common_page.php");
$view->render($params);
}
catch(PageNotFoundException $e)