Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
Jamroom Developers:
how does jamroom know what database name to use?

Joined: 20 Jun 2009
Posts: 344
Location: Portland Oregon

Posted: 09/24/11 23:14 
I am working on V2 of an existing module. In order to preserve the data for anyone installing V2 over V1, I need to check mysql's information_schema for existing tables. In order to do that I need to be able to know the name of the database that jamroom is using. I tried to iterate through the $config array as well as the $GLOBALS array and I was unable to find how jamroom knows which database to use.
Of course I know which database table my copy of jamroom are using but I need to know how jamroom knows. Any advice?

Tim McCune

Back to top

Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 09/25/11 13:47 
Jamroom does everything automatically in the dbQuery function - if you don't want it to use the jamroom tables you'll want to use the regular mysql functions.



Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Jamroom Team

Joined: 22 Apr 2008
Posts: 3423
Location: Tokyo

Posted: 09/26/11 16:57 
its $jamroom_db that you want.

When you setup your module, usually in the includes.php file you will add to the $jamroom_db array with your modules database names.

with a line something like this.

// set up our custom database tables
$jamroom_db['apLaunch_nukes'] = $config['db_prefix'].'apLaunch_nukes'; //holds the secret firing codes.

Then you will get something like this in $jamroom_db jamroom_apLaunch_nukes

to use it
$sql = "SELECT * FROM {$jamroom_db['apLaunch_nukes']} WHERE target = $target";

Is that useful?

Michael Ussher
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top

Joined: 20 Jun 2009
Posts: 344
Location: Portland Oregon

Posted: 09/27/11 13:24 
Thanks for the response. Essentially my plan was to query the the information_schema table for the existence of my modules tables, by doing the following query within the schema.php file:


FROM information_schema.tables
WHERE table_schema = '[jamroom database]'
AND table_name = 'mcAds';

And if the table exists, I need to test to see if a specific column(s) exists (Which is used in the modules V1.x but not V2.x) And if the column(s) exist I will rename the table with a temp name. Then let the schema.php script to perform the regular table verification by running the dbVerifyTable().

Then after all the new table schemas are in place, I plan to check the database for the existence of the renamed tables, and if they exist, migrate the appropriate data over to the new tables. Then delete temporary tables. As far as I understand, the $jamroom_db[] array contains the names of the database table names but not the actual name of the database, but I haven't checked yet.

After a little digging, I found where the database connection is created and placed into the $GLOBBALS array but I never found where the actual database name was found. I could just assume that the database name is jamroom but that would only be the case for people who use the default settings during installation.

Tim McCune

Back to top

Joined: 20 Jun 2009
Posts: 344
Location: Portland Oregon

Posted: 09/27/11 14:49 
Found what I was looking for. After examining jamroom-database.inc.php I found that the connection is made using: $GLOBALS['JR_HTPASSWD'][1] to hold the name of the database name.

Thanks for the help,

Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
Jamroom Developers

• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
• Support Forum
• Documentation
• Support Center
• Contact Support
• Community Forum
• Member Sites
• Developers
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.