当前位置: 首页>>代码示例>>PHP>>正文


PHP Posts::orderBy方法代码示例

本文整理汇总了PHP中Posts::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::orderBy方法的具体用法?PHP Posts::orderBy怎么用?PHP Posts::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Posts的用法示例。


在下文中一共展示了Posts::orderBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

<?php

$app->get('/(:page)', function ($page = 1) use($app, $settings) {
    $p = Posts::count();
    $pages = ceil($p / $settings->post_per_page);
    if ($page > $pages) {
        $app->pass();
    }
    $posts = Posts::orderBy('creation', 'desc')->skip($settings->post_per_page * ($page - 1))->take($settings->post_per_page)->get();
    $arr = array();
    //Posts
    foreach ($posts as $post) {
        if ($post['active'] == 'true') {
            $post['author'] = Users::get_author($post['user_id']);
            $post['date'] = date('d-m-Y H:i', $post['creation']);
            $post['url'] = $app->request->getUrl() . $app->request->getPath() . 'post/' . $post['id'];
            if ($settings->truncate == 'true') {
                $text = truncate_to_n_words($post['text'], 70, $post['url']);
                $post['text'] = $app->markdown->parse($text);
            } else {
                $post['text'] = $app->markdown->parse($post['text']);
            }
            $post['count'] = Posts::find($post['id'])->comments->count();
            $arr[] = $post;
        }
    }
    $app->render('posts.html', array('posts' => $arr, 'pages' => $pages, 'page' => $page));
})->conditions(array('page' => '\\d+'));
开发者ID:kuslahne,项目名称:SlimBlog,代码行数:28,代码来源:base.route.php

示例2: index

 /**
  * Display a listing of postst_topic
  *
  * @return Response
  */
 public function index()
 {
     $posts = Posts::orderBy('created_at', 'DESC')->get();
     return View::make('posts.index', compact('posts'));
 }
开发者ID:Abenaman,项目名称:ggc-talk,代码行数:10,代码来源:PostController.php

示例3: array

     $user = Users::whereRaw('username = ? AND password = ?', array($username, $password))->get();
     if ($user->count() != 0) {
         $_SESSION['user'] = $username;
         $app->redirect($settings->base_url . '/admin');
     } else {
         $app->flash('error', 1);
         $app->redirect($settings->base_url . '/admin/login');
     }
 });
 $app->get('/logout/', $authenticate($app, $settings), function () use($app, $settings) {
     unset($_SESSION['user']);
     $app->view()->setData('user', null);
     $app->redirect($settings->base_url);
 });
 $app->get('/', $authenticate($app, $settings), function () use($app) {
     $posts = Posts::orderBy('creation', 'desc')->get();
     $arr = array();
     foreach ($posts as $post) {
         $post['author'] = Users::get_author($post['user_id']);
         $post['date'] = date('d-m-Y H:i', $post['creation']);
         $post['url'] = $app->request->getUrl() . $app->request->getPath() . 'post/' . $post['id'];
         $arr[] = $post;
     }
     $app->render('a_posts.html', array('posts' => $arr));
 });
 $app->get('/posts/new/', $authenticate($app, $settings), function () use($app) {
     $flash = $app->view()->getData('flash');
     $error = isset($flash['error']) ? $flash['error'] : '';
     $app->render('a_post_new.html', array('error' => $error));
 });
 $app->post('/posts/new', $authenticate($app, $settings), function () use($app, $settings) {
开发者ID:kuslahne,项目名称:SlimBlog,代码行数:31,代码来源:admin.route.php


注:本文中的Posts::orderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。