![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_16461962252.webp)
Overview of the MySQL PHP drivers
2232
"example.com" using the username "user" and the password "password". And a query is run to greet
the user.
Example 20.13. Comparing the three MySQL APIs
<?php
// mysqli
$mysqli = new mysqli("example.com", "user", "password", "database");
$result = $mysqli->query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = $result->fetch_assoc();
echo htmlentities($row['_message']);
// PDO
$pdo = new PDO('mysql:host=example.com;dbname=database', 'user', 'password');
$statement = $pdo->query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = $statement->fetch(PDO::FETCH_ASSOC);
echo htmlentities($row['_message']);
// mysql
$c = mysql_connect("example.com", "user", "password");
mysql_select_db("database");
$result = mysql_query("SELECT 'Hello, dear MySQL user!' AS _message FROM DUAL");
$row = mysql_fetch_assoc($result);
echo htmlentities($row['_message']);
?>
Recommended API
It is recommended to use either the
mysqli
or
PDO_MySQL
extensions. It is not recommended to use
the old
mysql
extension for new development, as it has been deprecated as of PHP 5.5.0 and will be
removed in the future. A detailed feature comparison matrix is provided below. The overall performance
of all three extensions is considered to be about the same. Although the performance of the extension
contributes only a fraction of the total run time of a PHP web request. Often, the impact is as low as
0.1%.
Feature comparison
ext/mysqli
PDO_MySQL
ext/mysql
PHP version introduced
5.0
5.1
2.0
Included with PHP 5.x
Yes
Yes
Yes
Development status
Active
Active
Maintenance only
Lifecycle
Active
Active
Deprecated
Recommended for new
projects
Yes
Yes
No
OOP Interface
Yes
Yes
No
Procedural Interface
Yes
No
Yes
API supports non-
blocking, asynchronous
queries with mysqlnd
Yes
No
No
Persistent Connections
Yes
Yes
Yes
API supports Charsets
Yes
Yes
Yes
API supports server-side
Prepared Statements
Yes
Yes
No
API supports client-side
Prepared Statements
No
Yes
No
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...