Skip to content

Instantly share code, notes, and snippets.

@mmoscosa
Last active October 11, 2015 19:08
Show Gist options
  • Save mmoscosa/3905752 to your computer and use it in GitHub Desktop.
Save mmoscosa/3905752 to your computer and use it in GitHub Desktop.
Select Database depending on environment, CakePHP
<?php
/**
* Automatically configure database connection.
*/
public function __construct() {
$environment = Configure::read('environment');
$operatingSystem = (DS === '/') ? 'Linux' : 'Windows';
if ($environment === 'development') {
$this->default = $this->development;
} else {
$this->default = $this->production;
}
}
/**
* Default database.
*/
public $default = null;
/**
* Development database.
*/
public $development = array(
'driver' => 'Database/Mysql',
'host' => 'host',
'login' => 'login',
'password' => 'pass',
'database' => 'db',
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment