Best way to figure out whether a query returns RESULT or NON-RESULT
| From: | Karam Chand | Date: | Sat, 16 Oct 2004 03:52:03 +0000 |
| Subject: | Best way to figure out whether a query returns RESULT or NON-RESULT | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-199625@lists.php.net to get a copy of this message | ||
Hello,
I have an app where one module is similar to
phpMyAdmin (well only .1%) with error_reporting() set
to E_ALL.
Now a user can execute any query. What is the best way
to know whether a query is result or non-result.
e.g.
>>>>>>>>>>>>>>>>>>>>>>
$result = mysql_query ( $query, $mysql );
if ( !$result ) {
HandleError ( mysql_errno(), mysql_error() );
return;
}
if ( !mysql_num_rows ( $result ) && !mysql_num_fields
( $result ) )
{
// handle non_result values
return;
}
// handle result values
>>>>>>>>>>>>>>>>>>>>>>>>
The problem is that if its an Update stmt. php throws
up an error that $result in mysql_num_rows() is not a
valid handle.
Moreover, from the manual - mysql_affected_rows() does
not work with SELECT statements; only on statements
which modify records. So to use it I have to figure
out if its a non-SELECT statement
What you PHP gurus suggest the best way to handle such
situations?
Thanks in advance
Regards,
Karam
_______________________________
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.
http://messenger.yahoo.com