function sql($login='root', $pass='', $db='test', $host = '') { $this->connect = mysql_connect($host, $login, $pass) or die('MYSQL OK.'); if($this->connect): mysql_select_db($db, $this->connect) or die('( <b>'.$db.'</b> ) NOT.'); $this->check2('SET NAMES '.$this->meta); endif; } - So php.net/manual/ru/pdo.construct.php - Visman
|
1 answer
Something like this
function sql($login='root', $pass='', $db='test', $host = '127.0.0.1') { $dsn = 'mysql:dbname='.db.';host='.$host.';charset=utf8'; try { $this->connect = new PDO($dsn, $user, $password); } catch (PDOException $e) { echo 'Подключение не удалось: ' . $e->getMessage(); } } |