We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Temporarily change DB

Development and Programming

sabremarketing's avatar
sabremarketing
27 posts
16 years ago
sabremarketing's avatar sabremarketing

I’m trying to save some data to a separate DB than EE uses. I’m not sure how to do this, and I bet there’s probably an easy way I can change the $DB parameters.

So basically what i want to do is this:

global $DB; {!– change DB values to another DB –}

$my_query = $DB->query(“INSERT INTO table in another database…”);

{!– restore DB values from before –}

$my_query = $DB->query(“SELECT from EE database…”);

Moved to Plugins: Technical Assistance

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

This is more of a general PHP programming question than a technical support question.

I’ve always found it easier to keep all the tables I need in the same database so I can just use global $DB.

How are you going to use this code?

       
sabremarketing's avatar
sabremarketing
27 posts
16 years ago
sabremarketing's avatar sabremarketing

I have several EE installs that need to save to a single DB for some form results so they are all in the same place. They each use a different DB, so it would be a pain to have to compile the form submissions across 10 databases. So I want them all saved together. I have my PHP broken out into a plugin just to keep my templates a little cleaner.

       
sabremarketing's avatar
sabremarketing
27 posts
16 years ago
sabremarketing's avatar sabremarketing

It’s a general PHP question, but its also working with the EE framework, so that’s why I came here.

       
sabremarketing's avatar
sabremarketing
27 posts
16 years ago
sabremarketing's avatar sabremarketing

I figured it out. I just changed the database and changed it back afterwards. I was over-complicating things.

Thanks

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Glad to hear it. /Don’t hesitate to post again if needed.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.