PDA

View Full Version : SQL query help...


MacMorag
04-21-2004, 09:03 PM
Not sure if this is the right place, but you guys seem to know your stuff.

I've just upgraded to vB3. In forumdisplay I've created a new field (by adding another field to the threads table, which is then extracted from the database in forumdisplay.php, and displayed by changing the threadbit template). Everything works great.

However, when you do a search (which uses search.php instead of forumdisplay.php) the additional field is empty. Obviously, as I still need to do a similar extraction of the thread table field from within search.php. The problem is I can't find where to add the query which will extract this field.

In forumdisplay.php I simply added the new field name to the list of fields which are extracted in the query at around line 657. However, I can't find anywhere to do a similar query within search.php. I've tried adding the field name to the query at around line 1183, but nothing shows (I assume it's got something to do with the conditional which is part of the query).

The field in the threads table is called 'testfield'. How do I get it to display in the search results?

Do I simply need to do another seperate query? If so, where about in search.php should I put this query?

Thanks.

Xenon
04-22-2004, 12:43 PM
hmm, on vb.org i've added field to that query:
// query thread data
$dataQuery = "
SELECT $previewfield
thread.threadid, thread.threadid AS postid, thread.title AS threadtitle, thread.iconid AS threadiconid,
thread.replycount, IF(thread.views=0, thread.replycount+1, thread.views) as views, thread.sticky,
thread.pollid, thread.open, thread.lastpost AS postdateline,
thread.lastpost, thread.lastposter, thread.attach, thread.postusername, thread.forumid, thread.iconid AS threadiconid,
user.userid AS postuserid,

around line 1570 and as you can see on our search pages the vb-version and such are showing up :)

MacMorag
04-22-2004, 01:03 PM
Thanks Stefan. :)

Xenon
04-22-2004, 03:21 PM
:)

you're welcome :)