• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Php Connect to DB

I'm trying to create a script to look at user on my team speak and game servers and assign points through the credits addon for use of clans servers. (this scraping of the servers I have done already)

I want to create a direct connection to the database from the script what commands does Xenforo use to connect to the database

I was going to use
mysql_connect("", "UserName", "Password ") or die(mysql_error());
mysql_select_db("Database") or die(mysql_error());
But the functions I see in credits code uses

$db = $this->_getDb();
How would I align my database connect so I can talk to the database this way

Thanks in advance for any help (I have 10 days off work and would like to get this done)
Here is the code I'm using to get some user id info and connect to the database


define('XF_ROOT', $_SERVER['DOCUMENT_ROOT'] . ''); // set this!
define('TIMENOW', time());
define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed
require_once(XF_ROOT . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');
XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);
XenForo_Application::set('page_start_time', TIMENOW);
error_reporting(E_ALL & ~E_NOTICE); // Turn off the strict error reporting.
$dependencies = new XenForo_Dependencies_Public();

//Get the default options from XenForo.
$options = XenForo_Application::get('options');

$userid="4"; // set this to what ever as an example im setting it as 4
$userinfo = XenForo_Model::create('XenForo_Model_User')->
                    getUserById($userid,array('join' => XenForo_Model_User::FETCH_USER_FULL ));                              


$db = XenForo_Application::getDb(); // this load the database up will write and read date here soon
I will be writing data soon to the database