php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #40377 mysql_query: error at "Return Values" section
Submitted: 2007-02-06 21:21 UTC Modified: 2007-03-23 17:51 UTC
From: burg1 at gmx dot net Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: burg1 at gmx dot net
New email:
PHP Version: OS:

 

 [2007-02-06 21:21 UTC] burg1 at gmx dot net
Description:
------------
Currently, the mysql_query() function returns a resource only on some commands (SELECT, SHOW, DESCRIBE or EXPLAIN). On any other command, it just returns TRUE.

My suggestion: Let the function return the actual MySQL output on those "other commands" (I'm talking about commands like ANALYZE TABLE that do generate an output). Could be given as an associative array, or if that's not possible, just as a string.

This way, mysql_query would return:
*) a resource on SELECT, SHOW, DESCRIBE or EXPLAIN
*) an array/string on commands that give an output (OPTIMIZE TABLE, etc.)
*) TRUE on commands that don't give an output (DELETE, etc.)
*) FALSE on error






Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-06 23:05 UTC] burg1 at gmx dot net
Sorry for the original post - I've just noticed that this feature is already implemented ;-)

So this feature request transforms into a documentation problem:

mysql_query() doesn't only return a resource for SELECT, SHOW, DESCRIBE or EXPLAIN commands (as stated in the docs), but also for other types of commands which return an output - at least for ANALYZE TABLE and OPTIMIZE TABLE (don't know if there exist other MySQL commands like this)

Code to check:
$result = mysql_query("ANALYZE TABLE tablename");
print_r (mysql_fetch_row($result));
 [2007-03-23 17:51 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, ..."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 07 14:01:37 2025 UTC