Page 2 of 2

Re: [MySQL] Query syntax error?

Posted: Sun Feb 10, 2008 1:13 pm
by nutkenz
astions wrote:The logic of your query is way off and it's missing aliases. Post your table structure and what your trying to accomplish.
The structure is irrelevant because it's for a pagination class which should work on every single database.

I solved it like this:

Code: Select all

if (empty($group))
{
    $dbRCount = $db->get_var("SELECT COUNT(*) AS total $from $where");
}
else // Multiple rows will be returned
{
    $dbRCount = count($db->get_col("SELECT COUNT(*) AS total $from $where $group"));
}
Not the most efficient way probably, but the speed is OK.