mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Updating mysqli: bring overview up to date
Patch contributed by Dharman <tekiela246@gmail.com>. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@351329 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
63319dea7d
commit
14ba1dcb17
1 changed files with 17 additions and 93 deletions
|
@ -23,11 +23,11 @@
|
|||
</para>
|
||||
|
||||
<para>
|
||||
APIs can be procedural or object-oriented. With a procedural API you
|
||||
APIs can be procedural or object-oriented. With a procedural API, you
|
||||
call functions to carry out tasks, with the object-oriented API you
|
||||
instantiate classes and then call methods on the resulting objects.
|
||||
Of the two the latter is usually the preferred interface, as it is
|
||||
more modern and leads to better organized code.
|
||||
Of the two, the latter is usually the preferred interface, as it is
|
||||
more modern and leads to better-organized code.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<para>
|
||||
If your PHP application needs to communicate with a database server
|
||||
you will need to write PHP code to perform such activities as
|
||||
connecting to the database server, querying the database and other
|
||||
connecting to the database server, querying the database, and other
|
||||
database-related functions. Software is required to provide the API
|
||||
that your PHP application will use, and also handle the
|
||||
communication between your application and the database server,
|
||||
|
@ -95,8 +95,8 @@
|
|||
In the PHP documentation you will come across another term -
|
||||
<emphasis>extension</emphasis>. The PHP code consists of a core,
|
||||
with optional extensions to the core functionality. PHP's
|
||||
MySQL-related extensions, such as the <literal>mysqli</literal>
|
||||
extension, and the <literal>mysql</literal> extension, are
|
||||
MySQL-related extensions, such as the mysqli
|
||||
extension, and the PDO MySQL driver extension, are
|
||||
implemented using the PHP extension framework.
|
||||
</para>
|
||||
|
||||
|
@ -125,18 +125,12 @@
|
|||
</para>
|
||||
|
||||
<para>
|
||||
There are three main API options when considering connecting to a
|
||||
There are two main API options when considering connecting to a
|
||||
MySQL database server:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
PHP's MySQL Extension
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
PHP's mysqli Extension
|
||||
|
@ -157,37 +151,6 @@
|
|||
each API.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis role="bold">What is PHP's MySQL Extension?</emphasis>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This is the original extension designed to allow you to develop PHP
|
||||
applications that interact with a MySQL database. The
|
||||
<literal>mysql</literal> extension provides a procedural interface
|
||||
and is intended for use only with MySQL versions older than 4.1.3.
|
||||
This extension can be used with versions of MySQL 4.1.3 or newer,
|
||||
but not all of the latest MySQL server features will be available.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
If you are using MySQL versions 4.1.3 or later it is
|
||||
<emphasis>strongly</emphasis> recommended that you use the
|
||||
<literal>mysqli</literal> extension instead.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
The <literal>mysql</literal> extension source code is located in the
|
||||
PHP extension directory <filename>ext/mysql</filename>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For further information on the <literal>mysql</literal> extension,
|
||||
see <xref linkend="book.mysql"/>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<emphasis role="bold">What is PHP's mysqli Extension?</emphasis>
|
||||
</para>
|
||||
|
@ -240,14 +203,6 @@
|
|||
</itemizedlist>
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
If you are using MySQL versions 4.1.3 or later it is
|
||||
<emphasis>strongly</emphasis> recommended that you use this
|
||||
extension.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
As well as the object-oriented interface the extension also provides
|
||||
a procedural interface.
|
||||
|
@ -307,7 +262,7 @@
|
|||
|
||||
<para>
|
||||
The PDO MYSQL driver is not an API as such, at least from the PHP
|
||||
programmer's perspective. In fact the PDO MYSQL driver sits in the
|
||||
programmer's perspective. In fact, the PDO MYSQL driver sits in the
|
||||
layer below PDO itself and provides MySQL-specific functionality.
|
||||
The programmer still calls the PDO API, but PDO uses the PDO MYSQL
|
||||
driver to carry out communication with the MySQL server.
|
||||
|
@ -336,8 +291,7 @@
|
|||
</para>
|
||||
|
||||
<para>
|
||||
In order to communicate with the MySQL database server the
|
||||
<literal>mysql</literal> extension, <literal>mysqli</literal> and
|
||||
In order to communicate with the MySQL database server, <literal>mysqli</literal> and
|
||||
the PDO MYSQL driver each use a low-level library that implements
|
||||
the required protocol. In the past, the only available library was
|
||||
the MySQL Client Library, otherwise known as
|
||||
|
@ -348,14 +302,13 @@
|
|||
However, the interface presented by <literal>libmysqlclient</literal> was
|
||||
not optimized for communication with PHP applications, as
|
||||
<literal>libmysqlclient</literal> was originally designed with C
|
||||
applications in mind. For this reason the MySQL Native Driver,
|
||||
applications in mind. For this reason, the MySQL Native Driver,
|
||||
<literal>mysqlnd</literal>, was developed as an alternative to
|
||||
<literal>libmysqlclient</literal> for PHP applications.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <literal>mysql</literal> extension, the
|
||||
<literal>mysqli</literal> extension and the PDO MySQL driver can
|
||||
Both, the <literal>mysqli</literal> extension and the PDO MySQL driver can
|
||||
each be individually configured to use either
|
||||
<literal>libmysqlclient</literal> or <literal>mysqlnd</literal>. As
|
||||
<literal>mysqlnd</literal> is designed specifically to be utilised
|
||||
|
@ -364,13 +317,6 @@
|
|||
advantage of these improvements.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
The MySQL Native Driver can only be used with MySQL server
|
||||
versions 4.1.3 and later.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
The MySQL Native Driver is implemented using the PHP extension
|
||||
framework. The source code is located in
|
||||
|
@ -390,23 +336,21 @@
|
|||
</para>
|
||||
|
||||
<para>
|
||||
The following table compares the functionality of the three main
|
||||
The following table compares the functionality of the main
|
||||
methods of connecting to MySQL from PHP:
|
||||
</para>
|
||||
|
||||
<table>
|
||||
<title>Comparison of MySQL API options for PHP</title>
|
||||
<tgroup cols="4">
|
||||
<colspec colwidth="25*"/>
|
||||
<colspec colwidth="25*"/>
|
||||
<colspec colwidth="25*"/>
|
||||
<colspec colwidth="25*"/>
|
||||
<tgroup cols="3">
|
||||
<colspec colwidth="34*"/>
|
||||
<colspec colwidth="33*"/>
|
||||
<colspec colwidth="33*"/>
|
||||
<thead>
|
||||
<row>
|
||||
<entry></entry>
|
||||
<entry>PHP's mysqli Extension</entry>
|
||||
<entry>PDO (Using PDO MySQL Driver and MySQL Native Driver)</entry>
|
||||
<entry>PHP's MySQL Extension</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -414,61 +358,41 @@
|
|||
<entry>PHP version introduced</entry>
|
||||
<entry>5.0</entry>
|
||||
<entry>5.0</entry>
|
||||
<entry>Prior to 3.0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>Included with PHP 5.x</entry>
|
||||
<entry>yes</entry>
|
||||
<entry>yes</entry>
|
||||
<entry>Yes</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>MySQL development status</entry>
|
||||
<entry>Active development</entry>
|
||||
<entry>Active development as of PHP 5.3</entry>
|
||||
<entry>Maintenance only</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>Recommended by MySQL for new projects</entry>
|
||||
<entry>Yes - preferred option</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>No</entry>
|
||||
<entry>Active development</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>API supports Charsets</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>No</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>API supports server-side Prepared Statements</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>No</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>API supports client-side Prepared Statements</entry>
|
||||
<entry>No</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>No</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>API supports Stored Procedures</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>No</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>API supports Multiple Statements</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>Most</entry>
|
||||
<entry>No</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>Supports all MySQL 4.1+ functionality</entry>
|
||||
<entry>Yes</entry>
|
||||
<entry>Most</entry>
|
||||
<entry>No</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
|
|
Loading…
Reference in a new issue