tags:

views:

53

answers:

1

Often I just need to get a single value from MySQL that I know exists there. I use the following construct:

$result = end(mysql_fetch_array(mysql_query('SELECT FOUND_ROWS()', $db)));

Is there a proper single function in PHP that would do this?

+1  A: 

Yes, mysql_result will do this.

$result = mysql_result(mysql_query('SELECT FOUND_ROWS()', $db), 0);
Zackman
didn't notice the optional params of mysql_result. I guess that this is the limit - there is no function that combines mysql_query and mysql_result?
Ghostrider
If you make a lot of these calls you should create your own function that combines the two. As far as I know, no such function exists natively.
Zackman