APACHE-PHP7 does not support MySQL extensions, how do I use MYSQLND?

Source: Internet
Author: User

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=mysqlndAnd no longer be--with-mysqli=/usr/local/mysql

    • PHP7 formally removed the mysql extension

mysqlndand 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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.