PHP extension Database connection parameter description detailed

Source: Internet
Author: User
Tags mysql client

noun Explanation:What the hell is mysqli,mysqlnd,pdo? , what is the use?

MySQL: This extension are deprecated as of PHP 5.5.0, and has been removed as of PHP 7.0.0.
MYSQLI: MySQL improved Extension
MYSQLND: MySQL Native Drive
PDO: ThePHP Data Objects. Extension defines a lightweight, consistent interface for accessing databases in PHP.

Above, excerpt from PHP official manual: http://php.net/manual/en/book.mysqli.php

The following are Chinese translations:
MySQL is also known as the Original MYSQL,PHP4 version of the MySQL extension, which has been discarded from the PHP5 and removed from the PHP7.

Mysqli is called "MySQL Enhanced extensions".

Mysqlnd MySQL NATIVE dirver is called the "official drive" of MySQL or more directly called "Native Drive".

The PDO PHP data Objects PHP object is a Database abstraction layer specification in PHP applications.

Add a few more noun explanations:

1. What is an API?

An application interface (application programming interface abbreviation) that defines the classes, methods, functions, variables, and so on everything in your application that needs to be called in order to complete a particular task. The API required for PHP applications to interact with the database is usually exposed via PHP extensions (called to the terminal PHP programmer).

The above-mentioned MySQL and mysqli extensions provide such an API.

2, what is the driver?

A driver is a piece of software code designed to interact with a particular type of database server. The driver may call some libraries,

such as MySQL client library or MySQL native driver library. These libraries implement the underlying protocol for interacting with the MySQL database server.

from the point of view of PHP expansion, MySQL and mysqli are still relatively upper-level, relying on the bottom of the library to connect and access the database.
The above-mentioned MYSQLND is the underlying database driver. Of course, there is also a driver called libmysqlclient.

Summary:

From the application level, we operate the database through PHP's MySQL or mysqli extension API.

From the ground up, MYSQLND provides support for the underlying and database interactions (which can be easily understood as a network protocol interaction with MySQL server).

PDO, however, provides a unified API interface so that your PHP application does not care about the type of database server system you want to connect to. In other words, if you use the PDO API, you can seamlessly switch the database server whenever you need to. For example Mysql,sqlite any database is OK.

For most functions, the API interface provided by PDO and the interface provided by MYSQLI are consistent with the general effect of adding and deleting.


Understand by PHP code:

MySQL Connection:

<?php$conn = @ mysql_connect ("localhost", "root", "") or Die ("Database connection Error"), mysql_select_db ("BBS", $conn); mysql_query (" Set names ' UTF8 '); echo "Database connection succeeded";? >


Mysqli Connection:

<?php$conn = Mysqli_connect (' localhost ', ' root ', ' ', ' BBS '), if (! $conn) {die ("Database connection Error". Mysqli_connect_error ());} Else{echo "database connection succeeded";}? >



PDO Connection:

<?phptry{$pdo =new PDO ("Mysql:host=localhost;dbname=bbs", "Root", "");} catch (Pddexception $e) {echo "Database connection error";} echo "Database connection succeeded";? >


Note Common parameters
--enable-pdo
--with-pdo-mysql
--enable-mysqlnd
--with-mysqli
--with-mysql//PHP7 is no longer supported, whether compiling or Yum installation will report error

This article is from the "Boyhack" blog, make sure to keep this source http://461205160.blog.51cto.com/274918/1943416

PHP extension Database connection parameter description detailed

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.