MySQL: Get only count of result set.
Posted
by Varun
on Stack Overflow
See other posts from Stack Overflow
or by Varun
Published on 2010-03-22T11:25:05Z
Indexed on
2010/03/22
11:41 UTC
Read the original article
Hit count: 257
mysql
|programming
I am using MVC with PHP/MySQL.
Suppose I am using 10 functions with different queries for fetching details from the database.
But at other times I may want to get only the count of the result that will be returned by the query.
What is the standard way to handle such situation.
Should I write 10 more functions which duplicate almost whole query and return only the count.
Or
Should I always return the count also with the result set
Or
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.
Or
Is there a better way?
© Stack Overflow or respective owner