PDA

View Full Version : Pulling only "visible" threads from the database


Analogpoint
02-09-2007, 04:00 PM
I'm pulling the latest threads from the database to link to them from another page. I just want to be sure to only pull "visible" ie not moderated and deleted threads. Is the 'visible' field the right one to use or is there something I should do with the 'hiddencount' and 'deletedcount' fields?

select `title` , `threadid` from `thread` where `visible`=1 order by `threadid` desc limit 5

Thanks! :D

Zachery
02-09-2007, 04:17 PM
Also be aware that if you're not checking user permissions these threads could be pulled from anywhere in your forums. But I believe that will do what you want.

Analogpoint
02-09-2007, 04:20 PM
Thanks Zach,

Right now I don't have any hidden/mod forums, but if/when I do, then I could simply check the forumid in the threads table and exclude my hidden forums right?

Other than that, and just for confirmation, the visible field is what gets set to 0 when a thread is in the moderation queue or is deleted?

Thanks a bunch,

Zachery
02-09-2007, 04:30 PM
0 Soft deleted 1 visable 2 moderated I believe

Analogpoint
02-09-2007, 04:32 PM
OK, Thanks a lot, I appreciate it. :)

Paul M
02-09-2007, 07:05 PM
You also need to check that the open field does not equal 10 - if it does then it's a redirect, not a real thread.

Analogpoint
02-12-2007, 03:12 AM
Thanks Paul for that! That eventuality hadn't even occurred to me. :)