简体   繁体   中英

Joomla 2.5 Database Connection

I am working on a Joomla website and we are running jomsocial, my question is about the database connection using JFactory. Currently I need information from a database table that is not part of jomsocial so I have to get in the database from a specific page, and I'm doing it wrong. Only because I can't figure out how to make the right way work, so I'm asking here for help. Currently I am just using regular php and mysql_connect.. my DB connection looks like...

$db_host = 'localhost';
$db_user = 'xxxxxxxx';
$db_pass = 'xxxxxxxx';
$db_database = 'xxxxxxxx';
$link = mysql_connect($db_host,$db_user,$db_pass) or die('Not connected');
mysql_select_db($db_database,$link);
$user = CFactory::getUser($userid);
$user_plan = mysql_query("SELECT blah FROM blah WHERE blah = '".$user->id."'");
$user_plan_row = mysql_fetch_array($user_plan);

And this works, even though its wrong. What I want to do is use

JFactory::getDbo();

I have found this page which describes the syntax well I think, but I can not implement any of the methods described without breaking the page...

Any Ideas or help is greatly appreciated, as it stands right now I have all my secure information in the file and I don't want that I want to use the correct method, because when it comes time to move the site I'm going to have to go change each one of these manually instead of just changing the config file like usual.

您链接到的资源对我来说似乎不错,您将需要发布一些特定的错误。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM