本文整理汇总了PHP中Blog::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Blog::findAll方法的具体用法?PHP Blog::findAll怎么用?PHP Blog::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Blog
的用法示例。
在下文中一共展示了Blog::findAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Index action
* Show all blog posts
*/
public function index()
{
$blog = new Blog();
$params = array('blogs' => $blog->findAll());
$this->setParams('params', $params);
$this->render();
}
示例2: index
public function index()
{
// Blogクラスから$Blogインスタンス生成
$Blog = new Blog($this->plural_resource);
$sql = $Blog->findAll();
// 'SELECT * FROM blogs'という文字列が返ってくる
$blogs = mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
return $blogs;
}
示例3: index
public function index($category_id)
{
//var_dump($_GET['search']);
// Blogクラスから$Blogインスタンス生成
$Blog = new Blog($this->plural_resource);
if (isset($_GET['search'])) {
$sql = $Blog->findAll($category_id, $_GET['search']);
} else {
$sql = $Blog->findAll($category_id);
// 'SELECT * FROM blogs'という文字列が返ってくる
}
//var_dump($sql);
$blogs = mysqli_query($this->db, $sql) or die(mysqli_error($this->db));
//var_dump($blogs);
//var_dump('test');
$Category = new Category('categories');
$cat_sql = $Category->findAll();
//var_dump($cat_sql);
$categories = mysqli_query($this->db, $cat_sql) or die(mysqli_error($this->db));
//var_dump($categories);
$return['blogs'] = $blogs;
$return['categories'] = $categories;
return $return;
}
示例4: actionView
public function actionView($id)
{
$id = intval($id);
$blog = Blog::model()->find('id=:id', array('id' => $id));
$blog->views += 1;
$blog->save();
$catelist = Category::getDropList(1);
$model = new Blog();
$criteria = new CDbCriteria();
//查询条件
$criteria->addCondition("is_show=1");
//排序
$criteria->order = 'id DESC';
$criteria->limit = 5;
$recent = $model->findAll($criteria);
$this->render('view2', array('blog' => $blog, 'catelist' => $catelist, 'recent' => $recent));
}
示例5: getGlobal
<?php
$root = $GLOBALS['root'];
$footLines = getGlobal('footLines');
$posts = Blog::findAll("ORDER BY datetime DESC LIMIT 5");
?>
</section>
</div>
<footer>
<div class='container'>
<div class='row'>
<div class='col-sm-4 col-xs-12'>
<h2>Recent Articles</h2>
<ul>
<?php
if (count($posts)) {
foreach ($posts as $post) {
$title = $post->title;
$year = getDateElements("%Y", $post->datetime);
$link = $root . DS . 'blog' . DS . $year . DS . snakeString($title);
?>
<li><a href='<?php
echo $link . DS;
?>
'><?php
echo $title;
?>
</a></li>
<?php
}
示例6: get
/**
* Get a list of blogs
*
* @param Request $request
* @param string $params
* @return void
*/
protected static function get($request, $params)
{
$blogs = Blog::findAll($request->include);
static::response($blogs, 200);
}
示例7: foreach
<?php
$root = './../../..';
require $root . '/../app/initialize.php';
$pageTitle = 'Manage Blog';
$navSelect = 'blog';
$user = User::get('admin');
$posts = Blog::findAll("ORDER BY title ASC");
?>
<?php
includeFile('site/header.php');
?>
<h2>Blog</h2>
<h3>Articles</h3>
<?php
getAlerts();
?>
<p><a href='post.php'>Write New Post</a></p>
<?php
if (count($posts)) {
?>
<table class="table table-hover">
<tbody>
<?php
foreach ($posts as $post) {
?>