Re: Multiple queries in PHP

From: Date: Mon, 26 Jan 2009 11:38:33 +0000
Subject: Re: Multiple queries in PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-287138@lists.php.net to get a copy of this message
Ashley Sheridan wrote: > 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." /Per Jessen, Zürich

« previous php.general (#287138) next »