I used PHP7 and MySQL under Windows7, and when I enabled MySQL extension, I found only php_pdo_mysql and php_mysqli under ext. Also found that there is no mysql_* function, find data is said to use the Mysqlnd driver.
Is this a mysqlnd already installed? And then how do I use it. Thank you
Reply content:
I used PHP7 and MySQL under Windows7, and when I enabled MySQL extension, I found only php_pdo_mysql and php_mysqli under ext. Also found that there is no mysql_* function, find data is said to use the Mysqlnd driver.
Is this a mysqlnd already installed? And then how do I use it. Thank you
First correct a problem,
5.x start, PHP connection to MySQL regardless of the way you use the Mysqlnd drive (of course, when you install the good). including mysql_*
, PDO_MYSQL
,MYSQLi
--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
And no longer be--with-mysqli=/usr/local/mysql
mysqlnd
and mysql
mysqli
pdo_mysql
relationships mysqlnd
金属
, for example, but mysql
mysqli
pdo_mysql
just 金属制品
.
Connect to MySQL using PDO
$pdo = new PDO('mysql:host=localhost;dbname=database_name;port=3306','用户名','密码');$pdo->exec('set names utf8');$stmt = $pdo->prepare("select * from table where id =:id");$stmt->bindValue(':id',1,PDO::PARAM_INT);$stmt->execute();$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);$rows = $pdo->query("select * from table where id = 1")->fetchAll(PDO::FETCH_ASSOC);
The MySQL extension in php7 is completely removed, using PDO for better backwards compatibility;
You have a good mood, you can refer to the manual using PDO to connect to the database
Please use PDO more, there are object-oriented ideas, more useful
I didn't want to answer that .... Just worried about how to replace MySQL in the old project with PDO to see this .... Landlord, PDO you deserve to have