Hello all,
I think the code below which is within a plugin crashed my server! I was wondering if it was due to the use of $vbulletin->db and $db in the same function?
For example:
Code:
$search_sql = "SELECT threadid, title, lastpost, forumid,
replycount, dateline, postuserid, visible, open
FROM " . TABLE_PREFIX . "thread AS thread
WHERE NOT ISNULL(threadid) AND visible = '1' AND replycount > '0' AND open!='10' AND forumid IN (".$forums_to_search.") $mp_stats_timecut_activethreads
ORDER BY replycount DESC
LIMIT 0, $num_of_threads_to_display";
$active_threads_result = $vbulletin->db->query_read($search_sql);
$threadcount = $db->num_rows($active_threads_result);
# now get the results and add to an array
while ($thread_result = $db->fetch_array($active_threads_result)){
......
{
mp_stats_timecut_activethreads ends up being 1 day back in time stamp - again the code worked well and returned the correct results. The forum is also new so in total we are looking at 200 posts and 10 new ones in 10 days.
I copied the sql and code bits from a
well known plugin mentioned in this forum and it worked well when I was the only one calling the plugin however when I added the plugin to the forum home template and accessible to the public my server used all its memory and swap and had to be rebooted. There are two code blocks in the plugin which execute SQL for stats (the other is along the same lines).
I am unsure of why there are two access points used for the db calls ($vbulletin->db, $db) and I wonder if this is actually quite bad?
For example wouldn't you go:
Quote:
while ($thread_result = $vbulletin->db->fetch_array($active_threads_result)){
|
instead of:
Quote:
while ($thread_result = $db->fetch_array($active_threads_result)){
|
As I assume $vbulletin-> is actually controlling the access to the db for this instance of my code running? And I wouldn't be supprised that this in a site with say a few hundred visitors would cause issues with db sql execution etc...
Cheers
Marc