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;
}
Asked
Active
Viewed 222 times
1
0xdb
- 51,614
-
Так http://php.net/manual/ru/pdo.construct.php – Visman Sep 30 '17 at 10:54
1 Answers
1
Как-то так
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();
}
}
Ivan Bolnikh
- 1,604
- 1
- 9
- 11