Jump to content

trying to cut down this code a bit and it's locking up my server


spdwrench

Recommended Posts

ok I have a bit of code that pulls members thumbnails from the database.

 

but the original code had alot more information being pulled ... All I need is the filename_1 pulled with the gender and the id

 

$search_query = "SELECT p.id, p.gender, p.name, p.general_info, m.age, f.filename_1 FROM (dt_profile p, dt_photos f, dt_members m, dt_privacy pr) WHERE (p.status='1' AND (pr.featured_yn IS NULL OR pr.featured_yn='') AND pr.member_id=m.id AND p.member_id=m.id AND f.member_id=m.id AND f.filename_1<>'' AND p.gender='$genders[name]') ";

//$search_query = "SELECT p.id, p.gender, f.filename_1 FROM (dt_profile p, dt_photos f) WHERE (p.status='1' AND f.filename_1<>'' AND p.gender='$genders[name]') ";

 

 

the second part that is commented out is what I tried to do to cut back the strain on the server but when I run the line that is commented out it seems to be stuck and I get no results.

 

is there a problem with the syntax in the second part that I have commented out in this code?

 

thanks for any help

 

Paul

Link to comment
Share on other sites

have you tried to run that second query inside the database itself to see if it returns any rows?

 

paste that sql statement in your query browser and let it run....it might be returning a bunch of records...which could be what appears to be "hanging"

 

 

Link to comment
Share on other sites

Just thought I'd chip in with another idea to explore - wondered whether the "p.member_id=m.id AND f.member_id=m.id" condition had anything to do with it. It seems to be the link between the two tables, although that would also mean having to include the members table in your query.

 

What I imagine would be happening is the database is attempting to return all combinations of <profile, photo> pairs without restricting the set to only those that make sense (i.e. represent member data). Try the following query:

 

$search_query = "SELECT p.id, p.gender, f.filename_1 FROM (dt_profile p, dt_photos f, dt_members m) WHERE (p.status='1' AND p.member_id=m.id AND f.member_id=m.id AND f.filename_1<>'' AND p.gender='$genders[name]') ";

 

Cheers,

Darren.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.