I have 10 subscriber tables from subscriber_0 to subscriber_9, I get all the data from them through union by custom query in subscriber model, in the function getAllSubscribers, this table executes the query and returns the result to the subscriber controller, I have set $useTable = false because there is no subscriber table, my question is how do I paginate this data in the controller?
For reference I am writing my query here and the result returned Query:
$query = 'SELECT * FROM (
SELECT * FROM subscriber_1
UNION
SELECT * FROM subscriber_2
UNION
SELECT * FROM subscriber_3
UNION
SELECT * FROM subscriber_4
UNION
SELECT * FROM subscriber_5
UNION
SELECT * FROM subscriber_6
UNION
SELECT * FROM subscriber_7
UNION
SELECT * FROM subscriber_8
UNION
SELECT * FROM subscriber_9
UNION
SELECT * FROM subscriber_0
) AS subscriber WHERE created > \'' . $startDate . '\' AND created < \'' . $endDate . '\'';
Result:
array(
(int) 0 => array(
'subscriber' => array(
'a_party' => '923003210861',
'subtype' => '0',
'stat' => '0',
'created' => '2012-11-26 06:53:31',
'updated' => null
)
),
(int) 1 => array(
'subscriber' => array(
'a_party' => '923005264511',
'subtype' => '0',
'stat' => '0',
'created' => '2012-11-26 06:53:31',
'updated' => null
)
)
,
.
.
.
.(int) 50 => ...
I have added this in the subscribers controller
public $paginate = array(
'limit' => 10
);
What else do I need to add?
I have seen this but of no help
CakePHP pass custom query from controller into model paginate()
EDIT: Adding controller code below
$data = $this->Subscriber->getAllSubscribers();//This model method returns custom data from query
$this->paginate = array('fields' => $selectedField);
$paginatedData = $this->paginate($data);
//debug($paginatedData);
$this->set('subslist', $paginatedData);
The above code is not working, what am i doing wrong, thanks