![]() |
db query @ postbit_display_start
I'm trying to run db queries at the hook postbit_display_start, but for some reason it doesn't seem to work...
When I try this line: Code:
$foobar = $db->query_read("SELECT username FROM " . TABLE_PREFIX . "user WHERE userid = 1"); Ideas? EDIT: Nevermind, it seems it works when I use the "showthread_postbit_create" hook instead. Now I need to figure out why I get "Resource id #x" instead of the data I'm looking for... *sigh* |
Change your function to query_first then query_read.
|
In the postbit_* hooks you will most likely need to use the $this->registry->db variable or the $vbulletin->db variable as those hooks are executed within a class, if I remember correctly.
|
Quote:
Quote:
Anyways, I solved the resource id thingy with fetch_array. |
Well query_read only does like mysql_query but query_first does mysql_query and fetch_array both and returns the array. Plus you are only pulling out one row with that query.
|
Quote:
|
To get more then 1 row, you will need to do your query_read() followed by a fetch_array() in a loop.
|
Quote:
Quote:
|
Quote:
turns out the syntax I was after in the original hook was Code:
$stories = $this->registry->db->query_first |
Quote:
Code:
$foo = $this->registry->db->query_read('SQL STRING'); If you're not already doing that, you might want to ssh to the server (if you have that possibility) and tail the error log to receive real-time error reporting. In a command shell (cmd/terminal): Code:
ssh example.com -l root Code:
tail -f /var/log/httpd/error_log |
All times are GMT. The time now is 07:01 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|