Access DB name within UDT?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
donia
Forum Members
Forum Members
Posts: 11
Joined: Wed Feb 27, 2008 3:22 am

Access DB name within UDT?

Post by donia »

Is there a simple way to access the database name, username, and password from within a UDT? I have many UDTs that need access to the database, and right now I'm manually assigning the database name to a variable. $DBName = "mydbname";

The database name (and username and password) must be stored in a global somewhere, and I would like to just be able to access that.

Thank you!
tomgsd
Forum Members
Forum Members
Posts: 74
Joined: Tue Feb 12, 2008 10:00 am

Re: Access DB name within UDT?

Post by tomgsd »

You can access the config stuff like this:

Code: Select all

$config =& cmsms()->GetConfig();
However, if you're doing database operations you can just get a reference to the db object and run your query:

Code: Select all

$db =& cmsms()->GetDb();
$result = $db->Execute('SELECT * FROM tablename WHERE id = ?', array('1'));
Best place to find more info on how to do this is by looking at code in other modules, News would be a good place to start.
Post Reply

Return to “CMSMS Core”