0

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 Answer 1

2

Yes, mysql_result will do this.

$result = mysql_result(mysql_query('SELECT FOUND_ROWS()', $db), 0);
Sign up to request clarification or add additional context in comments.

2 Comments

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?
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.