Ejemplo n.º 1
0
<?php

$get = _get($_GET);
$lang = _getLang();
# Count query for the pager
$rowCount = db_count('post')->where()->condition('deleted', null)->fetch();
# Prerequisite for the Pager
$pager = _pager()->set('itemsPerPage', $lc_itemsPerPage)->set('pageNumLimit', $lc_pageNumLimit)->set('total', $rowCount)->set('ajax', true)->calculate();
$qb = db_select('post', 'p')->join('category', 'c', 'p.catId = c.catId')->join('user', 'u', 'p.uid = u.uid')->fields('p', array('postId', 'created', 'postTitle', 'postBody', array('postTitle_' . $lang, 'postTitle_i18n'), array('postBody_' . $lang, 'postBody_i18n')))->fields('c', array('catName', array('catName_' . $lang, 'catName_i18n')))->fields('u', array('fullName'))->where()->condition('p.deleted', null)->orderBy('p.created', 'DESC')->orderBy('u.fullName')->limit($pager->get('offset'), $pager->get('itemsPerPage'));
$lang = _urlLang($lang);
if ($qb->getNumRows()) {
    ?>
    <table cellpadding="0" cellspacing="0" border="0" class="list news">
        <tr class="label">
            <td class="tableLeft" colspan="2"><?php 
    echo _t('Actions');
    ?>
</td>
            <td>
                <span><?php 
    echo _t('Title');
    ?>
</span>
                <label class="lang">(<?php 
    echo _langName($lang);
    ?>
)</label>
            </td>
            <td><?php 
    echo _t('Author');
    ?>
Ejemplo n.º 2
0
$articles = $qb->getResult();
    // in view.php
    if (count($articles)) {
        foreach ($articles as $article) {
            // ...
        }
    } else {
        // ...
    }
//// OR you can even use $qb directly in view.php
$articles = $qb; // to use more user-friendly name in view.php
    // in view.php
    if ($articles->getNumRows()) {
        // ...
        while($article = $articles->fetchRow()) {
            // ...
        }
    } else {
        // ...
    }
//// you could use the above similar code for the actual querying from db
//// the below is a sample code to render the simulated data
*/
$articles = array();
$articles[] = array('title' => 'Welcome to the PHPLucidFrame Articles', 'slug' => 'welcome-to-the-lucidframe-blog', 'body' => 'PHPLucidFrame is a mini application development framework - a toolkit for PHP users. It provides several general purpose helper functions and logical structure for web application development. The goal is to provide a structured framework with small footprint that enables rapidly robust web application development.');
$articles[] = array('title' => 'Custom Routing to a Page Including a Form Example', 'slug' => 'custom-routing-to-a-page-including-a-form-example', 'body' => 'This is an example page which shows custom routing rules defined in <code class="inline">/inc/route.config.php</code>. The rule is mapping to <code class="inline">/app/blog-page/index.php</code>. That could be possible to write URL rewrite rules in <code class="inline">.htacccess</code>.');
$articles[] = array('title' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', 'slug' => 'php-micro-application-development-framework', 'body' => 'Quisque varius sapien eget lorem feugiat vel dictum neque semper. Duis consequat nisl vitae risus adipiscing aliquam. Suspendisse vehicula egestas blandit. In laoreet molestie est. Donec rhoncus sodales ligula vitae fringilla. Mauris congue blandit metus eu eleifend. Cras gravida, nisi at euismod malesuada, justo massa adipiscing nisl, porttitor tristique urna ipsum id lacus. Nullam a leo neque, eget pulvinar urna. Suspendisse fringilla ante vitae nisi ultricies vestibulum. Donec id libero quis orci blandit placerat. ');
$totalRecords = count($articles);
# Prerequisite for the Pager
$pager = _pager()->set('itemsPerPage', $lc_itemsPerPage = 2)->set('pageNumLimit', $lc_pageNumLimit)->set('total', $totalRecords)->set('ajax', false)->calculate();
$articles = array_slice($articles, $pager->get('offset'), $pager->get('itemsPerPage'));