PDA

View Full Version : MySQL in a Plugin


sccrgy789
06-19-2008, 10:49 PM
I have a plugin with the following characteristics:
Hook: global_start
Code:
$userswith = $vbulletin->db->query_first("SELECT * FROM " . TABLE_PREFIX . "mtweaks WHERE name='userswithimage'");
Active: Yes

My vBulletin is version 3.6.9 and the plugin system is enabled. I also have Debug mode on.

The issue at hand is the DB query is not executing. I cannot figure out why... I've tried using various references to $db ($this->registry->db, $vbulletin->db, $db, etc.) and none have seemed to work. (Some made the page fail to load)

The query is valid and works in the custom ACP pages I made. Also, I've been looking at the SQL log in the debug section (the box at the bottom of pages) and it doesn't look like my query ever runs.

So, I don't know why my query isn't running and I'd really appreciate some help getting it to work!

Opserty
06-19-2008, 10:52 PM
Try the global_setup_complete hook location

sccrgy789
06-19-2008, 11:28 PM
Thanks so much for your reply, that seemed to do the trick!

Paul M
06-20-2008, 12:04 AM
What makes you think it wasnt running ?

FYI, sql executed in that hook is not displayed in debug mode, this is due to the output from that hook being stored in a buffer. (its a bug IMO, but Jelsoft dont seem to think so).