Author Topic: How to retrieve query count number from filtering result  (Read 1507 times)

mewbie

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 33
    • View Profile
How to retrieve query count number from filtering result
« on: January 11, 2018, 10:22:07 am »
I need to retrieve the number of records returned with its total page for filtering result based on your example.
I can retrieve it with something like this:

Quote
$query ="SELECT count(*) FROM table where column='query'";

but not with:

Quote
$query ="SELECT count(*) FROM table ".$filterQuery;

When I peeked inside, indeed, $filterQuery is equal to where column= ?

Do you have a workaround?
Thanks


mewbie

  • Pro Deluxe
  • Newbie
  • *
  • Posts: 33
    • View Profile
Re: How to retrieve query count number from filtering result
« Reply #1 on: January 11, 2018, 01:15:03 pm »
I've got it, I should prepare it first before execute,

Quote
       
$stmt= $dbh->prepare($query);
$stmt->execute($filterParam);

But I still like to know the most effective way mixing filter, paging, sorting in php, I still DRY myself in my code.
Do you have that example?

Thanks