Created
April 2, 2015 10:30
-
-
Save Fohlen/ecb8eb625df582cbaa08 to your computer and use it in GitHub Desktop.
Global database object with configuration in F3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Load configuration | |
$f3->config('config.ini'); | |
// Prepare the database | |
$dbConfig = $f3->get('database'); | |
if (!isset($dbConfig['port'])) | |
$dbConfig['port'] = 3306; | |
$f3->set('DB', new DB\SQL( | |
'mysql:host='.$dbConfig['host'].';port='.$dbConfig['port'].';dbname='.$dbConfig['database'], | |
$dbConfig['user'], | |
$dbConfig['password'] | |
)); | |
/* | |
Corresponding config.ini | |
[database] | |
host=localhost | |
database=cubelounge | |
user=cubelounge | |
password= | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment