Log in

View Full Version : Tutorial for database access???


photongbic
08-22-2006, 11:35 AM
I am working on a map of my membership and events by county. I have added the needed custom fields to the calendar and the user profiles. Now all I need to do is populate the HTML from queries made to the vBulletin database.

Is there a tutorial somewhere on what is needed to query the database from PHP? Fieldnames, format, etc.? I need to access calendars (title, thread number, customfields) and membership list (username, user number, customfields).

Thanks!

Reven
08-22-2006, 02:22 PM
Have a look at this (https://vborg.vbsupport.ru/showthread.php?t=99570). Querying in vBulletin is different from querying in PHP - vBulletin wraps all queries within a database object so that it's possible in the future to allow multiple database types (though there are still reasons why they haven't implemented it now, mainly MySQL-only functions they've used I think).

The basic query for SELECT statements is:

$db->query_read ( SQL );

// And the way to lay out queries conforming to the way vBulletin does it is:

$db->query_read("
SELECT *
FROM " . TABLE_PREFIX . "random_table
WHERE id=$whatever_id
ORDER BY id ASC, age DESC
LIMIT 0, 10
");

// Each new command is on a new line and indented.

As I say though, have a look at the tutorials in there.

photongbic
08-28-2006, 03:32 AM
Thanks for the help! :)