Get Different Datasource in Different Enviroment?
Development
Datasource
artDev
Stage
Datasource
artStg
Production
Datasource
art
In ColdBox.cfc
coldbox = {
…
datasources = {
myDSN = { name=“artDev”, dbType=“oracle”}
}
…
environments = {
development = ^127.0.0.1",
stage = “^stage.”,
production = “^www.art,^art.”
}
…
}
function development() {
…
}
function stage() {
… what do I put here to change the datasource name? …
…
}
function production() {
…
}
bdw429s
2
Just modify the datasources struct like normal CFML. It lives in the variables scope of the CFC. Any struct operations are valid on it.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Maybe i’m mis-understanding the question but would you just put the datasource = {} under each environment listed in Coldbox.cfc ?
I may have figured out the answer on my own after posting is the below correct?
function stage() {
…
settings.datasources.mydsn= {name=‘artStg’, dbtype=‘oracle’};
…
}
yes, that is what i was thinking … except without settings. as i don’t believe that works.
datasources.mydsn = { name… … }
Your correct after more testing without the settings worked.