PDA

View Full Version : How to fetch forumid and put it into query


lazyseller
02-23-2009, 02:09 AM
How would i go about fetching the forumid the plugin is activated in and pass that variable into my query? Is this possible?

$listings = $vbulletin->db->query_read("SELECT title, threadid
FROM " . TABLE_PREFIX . "thread
WHERE forumid = 'variablehere'
ORDER BY rand() DESC
LIMIT 5
");

--------------- Added 1235378133 at 1235378133 ---------------

Got it working but just wanted to see if theres a better way to do this.

Is there a better way to do this?

$forumidtest = $foruminfo['forumid'];

$listings = $vbulletin->db->query_read("SELECT title, threadid
FROM " . TABLE_PREFIX . "thread
WHERE forumid = '$forumidtest'
ORDER BY rand() DESC
LIMIT 5
");

Dismounted
02-24-2009, 04:49 AM
ORDER BY RAND() is very slow. Have a read: http://akinas.com/pages/en/blog/mysql_random_row/