title: MySQL: Get only count of result set
body: <p>I am using MVC with PHP/MySQL.  </p>
  
  <p>Suppose I am using 10 functions with different queries for fetching details from the database.<br>
  But at other times I may want to get only the count of the result that will be returned by the query.<br>
  What is the standard way to handle such situation.<br>
  Should I write 10 more functions which duplicate almost whole query and return only the count.<br>
  Or<br>
  Should I always return the count also with the result set<br>
  Or<br>
  I can pass a flag to indicate that the function should return count only, and then based on the flag I will dynamically generate the (select part of) query.<br>
  Or<br>
  Is there a better way?   </p>