forked from ushahidi/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathohanzee-db.php
More file actions
59 lines (55 loc) · 1.6 KB
/
ohanzee-db.php
File metadata and controls
59 lines (55 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Database Config
*
* @author Ushahidi Team <team@ushahidi.com>
* @copyright 2013 Ushahidi
* @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License Version 3 (AGPL3)
*/
// Parse ClearDB URLs
if (getenv('CLEARDB_DATABASE_URL')) {
$url = parse_url(getenv('CLEARDB_DATABASE_URL'));
// Push url parts into env
putenv('DB_HOST='.$url['host']);
putenv('DB_USERNAME='.$url['user']);
putenv('DB_PASSWORD='.$url['pass']);
putenv('DB_DATABASE='.substr($url['path'], 1));
}
// DB config
$config = [
'type' => 'MySQLi',
'connection' => [
'hostname' => getenv('DB_HOST'),
'database' => getenv('DB_DATABASE'),
'username' => getenv('DB_USERNAME'),
'password' => getenv('DB_PASSWORD'),
'port' => getenv('DB_PORT'),
'persistent' => false,
],
'table_prefix' => '',
'charset' => 'utf8',
'caching' => true,
'profiling' => true,
];
// If multisite is enabled
if (! empty(getenv('MULTISITE_DOMAIN'))) {
// Use this config for the multisite db
return [
// Just define basics for default connection
'default' => [
'type' => 'MySQLi',
'connection' => ['persistent' => false],
'table_prefix' => '',
'charset' => 'utf8',
'caching' => true,
'profiling' => true,
],
'multisite' => $config,
];
} else {
// Otherwise this is the platform DB config
return [
'default' => $config,
'multisite' => $config,
];
}