2010 ∞
CodeIgniter Database Prefix For Multiple Domain Projects
Let’s say you’re building an app. It’s like Flickr + Twitter + Facebook + Vimeo, but better. You’ve got several domains you’re working on, dev.greatestappevar.com, staging.greatestappevar.com, etc. You want to keep one codebase, b/c you’re smart. I mean, look at this mashup app you’re making. Proof. Or is it truth? Truth.
Anyways, you’re developing this in CodeIgniter and everything is in version control. Your database tables all have prefixes, so as not to mix your dummy data with the precious real social goldmine mashup data. You’re all Active Record up in this place, and everything works great, but once you push to Staging, you’re going to have database issues. Thankfully, there is a feature in CodeIgniter that allows you to add a prefix to database table names. Drop this little line into your database file in the config directory, and you’ll be all set. (Keep in mind not to overwrite these on your commits)
$db['default']['dbprefix'] = "staging_";
As easy as that great idea of yours.


