[eluser]theknight[/eluser]
Code:
// setting offset for pagination
$offset=is_numeric($this->uri->segment($page_segment))?
$this->uri->segment($page_segment):
0;
$q = "
SELECT
Notices.Id,
NoticeLoc.Notices_Id,
Loc.Id as Loc_Id,
CAST(Notices.Text AS TEXT) as Text,
CAST(Notices.Title AS TEXT) as Title,
Notices.CDate as RDate
FROM NoticeLoc
JOIN Notices ON NoticeLoc.Notices_Id=Notices.Id JOIN Loc ON NLoc.Loc_Id=Loc.Id WHERE Loc_Id IN (1)
UNION
SELECT
Notices.Id,
'',
'',
CAST(Notices.Text AS TEXT) as Text,
CAST(Notices.Title AS TEXT) as Title,
Notices.CDate as RDate
FROM NoticeC
JOIN Notices ON NoticeC.Notices_Id=Notices.Id WHERE C_Id=110 AND CDate BETWEEN '10/01/2011' AND '07/14/2025' ORDER BY RDate desc ";
$query = $this->db->query($q);
//result array
$Notices = $query->result_array();
//count total number of records in query
$recCnt = count($Notices);
//pagination
//slice array, so that you only get the amount defined in the limit
$config['total_rows'] = array_slice($query, $page_segment , $limit);
$config['per_page'] = $limit;
$this->pagination->initialize($config);
//pass onto the controller
return array("paging"=>$this->pagination->create_links(),"notices"=>$notices);
I can't seem to get the final part working, page successfully loads all fo the notices, but pagination fails. Page ends up displaying all of the notices rather then, specific ones after slicing the array.
Any idea why?
cheers.