diff --git a/mysqly.php b/mysqly.php index f3459da..1198e43 100644 --- a/mysqly.php +++ b/mysqly.php @@ -73,7 +73,7 @@ public static function exec($sql, $bind = []) { if ( !self::$auth ) { self::$auth = @include self::$auth_file; } - self::$db = new PDO('mysql:host=' . (self::$auth['host'] ?: 'localhost') . ';dbname=' . self::$auth['db'], self::$auth['user'], self::$auth['pwd']); + self::$db = new PDO('mysql:host=' . (isset(self::$auth['host']) ?: '127.0.0.1') . ';port=' . (isset(self::$auth['port']) ?: '3306') . (self::$auth['db'] ? ';dbname=' . self::$auth['db'] : ''), self::$auth['user'], self::$auth['pwd']); self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }