Log in

View Full Version : Need to Chose a Threadid at start of file.


Michael Morris
01-11-2005, 10:24 PM
I'm working on a hack and I trying to add a feature that will allow users to call up threads from a certain thread by their name. To do this I need to recall the threadid.

Now, the $featsname variable by this point in the code has been ran through the globalize function lest hackers get any ideas. Here's de code..

// Determine our thread id by feat name.

// Determine our thread id by feat name.
if (!empty($featname))
{
// We are searching by name rather than thread id. We'll check permissions later,
// for now just query up the first occurance of the featname.
$threadcache = query_first("
SELECT threadid
FROM " . TABLE_PREFIX . "feats
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON(thread.threadid = feats.threadid)
WHERE thread.title = '" . addslashes($featname) . "'
");

$threadid = $threadcache['threadid'];
}


But this doesn't fetch the thread. What do I need to do?

EDIT: Just to be clear, my feats table has threadid as a foreign key so that it can be joined to the thread table. I presume that joining the thread table to it will drop the rows that don't occur on both tables.

Michael Morris
01-11-2005, 10:38 PM
Nevermind, found my problem - needed to call the function fetch_threadinfo. For the curious, final code:

// Determine our thread id by feat name.
if (!empty($featname))
{
// We are searching by name rather than thread id. We'll check permissions later,
// for now just query up the first occurance of the featname.
$featthread = $DB_site->query_first("
SELECT feats.threadid AS threadid
FROM " . TABLE_PREFIX . "feats
LEFT JOIN " . TABLE_PREFIX . "thread AS thread ON(thread.threadid = feats.threadid)
WHERE thread.title = '" . addslashes($featname) . "'
");
$threadid = $featthread['threadid'];

// Fetch it
fetch_threadinfo(&$threadid);
}