21293 Posts in 5733 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » How to: _config uses right db connection locally and on prd
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 805 Views |
-
How to: _config uses right db connection locally and on prd

27 June 2009 at 5:40am
Hello,
how can i make my _config always choose the right db connection?
To often i copy something from local to production without changing the db settings and then my site it down.
How can i solve this easily in the _config?
// Local
global $databaseConfig;
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "localhost",
"username" => "xxx",
"password" => "xxx",
"database" => "xxx",
);// Production
global $databaseConfig;
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "localhost",
"username" => "xxx",
"password" => "xxx",
"database" => "xxx",
); -
Re: How to: _config uses right db connection locally and on prd

27 June 2009 at 6:30am
if server is localhost, 127.0.0.1 {
use local db settingselse id server is domainname, ip {
use production db settingsHow do i convert that so a language Silverstripe understands?
-
Re: How to: _config uses right db connection locally and on prd

27 June 2009 at 6:23pm
Hey yea there are a few ways to do this, have a look at this http://ssbits.com/using-import-in-your-config-php-for-live-site-database-details/
-
Re: How to: _config uses right db connection locally and on prd

27 June 2009 at 11:13pm
Prefect just what i was looking for!!!
-
Re: How to: _config uses right db connection locally and on prd

29 June 2009 at 6:03am Last edited: 29 June 2009 6:06am
I take back my precious reply...
I doesn't work "anymore"
I get the following message...
[Warning] mysql_connect() [function.mysql-connect]: Access denied for user 'Liveusername'@'localhost' (using password: YES)
GET /4-Productie/xxx.nl/Line 35 in C:\wampserver\www\4-Productie\xxx.nl\sapphire\core\model\MySQLDatabase.php
_config.php
<?php
....
@include '_liveConfig.php';?>
_liveConfig.php
<?php
// Production
global $databaseConfig;
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "localhost",
"username" => "livename",
"password" => "livepassword",
"database" => "livedbname",
);Director::isLive('http://www.xxx.nl');
if(Director::isLive()) Debug::send_errors_to("richard.duinmayer@gmail.com");?>
Does anyone know another way to solve this?
-
Re: How to: _config uses right db connection locally and on prd

29 June 2009 at 5:59pm
Maybe try an environment file to store your settings - http://doc.silverstripe.com/doku.php?id=environment-management
| 805 Views | ||
|
Page:
1
|
Go to Top |


