Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query returns different results from php script and command line

Status
Not open for further replies.

pgosse

Programmer
Sep 26, 2001
42
0
0
CA
Hi folks. I'm having a very, very strange problem here.

I've got a query which is generated and executed in a php script. It scans a table of "areas" in a cms, a hierarchical folder structure stored in a table, and returns a list of users with access to any content which exists in the tree under the specified folder.

The results it is returning when executed in the php script are correct. However, when I turn on ADOdb's debugging in the application to get the query and run it from the command line the results are different.

For example, the following query which is output as the query executed by ADOdb's debugging returns two results from the php script and one from the command line:
Code:
select x.u_id, g.g_id, g.name as group_name, u.username, x.status
from cms_access x, cms_groups g, cms_users u, cms_group_membership gm
where x.a_id in (select a.a_id from cms_areas a
				 where (1 = 195 and (a.a_id = 1 or a.path like '1, %'))
				 or (1 != 195 and (a.path like '%, 195, %' or a.path like '%, 195')))
and gm.g_id = g.g_id
and gm.u_id = u.u_id
and x.g_id = g.g_id
and x.u_id = u.u_id
group by x.u_id, x.g_id, g.g_id, group_name, u.username, x.status
order by group_name, username
And the following query returns two results from the php script and none from the command line:
Code:
select x.u_id, g.g_id, g.name as group_name, u.username, x.status
from cms_access x, cms_groups g, cms_users u, cms_group_membership gm
where x.a_id in (select a.a_id from cms_areas a
				 where (1 = 195 and (a.a_id = 1 or a.path like '1, %'))
				 or (1 != 195 and (a.path like '%, 195, %' or a.path like '%, 195')))
and gm.g_id = g.g_id
and gm.u_id = u.u_id
and x.g_id = g.g_id
and x.u_id = u.u_id
group by x.u_id, x.g_id, g.g_id, group_name, u.username, x.status
order by group_name, username
Does anyone have any idea why I might be getting these different results? It makes absolutely no sense to me that the results would be different when executed within the php script or from the command line, since the query is exactly the same.

I'm getting the correct, desired results from within the php scripts which is the most important thing, but this will bug me until I figure it out so if anyone has any insight it is greatly appreciated.

Cheers and TIA.

Pablo
 
The thing that comes immediately to mind is database permissions, if the php script is connecting as a different user than you're using for executing the command line queries.
 
Hi there. Thanks for the reply.

The problem was actually a bug in ADOdb's code. When it output the query when debugging was turned on, it inserted spaces after the commas thus buggering up the query.

Cheers,
Pablo

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top