Apache-php7 does not support mysql extension, how to use mysqlnd?

Source: Internet
Author: User
I used php7 and mysql in Windows 7. When I enabled mysql extension, I found that only php_pdo_mysql and php_mysqli in ext. The mysql _ * function is not found at the same time. For more information, see mysqlnd driver. Is mysqlnd installed? Then how can I use it. Thank you.

I used php7 and mysql in Windows 7. When I enabled mysql extension, I found that only php_pdo_mysql and php_mysqli in ext. The mysql _ * function is not found at the same time. For more information, see mysqlnd driver.

Is mysqlnd installed? Then how can I use it. Thank you.

Reply content:

I used php7 and mysql in Windows 7. When I enabled mysql extension, I found that only php_pdo_mysql and php_mysqli in ext. The mysql _ * function is not found at the same time. For more information, see mysqlnd driver.

Is mysqlnd installed? Then how can I use it. Thank you.

First, correct a problem,

Starting from 5.x, PHP connects to MYSQL by using the mysqlnd Driver (of course, when you install it ). Includingmysql_*,PDO_MYSQL,MYSQLi

--with-mysqli=mysqlnd --with-pdo-mysql=mysqlndInstead--with-mysqli=/usr/local/mysql

  • PHP7 has been removed.mysqlExtension

mysqlndAndmysql mysqli pdo_mysqlLink analogymysqlndYesMetal, Andmysql mysqli pdo_mysqlJustMetal ProductsOnly

Use PDO to connect to mysql
$ Pdo = new PDO ('mysql: host = localhost; dbname = database_name; port = 000000', 'username', 'Password '); $ 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 );

Mysql extension in php7 is completely removed. For better backward compatibility, use PDO;
You have been installed. You can refer to the Manual to connect to the database with PDO.

Please use PDO more. There is an object-oriented idea in it for better use.

I didn't want to answer this question .... Just wondering how to replace mysql in the old project with pdo .... You deserve it, PDO.

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.