Re: Re: Multiple queries in PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2009-01-25 at 15:07 -0600, Shawn McKenzie wrote:
> Ashley Sheridan wrote:
> > Hi all,
> > 
> > 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.
> > 
> > Now the full query looks something like this:
> > 
> > 
> > mysql_query("SELECT @m:=0;");
> > 
> > $query = "SELECT * FROM(
> > 		SELECT profiles.id, ROUND(AVG(rated.score)) AS `rating`,
> > COUNT(rated.score) AS `total`, @m:=@m+1 AS rank FROM `rated` LEFT JOIN
> > `profiles` ON (profiles.id = rated.profile_id) GROUP BY rated.profile_id
> > ORDER BY rating DESC, total DESC) AS ranking WHERE ranking.id=$id";
> > $result = mysql_query($query);
> > 
> > 
> > which seems to be working OK so far, but does anyone know of any
> > potential pitfalls I might face when doing something like this?
> > 
> > Thanks,
> > 
> > 
> > Ash
> > www.ashleysheridan.co.uk
> > 
> 
> Might try the mysqli extension.  mysqli_multi_query()
> 
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com
> 
Unfortunately, I think the server this is going on to doesn't have that
extension :(


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux