public function getRecords() { $app = $this->app; $page = $app['request']->get('page', 1); $sql = $this->getSql(); $select = element('select', $sql); $from = element('from', $sql); $limit = element('limit', $sql); $totalRecords = $this->getTotalRecords(); $where = $this->composeWhere(); $group = $this->composeGroup(); $order = $this->composeOrder(); $app['paging']->limit($limit); $app['paging']->process($page, $totalRecords); $offset = $app['paging']->offset(); $limit = $app['paging']->limit(); $query = "SELECT {$select} FROM {$from} WHERE {$where} {$group} {$order} LIMIT {$offset}, {$limit}"; $app['trace']->debug('getRecords = ' . $query); $app['trace']->debug('total = ' . $totalRecords); return DB::select($query); }