Re: Multiple queries in PHP
| From: | Chris | Date: | Tue, 27 Jan 2009 01:44:57 +0000 |
| Subject: | Re: Multiple queries in PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-287197@lists.php.net to get a copy of this message | ||
Per Jessen wrote:
Ashley Sheridan wrote:Same for mysql_query: "mysql_query() sends a unique query (multiple queries are not supported)"... -- Postgresql & php tutorials http://www.designmagick.com/I've run into a bit of a problem. I put together a query using mysql variables in the form set @m:= 0; with the select that uses it directly after. For any wondering, the select was using it as an incremental value which can't be hard coded, as the value will depend on the ordering of the results of the query itself. The problem seems to be that while phpMyAdmin would execute this double query perfectly well, php using mysql_query() was having problems, as apparently it can't actually run multiple queries.I don't know about the PHP mysql_query(), but the MySQL C API works fine with multiple queries, it just has to be specifically enabled - the default is one query per call. However, it looks like the multiple query option is not supported by PHP: http://php.net/manual/en/mysqli.real-connect.php "For security reasons the MULTI_STATEMENT flag is not supported in PHP. If you want to execute multiple queries use the mysqli_multi_query() function."