Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $contentColumns = ['c.id', 'c.type', 'c.createdAt', 'c.updatedAt', 'c.status', 'c.score', 'c.userId', 'c.title', 'c.description', 'c.thumbnail', 'c.rateCount', 'c.rateTotal', 'c.rateUpRatio', 'c.rateUpRatioSource', 'c.origin', 'c.contentHarvestedId', 'c.curated', 'c.tags', 'c.creativeContent', 'c.copyrightCritical', 'c.activeTitleCached', 'c.activeDescriptionCached' ];
- $voteColumns = [ 'count(cmr.id) as countVotes','sum(cmr.value) as sumVotes' ];
- $supervoteColumns = [ 'count(sv.contentId) as svoteCount' ];
- $columns = array_merge( $contentColumns , $voteColumns , $supervoteColumns);
- $builder = $this->modelsManager->createBuilder()
- $select
- ->columns( $columns )
- ->from( array('c' => '\Hype\Model\Content'))
- ->leftJoin( '\Hype\Model\ContentModRating','cmr.contentId=c.id','cmr')
- ->leftJoin( '\Hype\Model\Supervotes','sv.contentId=c.id','sv')
- ->groupBy( array('c.id') )
- ->orderBy('c.title');
- // intercepting sql
- $intermediate = $builder->getQuery()->parse();
- $dialect = $this->di->getDefault()->get('db')->getDialect();
- $sql = $dialect->select($intermediate);
- print_r($sql);
- $paginator = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
- "builder" => $builder,
- "limit" => $itemCount,
- "page" => (int) $value
- ) );
- ?>
- <div class="well text-center">
- <a href="/test/index/1">First</a>
- <a href="/test/index/<?= $page->before; ?>">Previous</a>
- <a href="/test/index/<?= $page->next; ?>">Next</a>
- <a href="/test/index/<?= $page->last; ?>">Last</a>
- <?php echo "<br>You are on page ", $page->current, " of ", $page->total_pages; ?>
- </div>
- <?php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement