tags:

views:

150

answers:

2

I have this sql query:

SELECT DISTINCT r.uri uri
FROM resource r
INNER JOIN object o ON o.idResource = r.idResource
WHERE r.type = 2
AND r.idResource IN (
  SELECT DISTINCT r1.idResource
  FROM object o1
  INNER JOIN resource r1 ON r1.idResource = o1.idResource
  INNER JOIN class c1 ON c1.idClass = o1.idClass
  INNER JOIN property p2 ON p2.idResource = c1.idResource
  INNER JOIN object_value ov2 ON ov2.idProperty = p2.idProperty
                             AND ov2.idObject = o1.idObject
  WHERE c1.idResource = 364
  AND (p2.idProperty = 4 AND ov2.value LIKE '%dave%')
)

which works ok in phpmyadmin (mysql) but not in php code it gives timeout.

$result = mysql_query('$gquery') or die(mysql_error());

Any idea why?

+5  A: 

You shouldn't have $gquery in quotes. You should use

$result = mysql_query($gquery) or die(mysql_error());
Rob
Yep, you're trying to execute '$gquery' as a String, but not the value of the variable.
Fiarr
I tried both ways but still the same problem
Javier
Does your php file only have this line? Or is there more code that could be causing the problem?
Rob
Is in that exact line that it stops until it gives timeout (i have some echo for debug)There is more code but I guess the problem has to do with the query, because when I change it, everything works fine.
Javier
It may be due to the nested query..
Javier
Are you by any chance echoing the value of $gquery as it is passed to mysql_query?
Bruce Alderman
A: 

SOLVED: timeout issue. It was necessary to extend the timeout period. Sorry

Javier