|
- <?php
- if (empty($_SERVER['APPLICATION_ENV']) || $_SERVER['APPLICATION_ENV'] == 'production') {
- defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'production');
- } else {
- defined('APPLICATION_ENV') || define('APPLICATION_ENV', 'dev');
- }
- $getDbConfig = require dirname(dirname(__DIR__)) . '/config/dbConfig/db.' . APPLICATION_ENV . '.config.php';
- $config = $getDbConfig['CST'];
- define("MYSQL_HOST", $config['host']);
- define("MYSQL_USER", $config['user']);
- define("MYSQL_PASSWORD", $config['pwd']);
- define("MYSQL_DB", $config['db']);
- define("MYSQL_PORT", $config['port']);
- function conn()
- {
- $port = defined('MYSQL_PORT') ? MYSQL_PORT : 3306;
- try {
- $pdo = new PDO("mysql:host=" . MYSQL_HOST . ";port=" . $port . ";dbname=" . MYSQL_DB, MYSQL_USER, MYSQL_PASSWORD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "set names utf8"));
- return $pdo;
- } catch (PDOException $e) {
- write_log('ctsdata_test new PDO failed:' . $e->getMessage());
- }
- }
-
- ?>
|