The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Constant help needed. Learning how vBulletin works.
I looked at some tutorials, but I still don't understand it clearly. It looks like a regular query, but... I feel uncertain, still.
Example: I plan to create a chat hack for my forums (I plan to share), but I don't know how vBulletin works. I know very small details, but not enough. I still need to understand how to run queries to gather information from a user. When a user enters the page, php checks if the user is banned from the chat. In user, there's a table called chat_banned. With a value that would rather be a 1 or 0. (1 = True, 0 = False). And it also checks a group. In the same user table, there's a table called chat_group. Values would be one of the following: Admin, Mod, Member. I need to tell php to get that info from MySQL. I know how to do it in a regular website, but this is vBulletin I'm getting into, and I'm not sure how the coding works. I would really appreciate the help, and will be given credit in my planned hack. I found some ways around, but now I'm in another confusing spot. This is my code: PHP Code:
|
#2
|
|||
|
|||
Hi,
PHP Code:
When running a query, there are 2 parts. 1) query_read() - This runs the query and returns the result 2) fetch_array() - This converts the result into something PHP can understand So, for your query, you need to change the code to: PHP Code:
PHP Code:
For a query like yours, where there will only be 1 row returns, query_first() is ideal. So, your code using query_first() would look like: PHP Code:
Thanks, Alan. |
#3
|
||||
|
||||
shouldn't it be $db-> and not $vbulletin->db-> ?
|
#4
|
|||
|
|||
Both work fine, they both point to the same place. I prefer to use $vbulletin->db however because it gives a consistant feel to it all.
eg: PHP Code:
Thanks, Alan. |
#5
|
||||
|
||||
Well $bbuserinfo and $bboptions (isn't it vBoptions?) are not avaible in the php code, you need to use the class refrences (is that correct? or is it class varibles?, whatever) in order to get that data unless I'm guessing you copied the array to the $bbuserinfo varible.
$db-> works for 3.5/3.6. And I would think its easier while browsing and looking for queries its easier to pick out $db->query() compared to $vbulletin->db->query() |
#6
|
|||
|
|||
Hi,
(your right, it was $vboptiions - typo on my part ) You can use $vboptions in the code, it is defined here: Code:
includes\class_core.php(892): $vboptions =& $vbulletin->options; Code:
includes\class_core.php(894): $bbuserinfo =& $vbulletin->userinfo; Also, with regards to looking for queries, that's not a problem for me as all my queries are in the format PHP Code:
Incase anyones wondering I use _r for the sql resultset, and _a for the array eg: PHP Code:
Thanks, Alan. |
#7
|
|||
|
|||
To continue on the $db versus $vbulletin->db:
The object that is used is $vbulletin->db. To save on the keyboards of the developers $db is defined as a reference to the addresspace of $vbuylletin->db in the top-level scope. This means that you can exchange $db and $vbulletin->db if you want, they both point to the same object. If you however go into a function for example, then it will probably not have $db in it's scope. You will find also stock vB files where not $db is used but $vbulletin->db because $db is not in the scope. To avoid confusion and scope problems, i personally also always code the full qualification to the object, ie. $vbulletin->db. Like that is is maybe a bit more typing, but i can always use that, and it is more "correct" on an object oriented environment. You might find some guidelines over here: https://vborg.vbsupport.ru/showpost....72&postcount=5 (With thanks to DAnny for finding the post for me) |
#8
|
||||
|
||||
I always use $db in frontend files, but of course use the correct object when using classes. I do it for readability, and because it is faster to type.
$bbuserinfo and $vboptions are different because they aren't available (as said) in the PHP files, though running legacy_enable() will allow you to use them. Templates automatically convert them to their $vbulletin->X counterparts ($GLOBALS['vbulletin']->X I think). They say not to use $db in functions, because you will either have to global it as well ($vbulletin and $db) or create a reference to it. Anyway, not a big deal either way... personal preference by the looks of it. Edit: By the way, you don't need to exit; after using print_output(), because it will do it for you. |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|