简体   繁体   English

Joomla 2.5数据库连接

[英]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. 我正在Joomla网站上工作,我们正在运行jomsocial,我的问题是有关使用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. 目前,我需要数据库信息而不是jomsocial的一部分,因此我必须从特定页面进入数据库,而我做错了。 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... 目前,我只使用常规的php和mysql_connect。

$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. 非常感谢任何想法或帮助,因为它现在就存在于文件中,我已将所有安全信息保存在文件中,并且我不希望使用正确的方法,因为当需要移动网站时,必须手动更改其中的每一个,而不是像平常一样仅更改配置文件。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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