View Full Version : problem using db class in a hook
sp00fer
11-23-2006, 08:55 PM
i have this in the postbit_display_complete hook:
$result=$vbulletin->db->query_read("Select * from user")
and i get this error:
Call to a member function on a non-object in /home/genesisk/public_html/forums/includes/class_postbit.php(279) : eval()'d code on line 1
any help?
Guest190829
11-23-2006, 09:00 PM
i have this in the postbit_display_complete hook:
$result=$vbulletin->db->query_read("Select * from user")
and i get this error:
any help?
Since it is in the class you will probably have to do it this way:
$this->registry->db
instead of
$vbulletin->db
sp00fer
11-24-2006, 02:43 PM
thanks, that worked.....could u explain why though?
Guest190829
11-24-2006, 02:50 PM
thanks, that worked.....could u explain why though?
This deals with the foundations of Object Oriented Programming.
Since postbit_display_complete exists in a class, the $vbulletin object must be aggregated to that class.
vBulletin programming standards aggregates the vBulletin object to $registry.
$this->registry &= $vbulletin;
All class attributes can be accessed within the class with $this (Outside the class $this will be changed to the actual object name: ie: $vbulletin)
So you access the $vbulletin object inside the class as:
$this->registry
.
More information:
http://us2.php.net/oop
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.