AnsweredAssumed Answered

CWP:  Get number of results

Question asked by DanielMare on Apr 19, 2011
Latest reply on Apr 19, 2011 by DanielMare

Title

CWP:  Get number of results

Your post

I need to get number of records in order to create page links, i.e. Page 1, Page 2, Page 3 - i.e. if 10 records per page, and 30 records total, there needs to be 3 page links.

My current solution is:

$result = $request->execute();
$records = $result->getRecords();
$num_records = count($records);

Then to actually show content for current page:

$request->setRange(blabla);
$result = $request->execute(); // <-- again

etc, etc.

This works, but issue I have is it is very slow.  It seems quite inefficient to execute a result and get records for the simple purpose of counting them.

Is there a better way?     e.g. in mysql, I used: "SELECT COUNT(*) FROM table"

Outcomes