PDA

View Full Version : Some queries and plugin help


rockinaway
09-25-2009, 06:26 PM
I am making a plugin and just wondered, what should I use to call data from the database? i.e. what should replace mysql_query() and mysql_result()

Thanks

Lynne
09-25-2009, 06:58 PM
This page from the manual should help - SQL Query Syntax (http://www.vbulletin.com/docs/html/codestandards_sql_query)

rockinaway
09-25-2009, 07:02 PM
Okay a few questions. I have been using similar things but I get this error:


Fatal error: Call to a member function on a non-object in /home/.endora/othersites/etcworld.co.uk/test/includes/class_postbit.php(265) : eval()'d code on line 5

Then what is the difference between query_read and query_first?

And how can I do mysql_result?

Lynne
09-25-2009, 07:23 PM
query_first means you don't have to do a fetch_array after doing the query - it is for when you only expect one row from your query.

Take a look at the vbulletin code in your files. There are lots and lots of examples in there.

Your error is most likely from a plugin. Look at line 265 in class_postbit. My guess is it is a hook and thus you have an error in a plugin that uses that hook location.

Adrian Schneider
09-25-2009, 07:29 PM
Inside vBulletin classes, you must access the vBulletin registry object (which contains the database object) via $this->registry because $vbulletin and $db are not in scope. Your code would be something like this, $result = $this->registry->db->query_read("Your Query");

rockinaway
09-25-2009, 07:36 PM
Perfect :)

And, I seem to be using $vbulletin ..... instead of $this :)