src/db/BuildSql.php
public function open($config)
    {
        $config['user'] = isset($config['user']) ? $config['user'] : '';
        $config['pwd']  = isset($config['pwd']) ? $config['pwd'] : '';

        try {
            $do = new PDO($this->parseDNS($config), $config['user'], $config['pwd']);
        } catch (\PDOException $e) {
            $msg = $e->getMessage() . ' <br/>SQL Config:<br/>' . PHP_EOL;
            foreach ($config as $key => $value) {
                $msg .= $key . ' : <font style="color:red">' . $value . '</font><br/>' . PHP_EOL;
            }
            throw new Exception($msg);
        }

        $do->exec('set names ' . $config['charset']);
        $do->exec('SET sql_mode =\'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'');

        return $do;

    }
public function open($config)
    {
        $config['user'] = isset($config['user']) ? $config['user'] : '';
        $config['pwd']  = isset($config['pwd']) ? $config['pwd'] : '';

        try {
            $do = new PDO($this->parseDNS($config), $config['user'], $config['pwd']);
        } catch (\PDOException $e) {
            $msg = $e->getMessage() . ' <br/>SQL Config:<br/>' . PHP_EOL;
            foreach ($config as $key => $value) {
                $msg .= $key . ' : <font style="color:red">' . $value . '</font><br/>' . PHP_EOL;
            }
            throw new Exception($msg);
        }

        $do->exec('set names ' . $config['charset']);
        $do->exec('SET sql_mode =\'STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION\'');

        return $do;

    }
打开数据库链接