Author: mcbrown
Date: 2008-08-14 18:28:29 +0200 (Thu, 14 Aug 2008)
New Revision: 11561
Log:
Adding the PHP documentation into the tree
Updating dependencies
Added:
trunk/refman-common/apis-php-mysql.xml
trunk/refman-common/apis-php-mysqli.xml
trunk/refman-common/apis-php-pdo-mysql.xml
Removed:
0 Skipped: 0 Warnings: 0
0 Skipped: 0 Warnings: 0</entry>
Modified:
trunk/refman-4.1/Makefile.depends
trunk/refman-5.0/Makefile.depends
trunk/refman-common/apis-php.xml
Modified: trunk/refman-4.1/Makefile.depends
===================================================================
--- trunk/refman-4.1/Makefile.depends 2008-08-14 15:40:39 UTC (rev 11560)
+++ trunk/refman-4.1/Makefile.depends 2008-08-14 16:28:29 UTC (rev 11561)
Changed blocks: 4, Lines Added: 11, Lines Deleted: 1; 1999 bytes
@@ -34,6 +34,9 @@
../common/fixedchars.ent \
../common/phrases.ent \
../refman-common/../common/fixedchars.ent \
+ ../refman-common/../refman-common/apis-php-mysql.xml \
+ ../refman-common/../refman-common/apis-php-mysqli.xml \
+ ../refman-common/../refman-common/apis-php-pdo-mysql.xml \
../refman-common/all-entities.ent \
../refman-common/apis-cplusplus.xml \
../refman-common/apis-eiffel.xml \
@@ -61,6 +64,8 @@
../refman-4.1/metadata/programs-development.idmap \
../refman-4.1/metadata/programs-using.idmap \
../refman-4.1/metadata/programs.idmap \
+ ../refman-common/metadata/apis-php-mysql.idmap \
+ ../refman-common/metadata/apis-php-mysqli.idmap \
../refman-common/metadata/connector-j.idmap \
../refman-common/metadata/connector-odbc.idmap \
../refman-common/metadata/information-sources.idmap
@@ -849,6 +854,9 @@
../dynamic-docs/metadata-titles.en.xml \
../dynamic-docs/opsfunctions/opfunctions.xml \
../refman-common/../common/fixedchars.ent \
+ ../refman-common/../refman-common/apis-php-mysql.xml \
+ ../refman-common/../refman-common/apis-php-mysqli.xml \
+ ../refman-common/../refman-common/apis-php-pdo-mysql.xml \
../refman-common/../refman-common/connector-j-connprops.xml \
../refman-common/../refman-common/connector-j-errormap.xml \
../refman-common/all-entities.ent \
@@ -1137,7 +1145,9 @@
../refman-4.1/metadata/sql-syntax-utility.idmap \
../refman-4.1/metadata/sql-syntax.idmap \
../refman-4.1/metadata/storage-engines.idmap \
- ../refman-4.1/metadata/tutorial.idmap
+ ../refman-4.1/metadata/tutorial.idmap \
+ ../refman-common/metadata/apis-php-mysql.idmap \
+ ../refman-common/metadata/apis-php-mysqli.idmap
manual.validpure: $(manual_SOURCES)
manual.titles: $(manual_SOURCES)
manual.useless: $(manual_SOURCES)
Modified: trunk/refman-5.0/Makefile.depends
===================================================================
--- trunk/refman-5.0/Makefile.depends 2008-08-14 15:40:39 UTC (rev 11560)
+++ trunk/refman-5.0/Makefile.depends 2008-08-14 16:28:29 UTC (rev 11561)
Changed blocks: 4, Lines Added: 11, Lines Deleted: 1; 2063 bytes
@@ -34,6 +34,9 @@
../common/fixedchars.ent \
../common/phrases.ent \
../refman-common/../common/fixedchars.ent \
+ ../refman-common/../refman-common/apis-php-mysql.xml \
+ ../refman-common/../refman-common/apis-php-mysqli.xml \
+ ../refman-common/../refman-common/apis-php-pdo-mysql.xml \
../refman-common/all-entities.ent \
../refman-common/apis-cplusplus.xml \
../refman-common/apis-eiffel.xml \
@@ -61,6 +64,8 @@
../refman-5.0/metadata/programs-development.idmap \
../refman-5.0/metadata/programs-using.idmap \
../refman-5.0/metadata/programs.idmap \
+ ../refman-common/metadata/apis-php-mysql.idmap \
+ ../refman-common/metadata/apis-php-mysqli.idmap \
../refman-common/metadata/connector-j.idmap \
../refman-common/metadata/connector-odbc.idmap \
../refman-common/metadata/information-sources.idmap
@@ -1606,6 +1611,9 @@
../dynamic-docs/reserved-words/mysql-5.0.6-beta \
../dynamic-docs/reserved-words/mysql-5.0.9-beta \
../refman-common/../common/fixedchars.ent \
+ ../refman-common/../refman-common/apis-php-mysql.xml \
+ ../refman-common/../refman-common/apis-php-mysqli.xml \
+ ../refman-common/../refman-common/apis-php-pdo-mysql.xml \
../refman-common/../refman-common/connector-j-connprops.xml \
../refman-common/../refman-common/connector-j-errormap.xml \
../refman-common/all-entities.ent \
@@ -2021,7 +2029,9 @@
../refman-5.1/metadata/mysql-cluster-replication.idmap \
../refman-5.1/metadata/mysql-cluster-roadmap.idmap \
../refman-5.1/metadata/mysql-cluster.idmap \
- ../refman-5.1/metadata/replication-configuration.idmap
+ ../refman-5.1/metadata/replication-configuration.idmap \
+ ../refman-common/metadata/apis-php-mysql.idmap \
+ ../refman-common/metadata/apis-php-mysqli.idmap
manual.validpure: $(manual_SOURCES)
manual.titles: $(manual_SOURCES)
manual.useless: $(manual_SOURCES)
Added: trunk/refman-common/apis-php-mysql.xml
===================================================================
--- trunk/refman-common/apis-php-mysql.xml (rev 0)
+++ trunk/refman-common/apis-php-mysql.xml 2008-08-14 16:28:29 UTC (rev 11561)
Changed blocks: 1, Lines Added: 6534, Lines Deleted: 0; 172098 bytes
@@ -0,0 +1,10013 @@
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+<section id="apis-php-mysql">
+
+ <title>MySQL</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <para>
+ These functions allow you to access MySQL database servers. More
+ information about MySQL can be found at
+ <ulink url="http://www.mysql.com/">http://www.mysql.com/</ulink>.
+ </para>
+
+ <para>
+ Documentation for MySQL can be found at
+ <ulink url="http://dev.mysql.com/doc/">http://dev.mysql.com/doc/</ulink>.
+ </para>
+
+ <section id="apis-php-mysql.setup">
+
+ <title>Installing/Configuring</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <section id="apis-php-mysql.requirements">
+
+ <title>Requirements</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ In order to have these functions available, you must compile PHP
+ with MySQL support.
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysql.installation">
+
+ <title>Installation</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <para id="apis-php-mysql.configure">
+ For compiling, simply use the
+ <option>--with-mysql[=DIR]</option> configuration option where
+ the optional <literal>[DIR]</literal> points to the MySQL
+ installation directory.
+ </para>
+
+ <para>
+ Although this MySQL extension is compatible with MySQL 4.1.0 and
+ greater, it doesn't support the extra functionality that
+ these versions provide. For that, use the
+ <link linkend="apis-php-mysqli">MySQLi</link> extension.
+ </para>
+
+ <para>
+ If you would like to install the mysql extension along with the
+ mysqli extension you have to use the same client library to
+ avoid any conflicts.
+ </para>
+
+ <section id="apis-php-mysql.installation.linux">
+
+ <title>Installation on Linux Systems</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <section>
+
+ <title>PHP 4</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008
+ the PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ The option <option>--with-mysql</option> is enabled by
+ default. This default behavior may be disabled with the
+ <option>--without-mysql</option> configure option. If MySQL
+ is enabled without specifying the path to the MySQL install
+ DIR, PHP will use the bundled MySQL client libraries.
+ </para>
+
+ <para>
+ Users who run other applications that use MySQL (for
+ example, auth-mysql) should not use the bundled library, but
+ rather specify the path to MySQL's install directory,
+ like so: <option>--with-mysql=/path/to/mysql</option>. This
+ will force PHP to use the client libraries installed by
+ MySQL, thus avoiding any conflicts.
+ </para>
+
+ </section>
+
+ <section>
+
+ <title>PHP 5+</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008
+ the PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ MySQL is not enabled by default, nor is the MySQL library
+ bundled with PHP. Read this
+ <ulink url="http://www.php.net/manual/en/faq.databases.mysql.php5.php">
+ FAQ</ulink> for details on why. Use the
+ <option>--with-mysql[=DIR]</option> configure option to
+ include MySQL support. You can download <emphasis>headers
+ and libraries</emphasis> from
+ <ulink url="http://www.mysql.com/">MySQL</ulink>.
+ </para>
+
+ </section>
+
+ </section>
+
+ <section id="apis-php-mysql.installation.windows">
+
+ <title>Installation on Windows Systems</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <section>
+
+ <title>PHP 4</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008
+ the PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ The PHP MySQL extension is compiled into PHP.
+ </para>
+
+ </section>
+
+ <section>
+
+ <title>PHP 5+</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008
+ the PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ MySQL is no longer enabled by default, so the
+ <filename>php_mysql.dll</filename> DLL must be enabled
+ inside of <filename>php.ini</filename>. Also, PHP needs
+ access to the MySQL client library. A file named
+ <filename>libmysql.dll</filename> is included in the Windows
+ PHP distribution and in order for PHP to talk to MySQL this
+ file needs to be available to the Windows systems
+ <envar>PATH</envar>. See the FAQ titled
+ "<ulink url="http://www.php.net/manual/en/faq.installation.addtopath.php">How
+ do I add my PHP directory to the PATH on
+ Windows</ulink>" for information on how to do this.
+ Although copying <filename>libmysql.dll</filename> to the
+ Windows system directory also works (because the system
+ directory is by default in the system's
+ <envar>PATH</envar>), it's not recommended.
+ </para>
+
+ <para>
+ As with enabling any PHP extension (such as
+ <filename>php_mysql.dll</filename>), the PHP directive
+ <ulink url="http://www.php.net/manual/en/ini.extension-dir.php">extension_dir</ulink>
+ should be set to the directory where the PHP extensions are
+ located. See also the
+ <ulink url="http://www.php.net/manual/en/install.windows.manual.php">Manual
+ Windows Installation Instructions</ulink>. An example
+ extension_dir value for PHP 5 is
+ <literal>c:\php\ext</literal>
+ </para>
+
+ <note>
+ <para>
+ If when starting the web server an error similar to the
+ following occurs: <literal>"Unable to load dynamic
+ library './php_mysql.dll'"</literal>, this
+ is because <filename>php_mysql.dll</filename> and/or
+ <filename>libmysql.dll</filename> cannot be found by the
+ system.
+ </para>
+ </note>
+
+ </section>
+
+ </section>
+
+ <section id="apis-php-mysql.installation.notes">
+
+ <title>MySQL Installation Notes</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <warning>
+ <para>
+ Crashes and startup problems of PHP may be encountered when
+ loading this extension in conjunction with the recode
+ extension. See the
+ <ulink url="http://www.php.net/manual/en/ref.recode.php">recode</ulink>
+ extension for more information.
+ </para>
+ </warning>
+
+ <note>
+ <para>
+ If you need charsets other than <emphasis>latin</emphasis>
+ (default), you have to install external (not bundled)
+ libmysql with compiled charset support.
+ </para>
+ </note>
+
+ </section>
+
+ </section>
+
+ <section id="apis-php-mysql.configuration">
+
+ <title>Runtime Configuration</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <simpara>
+The behaviour of these functions is affected by settings in <filename>php.ini</filename>.
+</simpara>
+
+ <para>
+ <table>
+ <title>MySQL Configuration Options</title>
+ <tgroup cols="4">
+ <colspec colwidth="25*"/>
+ <colspec colwidth="25*"/>
+ <colspec colwidth="25*"/>
+ <colspec colwidth="25*"/>
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Default</entry>
+ <entry>Changeable</entry>
+ <entry>Changelog</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>mysql.allow_persistent</entry>
+ <entry>"1"</entry>
+ <entry>PHP_INI_SYSTEM</entry>
+ <entry/>
+ </row>
+ <row>
+ <entry>mysql.max_persistent</entry>
+ <entry>"-1"</entry>
+ <entry>PHP_INI_SYSTEM</entry>
+ <entry/>
+ </row>
+ <row>
+ <entry>mysql.max_links</entry>
+ <entry>"-1"</entry>
+ <entry>PHP_INI_SYSTEM</entry>
+ <entry/>
+ </row>
+ <row>
+ <entry>mysql.trace_mode</entry>
+ <entry>"0"</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>Available since PHP 4.3.0.</entry>
+ </row>
+ <row>
+ <entry>mysql.default_port</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry/>
+ </row>
+ <row>
+ <entry>mysql.default_socket</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>Available since PHP 4.0.1.</entry>
+ </row>
+ <row>
+ <entry>mysql.default_host</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry/>
+ </row>
+ <row>
+ <entry>mysql.default_user</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry/>
+ </row>
+ <row>
+ <entry>mysql.default_password</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry/>
+ </row>
+ <row>
+ <entry>mysql.connect_timeout</entry>
+ <entry>"60"</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>PHP_INI_SYSTEM in PHP <= 4.3.2. Available since PHP 4.3.0.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ For further details and definitions of the PHP_INI_* constants,
+ see the
+ <ulink url="http://www.php.net/manual/en/ini.php"></ulink>.
+ </para>
+
+ <para>
+ Here's a short explanation of the configuration directives.
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry id="apis-php-ini.mysql.allow-persistent">
+ <term>
+ <parameter>mysql.allow_persistent</parameter>
+ <type>boolean</type>
+ </term>
+
+ <listitem>
+ <para>
+ Whether to allow
+ <ulink url="http://www.php.net/manual/en/features.persistent-connections.php">persistent
+ connections</ulink> to MySQL.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.max-persistent">
+ <term>
+ <parameter>mysql.max_persistent</parameter>
+ <type>integer</type>
+ </term>
+
+ <listitem>
+ <para>
+ The maximum number of persistent MySQL connections per
+ process.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.max-links">
+ <term>
+ <parameter>mysql.max_links</parameter>
+ <type>integer</type>
+ </term>
+
+ <listitem>
+ <para>
+ The maximum number of MySQL connections per process,
+ including persistent connections.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.trace-mode">
+ <term>
+ <parameter>mysql.trace_mode</parameter>
+ <type>boolean</type>
+ </term>
+
+ <listitem>
+ <para>
+ Trace mode. When <literal>mysql.trace_mode</literal> is
+ enabled, warnings for table/index scans, non free result
+ sets, and SQL-Errors will be displayed. (Introduced in
+ PHP 4.3.0)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.default-port">
+ <term>
+ <parameter>mysql.default_port</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default TCP port number to use when connecting to
+ the database server if no other port is specified. If no
+ default is specified, the port will be obtained from the
+ <envar>MYSQL_TCP_PORT</envar> environment variable, the
+ <literal>mysql-tcp</literal> entry in
+ <filename>/etc/services</filename> or the compile-time
+
+ <constant>MYSQL_PORT</constant>
+
+ constant, in that order. Win32 will only use the
+
+ <constant>MYSQL_PORT</constant>
+
+ constant.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.default-socket">
+ <term>
+ <parameter>mysql.default_socket</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default socket name to use when connecting to a
+ local database server if no other socket name is
+ specified.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.default-host">
+ <term>
+ <parameter>mysql.default_host</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default server host to use when connecting to the
+ database server if no other host is specified.
+ Doesn't apply in
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.default-user">
+ <term>
+ <parameter>mysql.default_user</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default user name to use when connecting to the
+ database server if no other name is specified.
+ Doesn't apply in
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.default-password">
+ <term>
+ <parameter>mysql.default_password</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default password to use when connecting to the
+ database server if no other password is specified.
+ Doesn't apply in
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysql.connect-timeout">
+ <term>
+ <parameter>mysql.connect_timeout</parameter>
+ <type>integer</type>
+ </term>
+
+ <listitem>
+ <para>
+ Connect timeout in seconds. On Linux this timeout is
+ also used for waiting for the first answer from the
+ server.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysql.resources">
+
+ <title>Resource Types</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ There are two resource types used in the MySQL module. The first
+ one is the link identifier for a database connection, the second
+ a resource which holds the result of a query.
+ </para>
+
+ </section>
+
+ </section>
+
+ <section id="apis-php-mysql.constants">
+
+ <title>Predefined Constants</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <simpara>
+The constants below are defined by this extension, and
+will only be available when the extension has either
+been compiled into PHP or dynamically loaded at runtime.
+</simpara>
+
+ <para>
+ Since PHP 4.3.0 it is possible to specify additional client flags
+ for the
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ and
+ <link linkend="apis-php-function.mysql-pconnect"><function>mysql_pconnect</function></link>
+ functions. The following constants are defined:
+
+ <table id="apis-php-mysql.client-flags">
+ <title>MySQL client constants</title>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Constant</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>MYSQL_CLIENT_COMPRESS</entry>
+ <entry>Use compression protocol</entry>
+ </row>
+ <row>
+ <entry>MYSQL_CLIENT_IGNORE_SPACE</entry>
+ <entry>Allow space after function names</entry>
+ </row>
+ <row>
+ <entry>MYSQL_CLIENT_INTERACTIVE</entry>
+ <entry>Allow interactive_timeout seconds (instead of wait_timeout) of
+ inactivity before closing the connection.</entry>
+ </row>
+ <row>
+ <entry>MYSQL_CLIENT_SSL</entry>
+ <entry>Use SSL encryption. This flag is only available with version 4.x of the
+ MySQL client library or newer. Version 3.23.x is bundled
+ both with PHP 4 and Windows binaries of PHP 5.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+
+ <para>
+ The function
+ <link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+ uses a constant for the different types of result arrays. The
+ following constants are defined:
+
+ <table>
+ <title>MySQL fetch constants</title>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Constant</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>MYSQL_ASSOC</entry>
+ <entry>Columns are returned into the array having the fieldname as the array
+ index.</entry>
+ </row>
+ <row>
+ <entry>MYSQL_BOTH</entry>
+ <entry>Columns are returned into the array having both a numerical index and
+ the fieldname as the array index.</entry>
+ </row>
+ <row>
+ <entry>MYSQL_NUM</entry>
+ <entry>Columns are returned into the array having a numerical index to the
+ fields. This index starts with 0, the first field in the
+ result.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysql.examples">
+
+ <title>Examples</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <section id="apis-php-mysql.examples-basic">
+
+ <title>Basic</title>
+
+ <para>
+ This simple example shows how to connect, execute a query, print
+ resulting rows and disconnect from a MySQL database.
+
+ <example>
+
+ <title>MySQL extension overview example</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008
+ the PHP Documentation Group.</link>
+ </para>
+
+<programlisting>
+<![CDATA[
+<?php
+// Connecting, selecting database
+$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
+ or die('Could not connect: ' . mysql_error());
+echo 'Connected successfully';
+mysql_select_db('my_database') or die('Could not select database');
+
+// Performing SQL query
+$query = 'SELECT * FROM my_table';
+$result = mysql_query($query) or die('Query failed: ' . mysql_error());
+
+// Printing results in HTML
+echo "<table>\n";
+while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
+ echo "\t<tr>\n";
+ foreach ($line as $col_value) {
+ echo "\t\t<td>$col_value</td>\n";
+ }
+ echo "\t</tr>\n";
+}
+echo "</table>\n";
+
+// Free resultset
+mysql_free_result($result);
+
+// Closing connection
+mysql_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ </section>
+
+ </section>
+
+ <section id="apis-php-ref.mysql">
+
+ <title>MySQL Functions</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <note>
+ <para>
+ Most MySQL functions accept
+ <parameter>link_identifier</parameter> as the last optional
+ parameter. If it is not provided, last opened connection is
+ used. If it doesn't exist, connection is tried to establish
+ with default parameters defined in <filename>php.ini</filename>.
+ If it is not successful, functions return
+
+ <constant>FALSE</constant>
+
+ .
+ </para>
+ </note>
+
+ <section id="apis-php-function.mysql-affected-rows">
+
+ <title><literal>mysql_affected_rows</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_affected_rows</literal>
+ </para>
+
+ <para>
+ Get number of affected rows in previous MySQL operation
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysql_affected_rows</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Get the number of affected rows by the last INSERT, UPDATE,
+ REPLACE or DELETE query associated with
+ <parameter>link_identifier</parameter>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the number of affected rows on success, and -1 if the
+ last query failed.
+ </para>
+
+ <para>
+ If the last query was a DELETE query with no WHERE clause, all
+ of the records will have been deleted from the table but this
+ function will return zero with MySQL versions prior to 4.1.2.
+ </para>
+
+ <para>
+ When using UPDATE, MySQL will not update columns where the new
+ value is the same as the old value. This creates the possibility
+ that
+ <link linkend="apis-php-function.mysql-affected-rows"><function>mysql_affected_rows</function></link>
+ may not actually equal the number of rows matched, only the
+ number of rows that were literally affected by the query.
+ </para>
+
+ <para>
+ The REPLACE statement first deletes the record with the same
+ primary key and then inserts the new record. This function
+ returns the number of deleted records plus the number of
+ inserted records.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-affected-rows"><function>mysql_affected_rows</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+mysql_select_db('mydb');
+
+/* this should return the correct numbers of deleted records */
+mysql_query('DELETE FROM mytable WHERE id < 10');
+printf("Records deleted: %d\n", mysql_affected_rows());
+
+/* with a where clause that is never true, it should return 0 */
+mysql_query('DELETE FROM mytable WHERE 0');
+printf("Records deleted: %d\n", mysql_affected_rows());
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Records deleted: 10
+Records deleted: 0
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-affected-rows"><function>mysql_affected_rows</function></link>
+ example using transactions</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+mysql_select_db('mydb');
+
+/* Update records */
+mysql_query("UPDATE mytable SET used=1 WHERE id < 10");
+printf ("Updated records: %d\n", mysql_affected_rows());
+mysql_query("COMMIT");
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Updated Records: 10
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <title>Transactions</title>
+
+ <para>
+ If you are using transactions, you need to call
+ <link linkend="apis-php-function.mysql-affected-rows"><function>mysql_affected_rows</function></link>
+ after your INSERT, UPDATE, or DELETE query, not after the
+ COMMIT.
+ </para>
+ </note>
+
+ <note>
+ <title>SELECT Statements</title>
+
+ <para>
+ To retrieve the number of rows returned by a SELECT, it is
+ possible to use
+ <link linkend="apis-php-function.mysql-num-rows"><function>mysql_num_rows</function></link>.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-num-rows"><function>mysql_num_rows</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-info"><function>mysql_info</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-change-user">
+
+ <title><literal>mysql_change_user</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_change_user</literal>
+ </para>
+
+ <para>
+ Change logged in user of the active connection
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysql_change_user</methodname>
+ <methodparam>
+ <type>string</type><parameter>user</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>password</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>database</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-change-user"><function>mysql_change_user</function></link>
+ changes the logged in user of the current active connection, or
+ the connection given by the optional
+ <parameter>link_identifier</parameter> parameter. If a database
+ is specified, this will be the current database after the user
+ has been changed. If the new user and password authorization
+ fails, the current connected user stays active.
+ </para>
+
+ <para>
+ This function is deprecated and no longer exists in PHP.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>user</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The new MySQL username.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>password</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The new MySQL password.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>database</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL database. If not specified, the current
+ selected database is used.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">ChangeLog</emphasis>
+ </para>
+
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Version</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>3.0.14</entry>
+ <entry>This function was removed from PHP.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <title>Requirements</title>
+
+ <para>
+ This function requires MySQL 3.23.3 or higher.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-select-db"><function>mysql_select_db</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-client-encoding">
+
+ <title><literal>mysql_client_encoding</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_client_encoding</literal>
+ </para>
+
+ <para>
+ Returns the name of the character set
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_client_encoding</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Retrieves the <literal>character_set</literal> variable from
+ MySQL.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the default character set name for the current
+ connection.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-client-encoding"><function>mysql_client_encoding</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+$charset = mysql_client_encoding($link);
+
+echo "The current character set is: $charset\n";
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+The current character set is: latin1
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-set-charset"><function>mysql_set_charset</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-real-escape-string"><function>mysql_real_escape_string</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-close">
+
+ <title><literal>mysql_close</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_close</literal>
+ </para>
+
+ <para>
+ Close MySQL connection
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysql_close</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-close"><function>mysql_close</function></link>
+ closes the non-persistent connection to the MySQL server
+ that's associated with the specified link identifier. If
+ <parameter>link_identifier</parameter> isn't specified, the
+ last opened link is used.
+ </para>
+
+ <para>
+ Using
+ <link linkend="apis-php-function.mysql-close"><function>mysql_close</function></link>
+ isn't usually necessary, as non-persistent open links are
+ automatically closed at the end of the script's execution.
+ See also
+ <ulink url="http://www.php.net/manual/en/language.types.resource.self-destruct.php">freeing
+ resources</ulink>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-close"><function>mysql_close</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Connected successfully
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ <link linkend="apis-php-function.mysql-close"><function>mysql_close</function></link>
+ will not close persistent links created by
+ <link linkend="apis-php-function.mysql-pconnect"><function>mysql_pconnect</function></link>.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-free-result"><function>mysql_free_result</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-connect">
+
+ <title><literal>mysql_connect</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_connect</literal>
+ </para>
+
+ <para>
+ Open a connection to a MySQL Server
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>resource</type><methodname>mysql_connect</methodname>
+ <methodparam>
+ <type>string</type><parameter>server</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>username</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>password</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>bool</type><parameter>new_link</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>client_flags</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Opens or reuses a connection to a MySQL server.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>server</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL server. It can also include a port number.
+ e.g. "hostname:port" or a path to a local
+ socket e.g. ":/path/to/socket" for the
+ localhost.
+ </para>
+
+ <para>
+ If the PHP directive
+ <ulink url="http://www.php.net/manual/en/ini.mysql.default-host.php">
+ mysql.default_host</ulink> is undefined (default), then
+ the default value is 'localhost:3306'. In
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>, this parameter is ignored and value
+ 'localhost:3306' is always used.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>username</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The username. Default value is defined by
+ <ulink url="http://www.php.net/manual/en/ini.mysql.default-user.php">mysql.default_user</ulink>.
+ In
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>, this parameter is ignored and the
+ name of the user that owns the server process is used.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>password</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The password. Default value is defined by
+ <ulink url="http://www.php.net/manual/en/ini.mysql.default-password.php">mysql.default_password</ulink>.
+ In
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>, this parameter is ignored and empty
+ password is used.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>new_link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ If a second call is made to
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ with the same arguments, no new link will be
+ established, but instead, the link identifier of the
+ already opened link will be returned. The
+ <parameter>new_link</parameter> parameter modifies this
+ behavior and makes
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ always open a new link, even if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called before with the same parameters. In
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>, this parameter is ignored.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>client_flags</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The <parameter>client_flags</parameter> parameter can be
+ a combination of the following constants: 128 (enable
+ <literal>LOAD DATA LOCAL</literal> handling),
+
+ <constant>MYSQL_CLIENT_SSL</constant>
+
+ ,
+
+ <constant>MYSQL_CLIENT_COMPRESS</constant>
+
+ ,
+
+ <constant>MYSQL_CLIENT_IGNORE_SPACE</constant>
+
+ or
+
+ <constant>MYSQL_CLIENT_INTERACTIVE</constant>
+
+ . Read the section about
+ <xref linkend="apis-php-mysql.client-flags"/> for
+ further information. In
+ <ulink url="http://www.php.net/manual/en/ini.sql.safe-mode.php">SQL
+ safe mode</ulink>, this parameter is ignored.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns a MySQL link identifier on success, or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">ChangeLog</emphasis>
+ </para>
+
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Version</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>4.3.0</entry>
+ <entry>Added the <parameter>client_flags</parameter> parameter.</entry>
+ </row>
+ <row>
+ <entry>4.2.0</entry>
+ <entry>Added the <parameter>new_link</parameter> parameter.</entry>
+ </row>
+ <row>
+ <entry>3.0.10</entry>
+ <entry>Added support for ":/path/to/socket" with
+ <parameter>server</parameter>.</entry>
+ </row>
+ <row>
+ <entry>3.0.0</entry>
+ <entry>Added support for ":port" with <parameter>server</parameter>.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ example using <literal>hostname:port</literal> syntax</title>
+
+<programlisting>
+<![CDATA[
+<?php
+// we connect to example.com and port 3307
+$link = mysql_connect('example.com:3307', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+
+// we connect to localhost at port 3307
+$link = mysql_connect('127.0.0.1:3307', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ example using ":/path/to/socket" syntax</title>
+
+<programlisting>
+<![CDATA[
+<?php
+// we connect to localhost and socket e.g. /tmp/mysql.sock
+
+//variant 1: ommit localhost
+$link = mysql_connect(':/tmp/mysql', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+
+
+// variant 2: with localhost
+$link = mysql_connect('localhost:/tmp/mysql.sock', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+echo 'Connected successfully';
+mysql_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ Whenever you specify "localhost" or
+ "localhost:port" as server, the MySQL client library
+ will override this and try to connect to a local socket (named
+ pipe on Windows). If you want to use TCP/IP, use
+ "127.0.0.1" instead of "localhost". If the
+ MySQL client library tries to connect to the wrong local
+ socket, you should set the correct path as
+ <ulink url="http://www.php.net/manual/en/ini.mysql.default-host.php"></ulink>
+ in your PHP configuration and leave the server field blank.
+ </para>
+ </note>
+
+ <note>
+ <para>
+ The link to the server will be closed as soon as the execution
+ of the script ends, unless it's closed earlier by
+ explicitly calling
+ <link linkend="apis-php-function.mysql-close"><function>mysql_close</function></link>.
+ </para>
+ </note>
+
+ <note>
+ <para>
+ You can suppress the error message on failure by prepending a
+ <ulink url="http://www.php.net/manual/en/language.operators.errorcontrol.php">@</ulink>
+ to the function name.
+ </para>
+ </note>
+
+ <note>
+ <para>
+ Error "Can't create TCP/IP socket (10106)"
+ usually means that the
+ <ulink url="http://www.php.net/manual/en/ini.variables-order.php">variables_order</ulink>
+ configure directive doesn't contain character
+ <literal>E</literal>. On Windows, if the environment is not
+ copied the <literal>SYSTEMROOT</literal> environment variable
+ won't be available and PHP will have problems loading
+ Winsock.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-pconnect"><function>mysql_pconnect</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-close"><function>mysql_close</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-create-db">
+
+ <title><literal>mysql_create_db</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_create_db</literal>
+ </para>
+
+ <para>
+ Create a MySQL database
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysql_create_db</methodname>
+ <methodparam>
+ <type>string</type><parameter>database_name</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-create-db"><function>mysql_create_db</function></link>
+ attempts to create a new database on the server associated with
+ the specified link identifier.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>database_name</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The name of the database being created.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-create-db"><function>mysql_create_db</function></link>
+ alternative example</title>
+
+ <para>
+ The function
+ <link linkend="apis-php-function.mysql-create-db"><function>mysql_create_db</function></link>
+ is deprecated. It is preferable to use
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+ to issue a sql <literal>CREATE DATABASE</literal> statement
+ instead.
+ </para>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+
+$sql = 'CREATE DATABASE my_db';
+if (mysql_query($sql, $link)) {
+ echo "Database my_db created successfully\n";
+} else {
+ echo 'Error creating database: ' . mysql_error() . "\n";
+}
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Database my_db created successfully
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_createdb</function>
+ </para>
+ </note>
+
+ <note>
+ <para>
+ This function will not be available if the MySQL extension was
+ built against a MySQL 4.x client library.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-select-db"><function>mysql_select_db</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-data-seek">
+
+ <title><literal>mysql_data_seek</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_data_seek</literal>
+ </para>
+
+ <para>
+ Move internal result pointer
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysql_data_seek</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>row_number</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+ moves the internal row pointer of the MySQL result associated
+ with the specified result identifier to point to the specified
+ row number. The next call to a MySQL fetch function, such as
+ <link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>,
+ would return that row.
+ </para>
+
+ <para>
+ <parameter>row_number</parameter> starts at 0. The
+ <parameter>row_number</parameter> should be a value in the range
+ from 0 to
+ <link linkend="apis-php-function.mysql-num-rows"><function>mysql_num_rows</function></link>
+ - 1. However if the result set is empty
+ (<link linkend="apis-php-function.mysql-num-rows"><function>mysql_num_rows</function></link>
+ == 0), a seek to 0 will fail with a
+ <ulink url="http://www.php.net/manual/en/errorfunc.constants.errorlevels.e-warning.php">E_WARNING</ulink>
+ and
+ <link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+ will return
+
+ <constant>FALSE</constant>
+
+ .
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>row_number</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The desired row number of the new result pointer.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+$db_selected = mysql_select_db('sample_db');
+if (!$db_selected) {
+ die('Could not select database: ' . mysql_error());
+}
+$query = 'SELECT last_name, first_name FROM friends';
+$result = mysql_query($query);
+if (!$result) {
+ die('Query failed: ' . mysql_error());
+}
+/* fetch rows in reverse order */
+for ($i = mysql_num_rows($result) - 1; $i >= 0; $i--) {
+ if (!mysql_data_seek($result, $i)) {
+ echo "Cannot seek to row $i: " . mysql_error() . "\n";
+ continue;
+ }
+
+ if (!($row = mysql_fetch_assoc($result))) {
+ continue;
+ }
+
+ echo $row['last_name'] . ' ' . $row['first_name'] . "<br />\n";
+}
+
+mysql_free_result($result);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ The function
+ <link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+ can be used in conjunction only with
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>,
+ not with
+ <link linkend="apis-php-function.mysql-unbuffered-query"><function>mysql_unbuffered_query</function></link>.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-num-rows"><function>mysql_num_rows</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-object"><function>mysql_fetch_object</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-db-name">
+
+ <title><literal>mysql_db_name</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_db_name</literal>
+ </para>
+
+ <para>
+ Get result data
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_db_name</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>row</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>mixed</type><parameter>field</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Retrieve the database name from a call to
+ <link linkend="apis-php-function.mysql-list-dbs"><function>mysql_list_dbs</function></link>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result pointer from a call to
+ <link linkend="apis-php-function.mysql-list-dbs"><function>mysql_list_dbs</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>row</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The index into the result set.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>field</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The field name.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the database name on success, and
+
+ <constant>FALSE</constant>
+
+ on failure. If
+
+ <constant>FALSE</constant>
+
+ is returned, use
+ <link linkend="apis-php-function.mysql-error"><function>mysql_error</function></link>
+ to determine the nature of the error.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-db-name"><function>mysql_db_name</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+error_reporting(E_ALL);
+
+$link = mysql_connect('dbhost', 'username', 'password');
+$db_list = mysql_list_dbs($link);
+
+$i = 0;
+$cnt = mysql_num_rows($db_list);
+while ($i < $cnt) {
+ echo mysql_db_name($db_list, $i) . "\n";
+ $i++;
+}
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_dbname</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-list-dbs"><function>mysql_list_dbs</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-tablename"><function>mysql_tablename</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-db-query">
+
+ <title><literal>mysql_db_query</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_db_query</literal>
+ </para>
+
+ <para>
+ Send a MySQL query
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>resource</type><methodname>mysql_db_query</methodname>
+ <methodparam>
+ <type>string</type><parameter>database</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>query</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-db-query"><function>mysql_db_query</function></link>
+ selects a database, and executes a query on it.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>database</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The name of the database that will be selected.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>query</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL query.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns a positive MySQL result resource to the query result, or
+
+ <constant>FALSE</constant>
+
+ on error. The function also returns
+
+ <constant>TRUE</constant>
+
+ /
+
+ <constant>FALSE</constant>
+
+ for
+ <literal>INSERT</literal>/<literal>UPDATE</literal>/<literal>DELETE</literal>
+ queries to indicate success/failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">ChangeLog</emphasis>
+ </para>
+
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Version</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>4.0.6</entry>
+ <entry>This function is deprecated, do not use this function. Use
+ <link linkend="apis-php-function.mysql-select-db"><function>mysql_select_db</function></link>
+ and
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+ instead.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-db-query"><function>mysql_db_query</function></link>
+ alternative example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+if (!$link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')) {
+ echo 'Could not connect to mysql';
+ exit;
+}
+
+if (!mysql_select_db('mysql_dbname', $link)) {
+ echo 'Could not select database';
+ exit;
+}
+
+$sql = 'SELECT foo FROM bar WHERE id = 42';
+$result = mysql_query($sql, $link);
+
+if (!$result) {
+ echo "DB Error, could not query the database\n";
+ echo 'MySQL Error: ' . mysql_error();
+ exit;
+}
+
+while ($row = mysql_fetch_assoc($result)) {
+ echo $row['foo'];
+}
+
+mysql_free_result($result);
+
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ Be aware that this function does <emphasis>NOT</emphasis>
+ switch back to the database you were connected before. In
+ other words, you can't use this function to
+ <emphasis>temporarily</emphasis> run a sql query on another
+ database, you would have to manually switch back. Users are
+ strongly encouraged to use the
+ <literal>database.table</literal> syntax in their sql queries
+ or
+ <link linkend="apis-php-function.mysql-select-db"><function>mysql_select_db</function></link>
+ instead of this function.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-select-db"><function>mysql_select_db</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-drop-db">
+
+ <title>faketitle</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_drop_db</literal>
+ </para>
+
+ <para>
+ Drop (delete) a MySQL database
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysql_drop_db</methodname>
+ <methodparam>
+ <type>string</type><parameter>database_name</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-drop-db"><function>mysql_drop_db</function></link>
+ attempts to drop (remove) an entire database from the server
+ associated with the specified link identifier. This function is
+ deprecated, it is preferable to use
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+ to issue a sql <literal>DROP DATABASE</literal> statement
+ instead.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>database_name</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The name of the database that will be deleted.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-drop-db"><function>mysql_drop_db</function></link>
+ alternative example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+
+$sql = 'DROP DATABASE my_db';
+if (mysql_query($sql, $link)) {
+ echo "Database my_db was successfully dropped\n";
+} else {
+ echo 'Error dropping database: ' . mysql_error() . "\n";
+}
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <warning>
+ <para>
+ This function will not be available if the MySQL extension was
+ built against a MySQL 4.x client library.
+ </para>
+ </warning>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_dropdb</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-errno">
+
+ <title><literal>mysql_errno</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_errno</literal>
+ </para>
+
+ <para>
+ Returns the numerical value of the error message from
+ previous MySQL operation
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysql_errno</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the error number from the last MySQL function.
+ </para>
+
+ <para>
+ Errors coming back from the MySQL database backend no longer
+ issue warnings. Instead, use
+ <link linkend="apis-php-function.mysql-errno"><function>mysql_errno</function></link>
+ to retrieve the error code. Note that this function only returns
+ the error code from the most recently executed MySQL function
+ (not including
+ <link linkend="apis-php-function.mysql-error"><function>mysql_error</function></link>
+ and
+ <link linkend="apis-php-function.mysql-errno"><function>mysql_errno</function></link>),
+ so if you want to use it, make sure you check the value before
+ calling another MySQL function.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the error number from the last MySQL function, or
+ <literal>0</literal> (zero) if no error occurred.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-errno"><function>mysql_errno</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect("localhost", "mysql_user", "mysql_password");
+
+if (!mysql_select_db("nonexistentdb", $link)) {
+ echo mysql_errno($link) . ": " . mysql_error($link). "\n";
+}
+
+mysql_select_db("kossu", $link);
+if (!mysql_query("SELECT * FROM nonexistenttable", $link)) {
+ echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
+}
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+1049: Unknown database 'nonexistentdb'
+1146: Table 'kossu.nonexistenttable' doesn't exist
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-error"><function>mysql_error</function></link>
+
+ </member>
+
+ <member><ulink url="http://dev.mysql.com/doc/mysql/en/error-handling.html">MySQL error codes</ulink>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-error">
+
+ <title><literal>mysql_error</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_error</literal>
+ </para>
+
+ <para>
+ Returns the text of the error message from previous MySQL
+ operation
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_error</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the error text from the last MySQL function. Errors
+ coming back from the MySQL database backend no longer issue
+ warnings. Instead, use
+ <link linkend="apis-php-function.mysql-error"><function>mysql_error</function></link>
+ to retrieve the error text. Note that this function only returns
+ the error text from the most recently executed MySQL function
+ (not including
+ <link linkend="apis-php-function.mysql-error"><function>mysql_error</function></link>
+ and
+ <link linkend="apis-php-function.mysql-errno"><function>mysql_errno</function></link>),
+ so if you want to use it, make sure you check the value before
+ calling another MySQL function.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the error text from the last MySQL function, or
+ <literal>''</literal> (empty string) if no error
+ occurred.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-error"><function>mysql_error</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect("localhost", "mysql_user", "mysql_password");
+
+mysql_select_db("nonexistentdb", $link);
+echo mysql_errno($link) . ": " . mysql_error($link). "\n";
+
+mysql_select_db("kossu", $link);
+mysql_query("SELECT * FROM nonexistenttable", $link);
+echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+1049: Unknown database 'nonexistentdb'
+1146: Table 'kossu.nonexistenttable' doesn't exist
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-errno"><function>mysql_errno</function></link>
+
+ </member>
+
+ <member><ulink url="http://dev.mysql.com/doc/mysql/en/error-handling.html">MySQL error codes</ulink>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-escape-string">
+
+ <title><literal>mysql_escape_string</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_escape_string</literal>
+ </para>
+
+ <para>
+ Escapes a string for use in a mysql_query
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_escape_string</methodname>
+ <methodparam>
+ <type>string</type><parameter>unescaped_string</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ This function will escape the
+ <parameter>unescaped_string</parameter>, so that it is safe to
+ place it in a
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ This function is deprecated.
+ </para>
+
+ <para>
+ This function is identical to
+ <link linkend="apis-php-function.mysql-real-escape-string"><function>mysql_real_escape_string</function></link>
+ except that
+ <link linkend="apis-php-function.mysql-real-escape-string"><function>mysql_real_escape_string</function></link>
+ takes a connection handler and escapes the string according to
+ the current character set.
+ <link linkend="apis-php-function.mysql-escape-string"><function>mysql_escape_string</function></link>
+ does not take a connection argument and does not respect the
+ current charset setting.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>unescaped_string</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The string that is to be escaped.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the escaped string.
+ </para>
+
+ <para>
+ <emphasis role="bold">ChangeLog</emphasis>
+ </para>
+
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Version</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>4.3.0</entry>
+ <entry>This function became deprecated, do not use this function. Instead, use
+ <link linkend="apis-php-function.mysql-real-escape-string"><function>mysql_real_escape_string</function></link>.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-escape-string"><function>mysql_escape_string</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$item = "Zak's Laptop";
+$escaped_item = mysql_escape_string($item);
+printf("Escaped string: %s\n", $escaped_item);
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Escaped string: Zak\'s Laptop
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ <link linkend="apis-php-function.mysql-escape-string"><function>mysql_escape_string</function></link>
+ does not escape <literal>%</literal> and <literal>_</literal>.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-real-escape-string"><function>mysql_real_escape_string</function></link>
+
+ </member>
+
+ <member><function>addslashes</function>
+
+ </member>
+
+ <member>The <ulink url="http://www.php.net/manual/en/ini.magic-quotes-gpc.php">magic_quotes_gpc</ulink> directive.</member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-fetch-array">
+
+ <title><literal>mysql_fetch_array</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_fetch_array</literal>
+ </para>
+
+ <para>
+ Fetch a result row as an associative array, a numeric array,
+ or both
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>array</type><methodname>mysql_fetch_array</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>result_type</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns an array that corresponds to the fetched row and moves
+ the internal data pointer ahead.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>result_type</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The type of array that is to be fetched. It's a
+ constant and can take the following values:
+
+ <constant>MYSQL_ASSOC</constant>
+
+ ,
+
+ <constant>MYSQL_NUM</constant>
+
+ , and the default value of
+
+ <constant>MYSQL_BOTH</constant>
+
+ .
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns an array of strings that corresponds to the fetched row,
+ or
+
+ <constant>FALSE</constant>
+
+ if there are no more rows. The type of returned array depends on
+ how <parameter>result_type</parameter> is defined. By using
+
+ <constant>MYSQL_BOTH</constant>
+
+ (default), you'll get an array with both associative and
+ number indices. Using
+
+ <constant>MYSQL_ASSOC</constant>
+
+ , you only get associative indices (as
+ <link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+ works), using
+
+ <constant>MYSQL_NUM</constant>
+
+ , you only get number indices (as
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+ works).
+ </para>
+
+ <para>
+ If two or more columns of the result have the same field names,
+ the last column will take precedence. To access the other
+ column(s) of the same name, you must use the numeric index of
+ the column or make an alias for the column. For aliased columns,
+ you cannot access the contents with the original column name.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>Query with aliased duplicate field names</title>
+
+<programlisting>
+<![CDATA[
+SELECT table1.field AS foo, table2.field AS bar FROM table1, table2
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+ with
+
+ <constant>MYSQL_NUM</constant></title>
+
+<programlisting>
+<![CDATA[
+<?php
+mysql_connect("localhost", "mysql_user", "mysql_password") or
+ die("Could not connect: " . mysql_error());
+mysql_select_db("mydb");
+
+$result = mysql_query("SELECT id, name FROM mytable");
+
+while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
+ printf("ID: %s Name: %s", $row[0], $row[1]);
+}
+
+mysql_free_result($result);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+ with
+
+ <constant>MYSQL_ASSOC</constant></title>
+
+<programlisting>
+<![CDATA[
+<?php
+mysql_connect("localhost", "mysql_user", "mysql_password") or
+ die("Could not connect: " . mysql_error());
+mysql_select_db("mydb");
+
+$result = mysql_query("SELECT id, name FROM mytable");
+
+while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
+ printf("ID: %s Name: %s", $row["id"], $row["name"]);
+}
+
+mysql_free_result($result);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+ with
+
+ <constant>MYSQL_BOTH</constant></title>
+
+<programlisting>
+<![CDATA[
+<?php
+mysql_connect("localhost", "mysql_user", "mysql_password") or
+ die("Could not connect: " . mysql_error());
+mysql_select_db("mydb");
+
+$result = mysql_query("SELECT id, name FROM mytable");
+
+while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
+ printf ("ID: %s Name: %s", $row[0], $row["name"]);
+}
+
+mysql_free_result($result);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <title>Performance</title>
+
+ <para>
+ An important thing to note is that using
+ <link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+ is <emphasis>not significantly</emphasis> slower than using
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>,
+ while it provides a significant added value.
+ </para>
+ </note>
+
+ <note>
+ <simpara>Field names returned by this function
+are <emphasis>case-sensitive</emphasis>.</simpara>
+ </note>
+
+ <note>
+ <simpara>This function sets NULL fields to
+the PHP <constant>NULL</constant> value.</simpara>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-fetch-assoc">
+
+ <title><literal>mysql_fetch_assoc</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_fetch_assoc</literal>
+ </para>
+
+ <para>
+ Fetch a result row as an associative array
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>array</type><methodname>mysql_fetch_assoc</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns an associative array that corresponds to the fetched row
+ and moves the internal data pointer ahead.
+ <link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+ is equivalent to calling
+ <link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+ with MYSQL_ASSOC for the optional second parameter. It only
+ returns an associative array.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns an associative array of strings that corresponds to the
+ fetched row, or
+
+ <constant>FALSE</constant>
+
+ if there are no more rows.
+ </para>
+
+ <para>
+ If two or more columns of the result have the same field names,
+ the last column will take precedence. To access the other
+ column(s) of the same name, you either need to access the result
+ with numeric indices by using
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+ or add alias names. See the example at the
+ <link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+ description about aliases.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>An expanded
+ <link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+$conn = mysql_connect("localhost", "mysql_user", "mysql_password");
+
+if (!$conn) {
+ echo "Unable to connect to DB: " . mysql_error();
+ exit;
+}
+
+if (!mysql_select_db("mydbname")) {
+ echo "Unable to select mydbname: " . mysql_error();
+ exit;
+}
+
+$sql = "SELECT id as userid, fullname, userstatus
+ FROM sometable
+ WHERE userstatus = 1";
+
+$result = mysql_query($sql);
+
+if (!$result) {
+ echo "Could not successfully run query ($sql) from DB: " . mysql_error();
+ exit;
+}
+
+if (mysql_num_rows($result) == 0) {
+ echo "No rows found, nothing to print so am exiting";
+ exit;
+}
+
+// While a row of data exists, put that row in $row as an associative array
+// Note: If you're expecting just one row, no need to use a loop
+// Note: If you put extract($row); inside the following loop, you'll
+// then create $userid, $fullname, and $userstatus
+while ($row = mysql_fetch_assoc($result)) {
+ echo $row["userid"];
+ echo $row["fullname"];
+ echo $row["userstatus"];
+}
+
+mysql_free_result($result);
+
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <title>Performance</title>
+
+ <para>
+ An important thing to note is that using
+ <link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+ is <emphasis>not significantly</emphasis> slower than using
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>,
+ while it provides a significant added value.
+ </para>
+ </note>
+
+ <note>
+ <simpara>Field names returned by this function
+are <emphasis>case-sensitive</emphasis>.</simpara>
+ </note>
+
+ <note>
+ <simpara>This function sets NULL fields to
+the PHP <constant>NULL</constant> value.</simpara>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-error"><function>mysql_error</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-fetch-field">
+
+ <title><literal>mysql_fetch_field</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_fetch_field</literal>
+ </para>
+
+ <para>
+ Get column information from a result and return as an object
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>object</type><methodname>mysql_fetch_field</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>field_offset</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns an object containing field information. This function
+ can be used to obtain information about fields in the provided
+ query result.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>field_offset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The numerical field offset. If the field offset is not
+ specified, the next field that was not yet retrieved by
+ this function is retrieved. The
+ <parameter>field_offset</parameter> starts at
+ <literal>0</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns an <type>object</type> containing field information. The
+ properties of the object are:
+ </para>
+
+ <para>
+ <itemizedlist>
+
+ <listitem>
+ <simpara>
+ name - column name
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ table - name of the table the column belongs to
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ def - default value of the column
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ max_length - maximum length of the column
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ not_null - 1 if the column cannot be <constant>NULL</constant>
+
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ primary_key - 1 if the column is a primary key
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ unique_key - 1 if the column is a unique key
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ multiple_key - 1 if the column is a non-unique key
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ numeric - 1 if the column is numeric
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ blob - 1 if the column is a BLOB
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ type - the type of the column
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ unsigned - 1 if the column is unsigned
+ </simpara>
+ </listitem>
+
+ <listitem>
+ <simpara>
+ zerofill - 1 if the column is zero-filled
+ </simpara>
+ </listitem>
+
+ </itemizedlist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-fetch-field"><function>mysql_fetch_field</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$conn = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$conn) {
+ die('Could not connect: ' . mysql_error());
+}
+mysql_select_db('database');
+$result = mysql_query('select * from table');
+if (!$result) {
+ die('Query failed: ' . mysql_error());
+}
+/* get column metadata */
+$i = 0;
+while ($i < mysql_num_fields($result)) {
+ echo "Information for column $i:<br />\n";
+ $meta = mysql_fetch_field($result, $i);
+ if (!$meta) {
+ echo "No information available<br />\n";
+ }
+ echo "<pre>
+blob: $meta->blob
+max_length: $meta->max_length
+multiple_key: $meta->multiple_key
+name: $meta->name
+not_null: $meta->not_null
+numeric: $meta->numeric
+primary_key: $meta->primary_key
+table: $meta->table
+type: $meta->type
+default: $meta->def
+unique_key: $meta->unique_key
+unsigned: $meta->unsigned
+zerofill: $meta->zerofill
+</pre>";
+ $i++;
+}
+mysql_free_result($result);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <simpara>Field names returned by this function
+are <emphasis>case-sensitive</emphasis>.</simpara>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-field-seek"><function>mysql_field_seek</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-fetch-lengths">
+
+ <title><literal>mysql_fetch_lengths</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_fetch_lengths</literal>
+ </para>
+
+ <para>
+ Get the length of each output in a result
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>array</type><methodname>mysql_fetch_lengths</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns an array that corresponds to the lengths of each field
+ in the last row fetched by MySQL.
+ </para>
+
+ <para>
+ <link linkend="apis-php-function.mysql-fetch-lengths"><function>mysql_fetch_lengths</function></link>
+ stores the lengths of each result column in the last row
+ returned by
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>,
+ <link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>,
+ <link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>,
+ and
+ <link linkend="apis-php-function.mysql-fetch-object"><function>mysql_fetch_object</function></link>
+ in an array, starting at offset 0.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ An <type>array</type> of lengths on success, or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>A
+ <link linkend="apis-php-function.mysql-fetch-lengths"><function>mysql_fetch_lengths</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
+if (!$result) {
+ echo 'Could not run query: ' . mysql_error();
+ exit;
+}
+$row = mysql_fetch_assoc($result);
+$lengths = mysql_fetch_lengths($result);
+
+print_r($row);
+print_r($lengths);
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Array
+(
+ [id] => 42
+ [email] => user@stripped
+)
+Array
+(
+ [0] => 2
+ [1] => 16
+)
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-field-len"><function>mysql_field_len</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+
+ </member>
+
+ <member><function>strlen</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-fetch-object">
+
+ <title><literal>mysql_fetch_object</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_fetch_object</literal>
+ </para>
+
+ <para>
+ Fetch a result row as an object
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>object</type><methodname>mysql_fetch_object</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>class_name</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>array</type><parameter>params</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns an object with properties that correspond to the fetched
+ row and moves the internal data pointer ahead.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>class_name</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The name of the class to instantiate, set the properties
+ of and return. If not specified, a
+ <classname>stdClass</classname> object is returned.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>params</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ An optional <type>array</type> of parameters to pass to
+ the constructor for <parameter>class_name</parameter>
+ objects.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns an <type>object</type> with string properties that
+ correspond to the fetched row, or
+
+ <constant>FALSE</constant>
+
+ if there are no more rows.
+ </para>
+
+ <para>
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+ fetches one row of data from the result associated with the
+ specified result identifier. The row is returned as an array.
+ Each result column is stored in an array offset, starting at
+ offset 0.
+ </para>
+
+ <para>
+ <emphasis role="bold">ChangeLog</emphasis>
+ </para>
+
+ <para>
+ <informaltable>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Version</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>5.0.0</entry>
+ <entry>Added the ability to return as a different object.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-fetch-object"><function>mysql_fetch_object</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+mysql_connect("hostname", "user", "password");
+mysql_select_db("mydb");
+$result = mysql_query("select * from mytable");
+while ($row = mysql_fetch_object($result)) {
+ echo $row->user_id;
+ echo $row->fullname;
+}
+mysql_free_result($result);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-fetch-object"><function>mysql_fetch_object</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+class foo {
+ public $name;
+}
+
+mysql_connect("hostname", "user", "password");
+mysql_select_db("mydb");
+
+$result = mysql_query("select name from mytable limit 1");
+$obj = mysql_fetch_object($result, 'foo');
+var_dump($obj);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <title>Performance</title>
+
+ <para>
+ Speed-wise, the function is identical to
+ <link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>,
+ and almost as quick as
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+ (the difference is insignificant).
+ </para>
+ </note>
+
+ <note>
+ <para>
+ <link linkend="apis-php-function.mysql-fetch-object"><function>mysql_fetch_object</function></link>
+ is similar to
+ <link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>,
+ with one difference - an object is returned, instead of an
+ array. Indirectly, that means that you can only access the
+ data by the field names, and not by their offsets (numbers are
+ illegal property names).
+ </para>
+ </note>
+
+ <note>
+ <simpara>Field names returned by this function
+are <emphasis>case-sensitive</emphasis>.</simpara>
+ </note>
+
+ <note>
+ <simpara>This function sets NULL fields to
+the PHP <constant>NULL</constant> value.</simpara>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-fetch-row">
+
+ <title><literal>mysql_fetch_row</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_fetch_row</literal>
+ </para>
+
+ <para>
+ Get a result row as an enumerated array
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>array</type><methodname>mysql_fetch_row</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns a numerical array that corresponds to the fetched row
+ and moves the internal data pointer ahead.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns an numerical array of strings that corresponds to the
+ fetched row, or
+
+ <constant>FALSE</constant>
+
+ if there are no more rows.
+ </para>
+
+ <para>
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link>
+ fetches one row of data from the result associated with the
+ specified result identifier. The row is returned as an array.
+ Each result column is stored in an array offset, starting at
+ offset 0.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>Fetching one row with
+ <link linkend="apis-php-function.mysql-fetch-row"><function>mysql_fetch_row</function></link></title>
+
+<programlisting>
+<![CDATA[
+<?php
+$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
+if (!$result) {
+ echo 'Could not run query: ' . mysql_error();
+ exit;
+}
+$row = mysql_fetch_row($result);
+
+echo $row[0]; // 42
+echo $row[1]; // the email value
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <simpara>This function sets NULL fields to
+the PHP <constant>NULL</constant> value.</simpara>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-fetch-array"><function>mysql_fetch_array</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-assoc"><function>mysql_fetch_assoc</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-object"><function>mysql_fetch_object</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-data-seek"><function>mysql_data_seek</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-fetch-lengths"><function>mysql_fetch_lengths</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-result"><function>mysql_result</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-field-flags">
+
+ <title><literal>mysql_field_flags</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_field_flags</literal>
+ </para>
+
+ <para>
+ Get the flags associated with the specified field in a
+ result
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_field_flags</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>field_offset</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-field-flags"><function>mysql_field_flags</function></link>
+ returns the field flags of the specified field. The flags are
+ reported as a single word per flag separated by a single space,
+ so that you can split the returned value using
+ <function>explode</function>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> field_offset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The numerical field offset. The
+ <parameter>field_offset</parameter> starts at
+ <literal>0</literal>. If
+ <parameter>field_offset</parameter> does not exist, an
+ error of level
+
+ <constant>E_WARNING</constant>
+
+ is also issued.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns a string of flags associated with the result, or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ The following flags are reported, if your version of MySQL is
+ current enough to support them:
+ <literal>"not_null"</literal>,
+ <literal>"primary_key"</literal>,
+ <literal>"unique_key"</literal>,
+ <literal>"multiple_key"</literal>,
+ <literal>"blob"</literal>,
+ <literal>"unsigned"</literal>,
+ <literal>"zerofill"</literal>,
+ <literal>"binary"</literal>,
+ <literal>"enum"</literal>,
+ <literal>"auto_increment"</literal> and
+ <literal>"timestamp"</literal>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>A
+ <link linkend="apis-php-function.mysql-field-flags"><function>mysql_field_flags</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
+if (!$result) {
+ echo 'Could not run query: ' . mysql_error();
+ exit;
+}
+$flags = mysql_field_flags($result, 0);
+
+echo $flags;
+print_r(explode(' ', $flags));
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+not_null primary_key auto_increment
+Array
+(
+ [0] => not_null
+ [1] => primary_key
+ [2] => auto_increment
+)
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_fieldflags</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-field-type"><function>mysql_field_type</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-field-len"><function>mysql_field_len</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-field-len">
+
+ <title><literal>mysql_field_len</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_field_len</literal>
+ </para>
+
+ <para>
+ Returns the length of the specified field
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysql_field_len</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>field_offset</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-field-len"><function>mysql_field_len</function></link>
+ returns the length of the specified field.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> field_offset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The numerical field offset. The
+ <parameter>field_offset</parameter> starts at
+ <literal>0</literal>. If
+ <parameter>field_offset</parameter> does not exist, an
+ error of level
+
+ <constant>E_WARNING</constant>
+
+ is also issued.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ The length of the specified field index on success, or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-field-len"><function>mysql_field_len</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
+if (!$result) {
+ echo 'Could not run query: ' . mysql_error();
+ exit;
+}
+
+// Will get the length of the id field as specified in the database
+// schema.
+$length = mysql_field_len($result, 0);
+echo $length;
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_fieldlen</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-fetch-lengths"><function>mysql_fetch_lengths</function></link>
+
+ </member>
+
+ <member><function>strlen</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-field-name">
+
+ <title><literal>mysql_field_name</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_field_name</literal>
+ </para>
+
+ <para>
+ Get the name of the specified field in a result
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_field_name</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>field_offset</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-field-name"><function>mysql_field_name</function></link>
+ returns the name of the specified field index.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> field_offset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The numerical field offset. The
+ <parameter>field_offset</parameter> starts at
+ <literal>0</literal>. If
+ <parameter>field_offset</parameter> does not exist, an
+ error of level
+
+ <constant>E_WARNING</constant>
+
+ is also issued.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ The name of the specified field index on success, or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-field-name"><function>mysql_field_name</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+/* The users table consists of three fields:
+* user_id
+* username
+* password.
+*/
+$link = @mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect to MySQL server: ' . mysql_error());
+}
+$dbname = 'mydb';
+$db_selected = mysql_select_db($dbname, $link);
+if (!$db_selected) {
+ die("Could not set $dbname: " . mysql_error());
+}
+$res = mysql_query('select * from users', $link);
+
+echo mysql_field_name($res, 0) . "\n";
+echo mysql_field_name($res, 2);
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+user_id
+password
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <simpara>Field names returned by this function
+are <emphasis>case-sensitive</emphasis>.</simpara>
+ </note>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_fieldname</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-field-type"><function>mysql_field_type</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-field-len"><function>mysql_field_len</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-field-seek">
+
+ <title><literal>mysql_field_seek</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_field_seek</literal>
+ </para>
+
+ <para>
+ Set result pointer to a specified field offset
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysql_field_seek</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>field_offset</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Seeks to the specified field offset. If the next call to
+ <link linkend="apis-php-function.mysql-fetch-field"><function>mysql_fetch_field</function></link>
+ doesn't include a field offset, the field offset specified
+ in
+ <link linkend="apis-php-function.mysql-field-seek"><function>mysql_field_seek</function></link>
+ will be returned.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> field_offset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The numerical field offset. The
+ <parameter>field_offset</parameter> starts at
+ <literal>0</literal>. If
+ <parameter>field_offset</parameter> does not exist, an
+ error of level
+
+ <constant>E_WARNING</constant>
+
+ is also issued.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-fetch-field"><function>mysql_fetch_field</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-field-table">
+
+ <title><literal>mysql_field_table</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_field_table</literal>
+ </para>
+
+ <para>
+ Get name of the table the specified field is in
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_field_table</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>field_offset</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the name of the table that the specified field is in.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> field_offset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The numerical field offset. The
+ <parameter>field_offset</parameter> starts at
+ <literal>0</literal>. If
+ <parameter>field_offset</parameter> does not exist, an
+ error of level
+
+ <constant>E_WARNING</constant>
+
+ is also issued.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ The name of the table on success.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>A
+ <link linkend="apis-php-function.mysql-field-table"><function>mysql_field_table</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+$query = "SELECT account.*, country.* FROM account, country WHERE country.name = 'Portugal' AND account.country_id = country.id";
+
+// get the result from the DB
+$result = mysql_query($query);
+
+// Lists the table name and then the field name
+for ($i = 0; $i < mysql_num_fields($result); ++$i) {
+ $table = mysql_field_table($result, $i);
+ $field = mysql_field_name($result, $i);
+
+ echo "$table: $field\n";
+}
+
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_fieldtable</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-list-tables"><function>mysql_list_tables</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-field-type">
+
+ <title><literal>mysql_field_type</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_field_type</literal>
+ </para>
+
+ <para>
+ Get the type of the specified field in a result
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_field_type</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>field_offset</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-field-type"><function>mysql_field_type</function></link>
+ is similar to the
+ <link linkend="apis-php-function.mysql-field-name"><function>mysql_field_name</function></link>
+ function. The arguments are identical, but the field type is
+ returned instead.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter> field_offset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The numerical field offset. The
+ <parameter>field_offset</parameter> starts at
+ <literal>0</literal>. If
+ <parameter>field_offset</parameter> does not exist, an
+ error of level
+
+ <constant>E_WARNING</constant>
+
+ is also issued.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ The returned field type will be one of
+ <literal>"int"</literal>,
+ <literal>"real"</literal>,
+ <literal>"string"</literal>,
+ <literal>"blob"</literal>, and others as detailed in
+ the <ulink url="http://dev.mysql.com/doc/">MySQL
+ documentation</ulink>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-field-type"><function>mysql_field_type</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+mysql_connect("localhost", "mysql_username", "mysql_password");
+mysql_select_db("mysql");
+$result = mysql_query("SELECT * FROM func");
+$fields = mysql_num_fields($result);
+$rows = mysql_num_rows($result);
+$table = mysql_field_table($result, 0);
+echo "Your '" . $table . "' table has " . $fields . " fields and " . $rows . " record(s)\n";
+echo "The table has the following fields:\n";
+for ($i=0; $i < $fields; $i++) {
+ $type = mysql_field_type($result, $i);
+ $name = mysql_field_name($result, $i);
+ $len = mysql_field_len($result, $i);
+ $flags = mysql_field_flags($result, $i);
+ echo $type . " " . $name . " " . $len . " " . $flags . "\n";
+}
+mysql_free_result($result);
+mysql_close();
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Your 'func' table has 4 fields and 1 record(s)
+The table has the following fields:
+string name 64 not_null primary_key binary
+int ret 1 not_null
+string dl 128 not_null
+string type 9 not_null enum
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_fieldtype</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-field-name"><function>mysql_field_name</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-field-len"><function>mysql_field_len</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-free-result">
+
+ <title><literal>mysql_free_result</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_free_result</literal>
+ </para>
+
+ <para>
+ Free result memory
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysql_free_result</methodname>
+ <methodparam>
+ <type>resource</type><parameter>result</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-free-result"><function>mysql_free_result</function></link>
+ will free all memory associated with the result identifier
+ <parameter>result</parameter>.
+ </para>
+
+ <para>
+ <link linkend="apis-php-function.mysql-free-result"><function>mysql_free_result</function></link>
+ only needs to be called if you are concerned about how much
+ memory is being used for queries that return large result sets.
+ All associated result memory is automatically freed at the end
+ of the script's execution.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> result</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The result <type>resource</type> that is being
+ evaluated. This result comes from a call to
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ If a non-resource is used for the <parameter>result</parameter>,
+ an error of level E_WARNING will be emitted. It's worth
+ noting that
+ <link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+ only returns a <type>resource</type> for SELECT, SHOW, EXPLAIN,
+ and DESCRIBE queries.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>A
+ <link linkend="apis-php-function.mysql-free-result"><function>mysql_free_result</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$result = mysql_query("SELECT id,email FROM people WHERE id = '42'");
+if (!$result) {
+ echo 'Could not run query: ' . mysql_error();
+ exit;
+}
+/* Use the result, assuming we're done with it afterwards */
+$row = mysql_fetch_assoc($result);
+
+/* Now we free up the result and continue on with our script */
+mysql_free_result($result);
+
+echo $row['id'];
+echo $row['email'];
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ For backward compatibility, the following deprecated alias may
+ be used: <function>mysql_freeresult</function>
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-query"><function>mysql_query</function></link>
+
+ </member>
+
+ <member><function>is_resource</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-get-client-info">
+
+ <title><literal>mysql_get_client_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_get_client_info</literal>
+ </para>
+
+ <para>
+ Get MySQL client info
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_get_client_info</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ <link linkend="apis-php-function.mysql-get-client-info"><function>mysql_get_client_info</function></link>
+ returns a string that represents the client library version.
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ The MySQL client version.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-get-client-info"><function>mysql_get_client_info</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+printf("MySQL client info: %s\n", mysql_get_client_info());
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+MySQL client info: 3.23.39
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-get-host-info"><function>mysql_get_host_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-proto-info"><function>mysql_get_proto_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-server-info"><function>mysql_get_server_info</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-get-host-info">
+
+ <title><literal>mysql_get_host_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_get_host_info</literal>
+ </para>
+
+ <para>
+ Get MySQL host info
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_get_host_info</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Describes the type of connection in use for the connection,
+ including the server host name.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns a string describing the type of MySQL connection in use
+ for the connection or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-get-host-info"><function>mysql_get_host_info</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+printf("MySQL host info: %s\n", mysql_get_host_info());
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+MySQL host info: Localhost via UNIX socket
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-get-client-info"><function>mysql_get_client_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-proto-info"><function>mysql_get_proto_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-server-info"><function>mysql_get_server_info</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-get-proto-info">
+
+ <title><literal>mysql_get_proto_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_get_proto_info</literal>
+ </para>
+
+ <para>
+ Get MySQL protocol info
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysql_get_proto_info</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Retrieves the MySQL protocol.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the MySQL protocol on success, or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-get-proto-info"><function>mysql_get_proto_info</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+printf("MySQL protocol version: %s\n", mysql_get_proto_info());
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+MySQL protocol version: 10
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-get-client-info"><function>mysql_get_client_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-host-info"><function>mysql_get_host_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-server-info"><function>mysql_get_server_info</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-get-server-info">
+
+ <title><literal>mysql_get_server_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_get_server_info</literal>
+ </para>
+
+ <para>
+ Get MySQL server info
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_get_server_info</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Retrieves the MySQL server version.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns the MySQL server version on success, or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><link linkend="apis-php-function.mysql-get-server-info"><function>mysql_get_server_info</function></link>
+ example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
+if (!$link) {
+ die('Could not connect: ' . mysql_error());
+}
+printf("MySQL server version: %s\n", mysql_get_server_info());
+?>
+]]>
+ </programlisting>
+
+ <para>
+ The above example will output something similar to:
+ </para>
+
+ <screen>
+
+<![CDATA[
+MySQL server version: 4.0.1-alpha
+]]>
+
+ </screen>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-function.mysql-get-client-info"><function>mysql_get_client_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-host-info"><function>mysql_get_host_info</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-function.mysql-get-proto-info"><function>mysql_get_proto_info</function></link>
+
+ </member>
+
+ <member><function>phpversion</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-function.mysql-info">
+
+ <title><literal>mysql_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysql_info</literal>
+ </para>
+
+ <para>
+ Get information about the most recent query
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysql_info</methodname>
+ <methodparam>
+ <type>resource</type><parameter>link_identifier</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns detailed information about the last query.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link_identifier</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL connection. If the link identifier is not
+ specified, the last link opened by
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ is assumed. If no such link is found, it will try to
+ create one as if
+ <link linkend="apis-php-function.mysql-connect"><function>mysql_connect</function></link>
+ was called with no arguments. If by chance no connection
+ is found or established, an
+
+ <constant>E_WARNING</constant>
+
+ level error is generated.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns information about the statement on success, or
+
+ <constant>FALSE</constant>
+
+ on failure. See the example below for which statements provide
+ information, and what the returned value may look like.
+ Statements that are not listed will return
+
+ <constant>FALSE</constant>
+
+ .
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>Relevant MySQL Statements</title>
+
+ <para>
+ Statements that return string values. The numbers are only
+ for illustrating purpose; their values will correspond to
+ the query.
+ </para>
+
+<programlisting>
+<![CDATA[
+INSERT INTO ... SELECT ...
+String format: Records: 23 Duplicates: 0 Warnings: 0
+INSERT INTO ... VALUES (...),(...),(...)...
+String format: Records: 37 Duplicates: 0 Warnings: 0
+LOAD DATA INFILE ...
Added: trunk/refman-common/apis-php-mysqli.xml
===================================================================
--- trunk/refman-common/apis-php-mysqli.xml (rev 0)
+++ trunk/refman-common/apis-php-mysqli.xml 2008-08-14 16:28:29 UTC (rev 11561)
Changed blocks: 1, Lines Added: 5491, Lines Deleted: 0; 134202 bytes
@@ -0,0 +1,20860 @@
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+<section id="apis-php-mysqli">
+
+ <title>MySQL Improved Extension (<literal>Mysqli</literal>)</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <para>
+ The mysqli extension allows you to access the functionality provided
+ by MySQL 4.1 and above. More information about the MySQL Database
+ server can be found at
+ <ulink url="http://www.mysql.com/">http://www.mysql.com/</ulink>
+ </para>
+
+ <para>
+ Documentation for MySQL can be found at
+ <ulink url="http://dev.mysql.com/doc/">http://dev.mysql.com/doc/</ulink>.
+ </para>
+
+ <para>
+ Parts of this documentation included from MySQL manual with
+ permissions of MySQL AB.
+ </para>
+
+ <section id="apis-php-mysqli.examples">
+
+ <title>Examples</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <para>
+ All Examples in the MySQLI documentation use the world database
+ from MySQL AB. The world database can be found at
+ <ulink url="http://dev.mysql.com/get/Downloads/Manual/world.sql.gz/from/pick">http://dev.mysql.com/get/Downloads/Manual/world.sql.gz/from/pick</ulink>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.setup">
+
+ <title>Installing/Configuring</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <section id="apis-php-mysqli.requirements">
+
+ <title>Requirements</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ In order to have these functions available, you must compile PHP
+ with support for the mysqli extension.
+ </para>
+
+ <note>
+ <para>
+ The mysqli extension is designed to work with the version
+ 4.1.3 or above of MySQL. For previous versions, please see the
+ <link linkend="apis-php-mysql">MySQL</link> extension
+ documentation.
+ </para>
+ </note>
+
+ </section>
+
+ <section id="apis-php-mysqli.installation">
+
+ <title>Installation</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <para id="apis-php-mysqli.configure">
+ To install the mysqli extension for PHP, use the
+ <option>--with-mysqli=mysql_config_path/mysql_config</option>
+ configuration option where <literal>mysql_config_path</literal>
+ represents the location of the <literal>mysql_config</literal>
+ program that comes with MySQL versions greater than 4.1.
+ </para>
+
+ <para>
+ If you would like to install the mysql extension along with the
+ mysqli extension you have to use the same client library to
+ avoid any conflicts.
+ </para>
+
+ <section id="apis-php-mysqli.installation.windows">
+
+ <title>Installation on Windows Systems</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ MySQLi is not enabled by default, so the
+ <filename>php_mysqli.dll</filename> DLL must be enabled inside
+ of <filename>php.ini</filename>. Also, PHP needs access to the
+ MySQL client library. A file named
+ <filename>libmysql.dll</filename> is included in the Windows
+ PHP distribution and in order for PHP to talk to MySQL this
+ file needs to be available to the Windows systems
+ <envar>PATH</envar>. See the FAQ titled
+ "<ulink url="http://www.php.net/manual/en/faq.installation.addtopath.php">How
+ do I add my PHP directory to the PATH on Windows</ulink>"
+ for information on how to do this. Although copying
+ <filename>libmysql.dll</filename> to the Windows system
+ directory also works (because the system directory is by
+ default in the system's <envar>PATH</envar>), it's
+ not recommended.
+ </para>
+
+ <para>
+ As with enabling any PHP extension (such as
+ <filename>php_mysqli.dll</filename>), the PHP directive
+ <ulink url="http://www.php.net/manual/en/ini.extension-dir.php">extension_dir</ulink>
+ should be set to the directory where the PHP extensions are
+ located. See also the
+ <ulink url="http://www.php.net/manual/en/install.windows.manual.php">Manual
+ Windows Installation Instructions</ulink>. An example
+ extension_dir value for PHP 5 is <literal>c:\php\ext</literal>
+ </para>
+
+ <note>
+ <para>
+ If when starting the web server an error similar to the
+ following occurs: <literal>"Unable to load dynamic
+ library './php_mysqli.dll'"</literal>, this
+ is because <filename>php_mysqli.dll</filename> and/or
+ <filename>libmysql.dll</filename> cannot be found by the
+ system.
+ </para>
+ </note>
+
+ </section>
+
+ </section>
+
+ <section id="apis-php-mysqli.configuration">
+
+ <title>Runtime Configuration</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <simpara>
+The behaviour of these functions is affected by settings in <filename>php.ini</filename>.
+</simpara>
+
+ <para>
+ <table>
+ <title>MySQLi Configuration Options</title>
+ <tgroup cols="4">
+ <colspec colwidth="25*"/>
+ <colspec colwidth="25*"/>
+ <colspec colwidth="25*"/>
+ <colspec colwidth="25*"/>
+ <thead>
+ <row>
+ <entry>Name</entry>
+ <entry>Default</entry>
+ <entry>Changeable</entry>
+ <entry>Changelog</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>mysqli.max_links</entry>
+ <entry>"-1"</entry>
+ <entry>PHP_INI_SYSTEM</entry>
+ <entry>Available since PHP 5.0.0.</entry>
+ </row>
+ <row>
+ <entry>mysqli.default_port</entry>
+ <entry>"3306"</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>Available since PHP 5.0.0.</entry>
+ </row>
+ <row>
+ <entry>mysqli.default_socket</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>Available since PHP 5.0.0.</entry>
+ </row>
+ <row>
+ <entry>mysqli.default_host</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>Available since PHP 5.0.0.</entry>
+ </row>
+ <row>
+ <entry>mysqli.default_user</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>Available since PHP 5.0.0.</entry>
+ </row>
+ <row>
+ <entry>mysqli.default_pw</entry>
+ <entry>NULL</entry>
+ <entry>PHP_INI_ALL</entry>
+ <entry>Available since PHP 5.0.0.</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </para>
+
+ <para>
+ For further details and definitions of the above PHP_INI_*
+ constants, see the chapter on
+ <ulink url="http://www.php.net/manual/en/configuration.changes.php">configuration
+ changes</ulink>.
+ </para>
+
+ <para>
+ Here's a short explanation of the configuration directives.
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry id="apis-php-ini.mysqli.max-links">
+ <term>
+ <parameter>mysqli.max_links</parameter>
+ <type>integer</type>
+ </term>
+
+ <listitem>
+ <para>
+ The maximum number of MySQL connections per process.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysqli.default-port">
+ <term>
+ <parameter>mysqli.default_port</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default TCP port number to use when connecting to
+ the database server if no other port is specified. If no
+ default is specified, the port will be obtained from the
+ <literal>MYSQL_TCP_PORT</literal> environment variable,
+ the <literal>mysql-tcp</literal> entry in
+ <filename>/etc/services</filename> or the compile-time
+ <literal>MYSQL_PORT</literal> constant, in that order.
+ Win32 will only use the <literal>MYSQL_PORT</literal>
+ constant.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysqli.default-socket">
+ <term>
+ <parameter>mysqli.default_socket</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default socket name to use when connecting to a
+ local database server if no other socket name is
+ specified.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysqli.default-host">
+ <term>
+ <parameter>mysqli.default_host</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default server host to use when connecting to the
+ database server if no other host is specified.
+ Doesn't apply in
+ <ulink url="http://www.php.net/manual/en/ini.safe-mode.php">safe
+ mode</ulink>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysqli.default-user">
+ <term>
+ <parameter>mysqli.default_user</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default user name to use when connecting to the
+ database server if no other name is specified.
+ Doesn't apply in
+ <ulink url="http://www.php.net/manual/en/ini.safe-mode.php">safe
+ mode</ulink>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-ini.mysqli.default-pw">
+ <term>
+ <parameter>mysqli.default_pw</parameter>
+ <type>string</type>
+ </term>
+
+ <listitem>
+ <para>
+ The default password to use when connecting to the
+ database server if no other password is specified.
+ Doesn't apply in
+ <ulink url="http://www.php.net/manual/en/ini.safe-mode.php">safe
+ mode</ulink>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.resources">
+
+ <title>Resource Types</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <para>
+ This extension has no resource types defined.
+ </para>
+
+ </section>
+
+ </section>
+
+ <section id="apis-php-mysqli.constants">
+
+ <title>Predefined Constants</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <variablelist>
+
+ <varlistentry id="apis-php-constantmysqli-read-default-group">
+ <term>
+ <constant>MYSQLI_READ_DEFAULT_GROUP</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Read options from the named group from
+ <filename>my.cnf</filename> or the file specified with
+
+ <constant>MYSQLI_READ_DEFAULT_FILE</constant>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-read-default-file">
+ <term>
+ <constant>MYSQLI_READ_DEFAULT_FILE</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Read options from the named option file instead of from
+ <filename>my.cnf</filename>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-opt-connect-timeout">
+ <term>
+ <constant>MYSQLI_OPT_CONNECT_TIMEOUT</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Connect timeout in seconds
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-opt-local-infile">
+ <term>
+ <constant>MYSQLI_OPT_LOCAL_INFILE</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Enables command <literal>LOAD LOCAL INFILE</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-init-command">
+ <term>
+ <constant>MYSQLI_INIT_COMMAND</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Command to execute when connecting to MySQL server. Will
+ automatically be re-executed when reconnecting.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-client-ssl">
+ <term>
+ <constant>MYSQLI_CLIENT_SSL</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Use SSL (encrypted protocol). This option should not be set
+ by application programs; it is set internally in the MySQL
+ client library
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-client-compress">
+ <term>
+ <constant>MYSQLI_CLIENT_COMPRESS</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Use compression protocol
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-client-interactive">
+ <term>
+ <constant>MYSQLI_CLIENT_INTERACTIVE</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Allow interactive_timeout seconds (instead of wait_timeout
+ seconds) of inactivity before closing the connection. The
+ client's session wait_timeout variable will be set to
+ the value of the session interactive_timeout variable.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-client-ignore-space">
+ <term>
+ <constant>MYSQLI_CLIENT_IGNORE_SPACE</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Allow spaces after function names. Makes all functions names
+ reserved words.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-client-no-schema">
+ <term>
+ <constant>MYSQLI_CLIENT_NO_SCHEMA</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Don't allow the
+ <literal>db_name.tbl_name.col_name</literal> syntax.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-client-multi-queries">
+ <term>
+ <constant>MYSQLI_CLIENT_MULTI_QUERIES</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Allows multiple semicolon-delimited queries in a single
+ <link linkend="apis-php-mysqli.query"><function>mysqli_query</function></link>
+ call.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-store-result">
+ <term>
+ <constant>MYSQLI_STORE_RESULT</constant>
+ </term>
+
+ <listitem>
+ <para>
+ For using buffered resultsets
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-use-result">
+ <term>
+ <constant>MYSQLI_USE_RESULT</constant>
+ </term>
+
+ <listitem>
+ <para>
+ For using unbuffered resultsets
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-assoc">
+ <term>
+ <constant>MYSQLI_ASSOC</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Columns are returned into the array having the fieldname as
+ the array index.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-num">
+ <term>
+ <constant>MYSQLI_NUM</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Columns are returned into the array having an enumerated
+ index.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-both">
+ <term>
+ <constant>MYSQLI_BOTH</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Columns are returned into the array having both a numerical
+ index and the fieldname as the associative index.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-not-null-flag">
+ <term>
+ <constant>MYSQLI_NOT_NULL_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Indicates that a field is defined as <literal>NOT
+ NULL</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-pri-key-flag">
+ <term>
+ <constant>MYSQLI_PRI_KEY_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is part of a primary index
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-unique-key-flag">
+ <term>
+ <constant>MYSQLI_UNIQUE_KEY_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is part of a unique index.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-multiple-key-flag">
+ <term>
+ <constant>MYSQLI_MULTIPLE_KEY_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is part of an index.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-blob-flag">
+ <term>
+ <constant>MYSQLI_BLOB_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>BLOB</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-unsigned-flag">
+ <term>
+ <constant>MYSQLI_UNSIGNED_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>UNSIGNED</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-zerofill-flag">
+ <term>
+ <constant>MYSQLI_ZEROFILL_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>ZEROFILL</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-auto-increment-flag">
+ <term>
+ <constant>MYSQLI_AUTO_INCREMENT_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>AUTO_INCREMENT</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-timestamp-flag">
+ <term>
+ <constant>MYSQLI_TIMESTAMP_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>TIMESTAMP</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-set-flag">
+ <term>
+ <constant>MYSQLI_SET_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>SET</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-num-flag">
+ <term>
+ <constant>MYSQLI_NUM_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>NUMERIC</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-part-key-flag">
+ <term>
+ <constant>MYSQLI_PART_KEY_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is part of an multi-index
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-group-flag">
+ <term>
+ <constant>MYSQLI_GROUP_FLAG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is part of <literal>GROUP BY</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-decimal">
+ <term>
+ <constant>MYSQLI_TYPE_DECIMAL</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>DECIMAL</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-newdecimal">
+ <term>
+ <constant>MYSQLI_TYPE_NEWDECIMAL</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Precision math <literal>DECIMAL</literal> or
+ <literal>NUMERIC</literal> field (MySQL 5.0.3 and up)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-bit">
+ <term>
+ <constant>MYSQLI_TYPE_BIT</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>BIT</literal> (MySQL 5.0.3 and
+ up)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-tiny">
+ <term>
+ <constant>MYSQLI_TYPE_TINY</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>TINYINT</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-short">
+ <term>
+ <constant>MYSQLI_TYPE_SHORT</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>INT</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-long">
+ <term>
+ <constant>MYSQLI_TYPE_LONG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>INT</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-fload">
+ <term>
+ <constant>MYSQLI_TYPE_FLOAT</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>FLOAT</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-double">
+ <term>
+ <constant>MYSQLI_TYPE_DOUBLE</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>DOUBLE</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-null">
+ <term>
+ <constant>MYSQLI_TYPE_NULL</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>DEFAULT NULL</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-timestamp">
+ <term>
+ <constant>MYSQLI_TYPE_TIMESTAMP</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>TIMESTAMP</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-longlong">
+ <term>
+ <constant>MYSQLI_TYPE_LONGLONG</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>BIGINT</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-int24">
+ <term>
+ <constant>MYSQLI_TYPE_INT24</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>MEDIUMINT</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-date">
+ <term>
+ <constant>MYSQLI_TYPE_DATE</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>DATE</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-time">
+ <term>
+ <constant>MYSQLI_TYPE_TIME</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>TIME</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-datetime">
+ <term>
+ <constant>MYSQLI_TYPE_DATETIME</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>DATETIME</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-year">
+ <term>
+ <constant>MYSQLI_TYPE_YEAR</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>YEAR</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-newdate">
+ <term>
+ <constant>MYSQLI_TYPE_NEWDATE</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>DATE</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-enum">
+ <term>
+ <constant>MYSQLI_TYPE_ENUM</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>ENUM</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-set">
+ <term>
+ <constant>MYSQLI_TYPE_SET</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>SET</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-tiny-blob">
+ <term>
+ <constant>MYSQLI_TYPE_TINY_BLOB</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>TINYBLOB</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-medium-blob">
+ <term>
+ <constant>MYSQLI_TYPE_MEDIUM_BLOB</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>MEDIUMBLOB</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-long-blob">
+ <term>
+ <constant>MYSQLI_TYPE_LONG_BLOB</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>LONGBLOB</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-blob">
+ <term>
+ <constant>MYSQLI_TYPE_BLOB</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>BLOB</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-string">
+ <term>
+ <constant>MYSQLI_TYPE_VAR_STRING</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>VARCHAR</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-char">
+ <term>
+ <constant>MYSQLI_TYPE_STRING</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>CHAR</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-type-geometry">
+ <term>
+ <constant>MYSQLI_TYPE_GEOMETRY</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Field is defined as <literal>GEOMETRY</literal>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-need-data">
+ <term>
+ <constant>MYSQLI_NEED_DATA</constant>
+ </term>
+
+ <listitem>
+ <para>
+ More data available for bind variable
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-no-data">
+ <term>
+ <constant>MYSQLI_NO_DATA</constant>
+ </term>
+
+ <listitem>
+ <para>
+ No more data available for bind variable
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry id="apis-php-constantmysqli-data-truncated">
+ <term>
+ <constant>MYSQLI_DATA_TRUNCATED</constant>
+ </term>
+
+ <listitem>
+ <para>
+ Data truncation occurred. Available since PHP 5.1.0 and
+ MySQL 5.0.5.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ </section>
+
+ <section id="apis-php-class.mysqli">
+
+ <title>The MySQLi class</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <para>
+ Represents a connection between PHP and a MySQL database.
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>MySQLi</classname></ooclass>
+ <classsynopsisinfo><ooclass><classname>MySQLi</classname></ooclass>
+
+ </classsynopsisinfo>
+ <classsynopsisinfo>Properties</classsynopsisinfo>
+ <fieldsynopsis>
+ <type>int</type><varname>affected_rows</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>connect_errno</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>connect_error</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>int</type><varname>errno</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>error</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>int</type><varname>field_count</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>host_info</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>protocol_version</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>server_info</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>int</type><varname>server_version</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>info</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>int</type><varname>insert_id</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>string</type><varname>sqlstate</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>int</type><varname>thread_id</varname>
+ </fieldsynopsis>
+ <fieldsynopsis>
+ <type>int</type><varname>warning_count</varname>
+ </fieldsynopsis>
+ <classsynopsisinfo>Methods</classsynopsisinfo>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_affected_rows</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::autocommit</methodname>
+ <methodparam>
+ <type>bool</type><parameter>mode</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::change_user</methodname>
+ <methodparam>
+ <type>string</type><parameter>user</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>password</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>database</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli::character_set_name</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::close</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::commit</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_connect_errno</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_connect_error</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>mysqli</type><methodname>mysqli_connect</methodname>
+ <methodparam>
+ <type>string</type><parameter>host</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>username</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>passwd</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>dbname</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>port</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>socket</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::debug</methodname>
+ <methodparam>
+ <type>string</type><parameter>message</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::dump_debug_info</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_errno</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_error</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_field_count</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>object</type><methodname>mysqli::get_charset</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli::get_client_info</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli::get_client_version</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_get_host_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_get_proto_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_get_server_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_get_server_version</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>object</type><methodname>mysqli::get_warnings</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>mysqli</type><methodname>init</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_insert_id</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::kill</methodname>
+ <methodparam>
+ <type>int</type><parameter>processid</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::more_results</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::multi_query</methodname>
+ <methodparam>
+ <type>string</type><parameter>query</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::next_result</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::options</methodname>
+ <methodparam>
+ <type>int</type><parameter>option</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>mixed</type><parameter>value</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::ping</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>mysqli_stmt</type><methodname>prepare</methodname>
+ <methodparam>
+ <type>string</type><parameter>query</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>mixed</type><methodname>mysqli::query</methodname>
+ <methodparam>
+ <type>string</type><parameter>query</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>resultmode</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::real_connect</methodname>
+ <methodparam>
+ <type>string</type><parameter>host</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>username</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>passwd</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>dbname</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>port</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>socket</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>flags</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli::escape_string</methodname>
+ <methodparam>
+ <type>string</type><parameter>escapestr</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>real_query</methodname>
+ <methodparam>
+ <type>string</type><parameter>query</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::rollback</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::select_db</methodname>
+ <methodparam>
+ <type>string</type><parameter>dbname</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::set_charset</methodname>
+ <methodparam>
+ <type>string</type><parameter>charset</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>void</type><methodname>mysqli_set_local_infile_default</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_set_local_infile_handler</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>callback</type><parameter>read_func</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_sqlstate</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::ssl_set</methodname>
+ <methodparam>
+ <type>string</type><parameter>key</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>cert</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>ca</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>capath</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>cipher</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli::stat</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>mysqli_stmt</type><methodname>stmt_init</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>mysqli_result</type><methodname>store_result</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_thread_id</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_thread_safe</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>mysqli_result</type><methodname>use_result</methodname>
+ <void/>
+ </methodsynopsis>
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_warning_count</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+ </classsynopsis>
+
+ <section id="apis-php-mysqli.affected-rows">
+
+ <title><literal>mysqli->affected_rows</literal>,
+ <literal>mysqli_affected_rows</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->affected_rows</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_affected_rows</literal>
+ </para>
+
+ <para>
+ Gets the number of affected rows in a previous MySQL
+ operation
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>int</type><varname>affected_rows</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_affected_rows</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the number of rows affected by the last
+ <literal>INSERT</literal>, <literal>UPDATE</literal>,
+ <literal>REPLACE</literal> or <literal>DELETE</literal> query.
+ </para>
+
+ <para>
+ For SELECT statements <function>mysqli_affected_rows</function>
+ works like <function>mysqli_num_rows</function>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ An integer greater than zero indicates the number of rows
+ affected or retrieved. Zero indicates that no records where
+ updated for an UPDATE statement, no rows matched the
+ <literal>WHERE</literal> clause in the query or that no query
+ has yet been executed. -1 indicates that the query returned an
+ error.
+ </para>
+
+ <note>
+ <para>
+ If the number of affected rows is greater than maximal int
+ value, the number of affected rows will be returned as a
+ string.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Insert rows */
+$mysqli->query("CREATE TABLE Language SELECT * from CountryLanguage");
+printf("Affected rows (INSERT): %d\n", $mysqli->affected_rows);
+
+$mysqli->query("ALTER TABLE Language ADD Status int default 0");
+
+/* update rows */
+$mysqli->query("UPDATE Language SET Status=1 WHERE Percentage > 50");
+printf("Affected rows (UPDATE): %d\n", $mysqli->affected_rows);
+
+/* delete rows */
+$mysqli->query("DELETE FROM Language WHERE Percentage < 50");
+printf("Affected rows (DELETE): %d\n", $mysqli->affected_rows);
+
+/* select all rows */
+$result = $mysqli->query("SELECT CountryCode FROM Language");
+printf("Affected rows (SELECT): %d\n", $mysqli->affected_rows);
+
+$result->close();
+
+/* Delete table Language */
+$mysqli->query("DROP TABLE Language");
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+if (!$link) {
+ printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Insert rows */
+mysqli_query($link, "CREATE TABLE Language SELECT * from CountryLanguage");
+printf("Affected rows (INSERT): %d\n", mysqli_affected_rows($link));
+
+mysqli_query($link, "ALTER TABLE Language ADD Status int default 0");
+
+/* update rows */
+mysqli_query($link, "UPDATE Language SET Status=1 WHERE Percentage > 50");
+printf("Affected rows (UPDATE): %d\n", mysqli_affected_rows($link));
+
+/* delete rows */
+mysqli_query($link, "DELETE FROM Language WHERE Percentage < 50");
+printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($link));
+
+/* select all rows */
+$result = mysqli_query($link, "SELECT CountryCode FROM Language");
+printf("Affected rows (SELECT): %d\n", mysqli_affected_rows($link));
+
+mysqli_free_result($result);
+
+/* Delete table Language */
+mysqli_query($link, "DROP TABLE Language");
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Affected rows (INSERT): 984
+Affected rows (UPDATE): 168
+Affected rows (DELETE): 815
+Affected rows (SELECT): 169
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_num_rows</function>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.info"><function>mysqli_info</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.autocommit">
+
+ <title><literal>mysqli::autocommit</literal>,
+ <literal>mysqli_autocommit</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::autocommit</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_autocommit</literal>
+ </para>
+
+ <para>
+ Turns on or off auto-commiting database modifications
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (method)
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::autocommit</methodname>
+ <methodparam>
+ <type>bool</type><parameter>mode</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_autocommit</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>bool</type><parameter>mode</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Turns on or off auto-commit mode on queries for the database
+ connection.
+ </para>
+
+ <para>
+ To determine the current state of autocommit use the SQL command
+ <literal>SELECT @@autocommit</literal>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>mode</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Whether to turn on auto-commit or not.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ This function doesn't work with non transactional table
+ types (like MyISAM or ISAM).
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* turn autocommit on */
+$mysqli->autocommit(TRUE);
+
+if ($result = $mysqli->query("SELECT @@autocommit")) {
+ $row = $result->fetch_row();
+ printf("Autocommit is %s\n", $row[0]);
+ $result->free();
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+if (!$link) {
+ printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* turn autocommit on */
+mysqli_autocommit($link, TRUE);
+
+if ($result = mysqli_query($link, "SELECT @@autocommit")) {
+ $row = mysqli_fetch_row($result);
+ printf("Autocommit is %s\n", $row[0]);
+ mysqli_free_result($result);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Autocommit is 1
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-mysqli.commit"><function>mysqli_commit</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.rollback"><function>mysqli_rollback</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.change-user">
+
+ <title><literal>mysqli::change_user</literal>,
+ <literal>mysqli_change_user</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::change_user</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_change_user</literal>
+ </para>
+
+ <para>
+ Changes the user of the specified database connection
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (method):
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::change_user</methodname>
+ <methodparam>
+ <type>string</type><parameter>user</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>password</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>database</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_change_user</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>user</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>password</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>database</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Changes the user of the specified database connection and sets
+ the current database.
+ </para>
+
+ <para>
+ In order to successfully change users a valid
+ <parameter>username</parameter> and
+ <parameter>password</parameter> parameters must be provided and
+ that user must have sufficient permissions to access the desired
+ database. If for any reason authorization fails, the current
+ user authentication will remain.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>user</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL user name.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>password</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL password.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>database</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The database to change to.
+ </para>
+
+ <para>
+ If desired, the
+
+ <constant>NULL</constant>
+
+ value may be passed resulting in only changing the user
+ and not selecting a database. To select a database in
+ this case use the <function>mysqli_select_db</function>
+ function.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ Using this command will always cause the current database
+ connection to behave as if was a completely new database
+ connection, regardless of if the operation was completed
+ successfully. This reset includes performing a rollback on any
+ active transactions, closing all temporary tables, and
+ unlocking all locked tables.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+/* connect database test */
+$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Set Variable a */
+$mysqli->query("SET @a:=1");
+
+/* reset all and select a new database */
+$mysqli->change_user("my_user", "my_password", "world");
+
+if ($result = $mysqli->query("SELECT DATABASE()")) {
+ $row = $result->fetch_row();
+ printf("Default database: %s\n", $row[0]);
+ $result->close();
+}
+
+if ($result = $mysqli->query("SELECT @a")) {
+ $row = $result->fetch_row();
+ if ($row[0] === NULL) {
+ printf("Value of variable a is NULL\n");
+ }
+ $result->close();
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+/* connect database test */
+$link = mysqli_connect("localhost", "my_user", "my_password", "test");
+
+/* check connection */
+if (!$link) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Set Variable a */
+mysqli_query($link, "SET @a:=1");
+
+/* reset all and select a new database */
+mysqli_change_user($link, "my_user", "my_password", "world");
+
+if ($result = mysqli_query($link, "SELECT DATABASE()")) {
+ $row = mysqli_fetch_row($result);
+ printf("Default database: %s\n", $row[0]);
+ mysqli_free_result($result);
+}
+
+if ($result = mysqli_query($link, "SELECT @a")) {
+ $row = mysqli_fetch_row($result);
+ if ($row[0] === NULL) {
+ printf("Value of variable a is NULL\n");
+ }
+ mysqli_free_result($result);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Default database: world
+Value of variable a is NULL
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+
+ </member>
+
+ <member><function>mysqli_select_db</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.character-set-name">
+
+ <title><literal>mysqli::character_set_name</literal>,
+ <literal>mysqli_character_set_name</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::character_set_name</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_character_set_name</literal>
+ </para>
+
+ <para>
+ Returns the default character set for the database
+ connection
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (method):
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli::character_set_name</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_character_set_name</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the current character set for the database connection.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ The default character set for the current connection
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+/* Open a connection */
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Print current character set */
+$charset = $mysqli->character_set_name();
+printf ("Current character set is %s\n", $charset);
+
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+/* Open a connection */
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (!$link) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* Print current character set */
+$charset = mysqli_character_set_name($link);
+printf ("Current character set is %s\n",$charset);
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Current character set is latin1_swedish_ci
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_client_encoding</function>
+
+ </member>
+
+ <member><function>mysqli_real_escape_string</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.close">
+
+ <title><literal>mysqli::close</literal>, <literal>mysqli_close</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::close</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_close</literal>
+ </para>
+
+ <para>
+ Closes a previously opened database connection
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (method):
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::close</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_close</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Closes a previously opened database connection.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+
+ </member>
+
+ <member><function>mysqli_real_connect</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.commit">
+
+ <title><literal>mysqli::commit</literal>, <literal>mysqli_commit</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::commit</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_commit</literal>
+ </para>
+
+ <para>
+ Commits the current transaction
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (method)
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::commit</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_commit</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Commits the current transaction for the database connection.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+$mysqli->query("CREATE TABLE Language LIKE CountryLanguage Type=InnoDB");
+
+/* set autocommit to off */
+$mysqli->autocommit(FALSE);
+
+/* Insert some values */
+$mysqli->query("INSERT INTO Language VALUES ('DEU', 'Bavarian', 'F', 11.2)");
+$mysqli->query("INSERT INTO Language VALUES ('DEU', 'Swabian', 'F', 9.4)");
+
+/* commit transaction */
+$mysqli->commit();
+
+/* drop table */
+$mysqli->query("DROP TABLE Language");
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "test");
+
+/* check connection */
+if (!$link) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* set autocommit to off */
+mysqli_autocommit($link, FALSE);
+
+mysqli_query($link, "CREATE TABLE Language LIKE CountryLanguage Type=InnoDB");
+
+/* Insert some values */
+mysqli_query($link, "INSERT INTO Language VALUES ('DEU', 'Bavarian', 'F', 11.2)");
+mysqli_query($link, "INSERT INTO Language VALUES ('DEU', 'Swabian', 'F', 9.4)");
+
+/* commit transaction */
+mysqli_commit($link);
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-mysqli.autocommit"><function>mysqli_autocommit</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.rollback"><function>mysqli_rollback</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.connect-errno">
+
+ <title><literal>mysqli->connect_errno</literal>,
+ <literal>mysqli_connect_errno</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->connect_errno</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_connect_errno</literal>
+ </para>
+
+ <para>
+ Returns the error code from last connect call
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>string</type><varname>connect_errno</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_connect_errno</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ Returns the last error code number from the last call to
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>.
+ </para>
+
+ <note>
+ <para>
+ Client error message numbers are listed in the MySQL
+ <filename>errmsg.h</filename> header file, server error
+ message numbers are listed in
+ <filename>mysqld_error.h</filename>. In the MySQL source
+ distribution you can find a complete list of error messages
+ and error numbers in the file
+ <filename>Docs/mysqld_error.txt</filename>.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ An error code value for the last call to
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>,
+ if it failed. zero means no error occurred.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><function>mysqli_connect_errno</function> example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+$link = @mysqli_connect("localhost", "nonexisting_user", "");
+
+if (!$link) {
+ printf("Can't connect to localhost. Errorcode: %d\n", mysqli_connect_errno());
+}
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+
+ </member>
+
+ <member><function>mysqli_connect_error</function>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.errno"><function>mysqli_errno</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.error"><function>mysqli_error</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.sqlstate"><function>mysqli_sqlstate</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.connect-error">
+
+ <title><literal>mysqli->connect_error</literal>,
+ <literal>mysqli_connect_error</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->connect_error</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_connect_error</literal>
+ </para>
+
+ <para>
+ Returns a string description of the last connect error
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>string</type><varname>connect_error</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_connect_error</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ Returns the last error message string from the last call to
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ A string that describes the error. An empty string if no error
+ occurred.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title><function>mysqli_connect_error</function> example</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+$link = @mysqli_connect("localhost", "nonexisting_user", "");
+
+if (!$link) {
+ printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
+}
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+
+ </member>
+
+ <member><function>mysqli_connect_errno</function>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.errno"><function>mysqli_errno</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.error"><function>mysqli_error</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.sqlstate"><function>mysqli_sqlstate</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.connect">
+
+ <title><literal>mysqli::__construct</literal>,
+ <literal>mysqli_connect</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::__construct</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_connect</literal>
+ </para>
+
+ <para>
+ Open a new connection to the MySQL server
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (constructor):
+ </para>
+
+ <constructorsynopsis><methodname>mysqli::__construct</methodname>
+
+ <methodparam>
+ <type>string</type><parameter>host</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>username</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>passwd</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>dbname</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>port</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>socket</parameter>
+ </methodparam>
+
+ </constructorsynopsis>
+
+ <para>
+ Procedural style
+ </para>
+
+ <methodsynopsis>
+ <type>mysqli</type><methodname>mysqli_connect</methodname>
+ <methodparam>
+ <type>string</type><parameter>host</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>username</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>passwd</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>dbname</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>int</type><parameter>port</parameter>
+ </methodparam>
+
+ <methodparam>
+ <type>string</type><parameter>socket</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Opens a connection to the MySQL Server running on.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>host</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Can be either a host name or an IP address. Passing the
+
+ <constant>NULL</constant>
+
+ value or the string "localhost" to this
+ parameter, the local host is assumed. When possible,
+ pipes will be used instead of the TCP/IP protocol.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>username</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL user name.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>passwd</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ If not provided or
+
+ <constant>NULL</constant>
+
+ , the MySQL server will attempt to authenticate the user
+ against those user records which have no password only.
+ This allows one username to be used with different
+ permissions (depending on if a password as provided or
+ not).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>dbname</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ If provided will specify the default database to be used
+ when performing queries.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>port</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Specifies the port number to attempt to connect to the
+ MySQL server.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>socket</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Specifies the socket or named pipe that should be used.
+ </para>
+
+ <note>
+ <para>
+ Specifying the <parameter>socket</parameter> parameter
+ will not explicitly determine the type of connection
+ to be used when connecting to the MySQL server. How
+ the connection is made to the MySQL database is
+ determined by the <parameter>host</parameter>
+ parameter.
+ </para>
+ </note>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns a object which represents the connection to a MySQL
+ Server or
+
+ <constant>FALSE</constant>
+
+ if the connection failed.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+printf("Host information: %s\n", $mysqli->host_info);
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (!$link) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+printf("Host information: %s\n", mysqli_get_host_info($link));
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Host information: Localhost via UNIX socket
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ Error "Can't create TCP/IP socket (10106)"
+ usually means that the
+ <ulink url="http://www.php.net/manual/en/ini.variables-order.php">variables_order</ulink>
+ configure directive doesn't contain character
+ <literal>E</literal>. On Windows, if the environment is not
+ copied the <literal>SYSTEMROOT</literal> environment variable
+ won't be available and PHP will have problems loading
+ Winsock.
+ </para>
+ </note>
+
+ </section>
+
+ <section id="apis-php-mysqli.debug">
+
+ <title><literal>mysqli::debug</literal>, <literal>mysqli_debug</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::debug</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_debug</literal>
+ </para>
+
+ <para>
+ Performs debugging operations
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (method):
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::debug</methodname>
+ <methodparam>
+ <type>string</type><parameter>message</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_debug</methodname>
+ <methodparam>
+ <type>string</type><parameter>message</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Performs debugging operations using the Fred Fish debugging
+ library.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>message</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ A string representing the debugging operation to perform
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ .
+ </para>
+
+ <para>
+ <emphasis role="bold">Notes</emphasis>
+ </para>
+
+ <note>
+ <para>
+ To use the
+ <link linkend="apis-php-mysqli.debug"><function>mysqli_debug</function></link>
+ function you must complile the MySQL client library to support
+ debugging.
+ </para>
+ </note>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>Generating a Trace File</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+/* Create a trace file in '/tmp/client.trace' on the local (client) machine: */
+mysqli_debug("d:t:0,/tmp/client.trace");
+
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_dump_debug_info</function>
+
+ </member>
+
+ <member><function>mysqli_report</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.dump-debug-info">
+
+ <title><literal>mysqli::dump_debug_info</literal>,
+ <literal>mysqli_dump_debug_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::dump_debug_info</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_dump_debug_info</literal>
+ </para>
+
+ <para>
+ Dump debugging information into the log
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (method):
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli::dump_debug_info</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>bool</type><methodname>mysqli_dump_debug_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ This function is designed to be executed by an user with the
+ SUPER privilege and is used to dump debugging information into
+ the log for the MySQL Server relating to the connection.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns
+
+ <constant>TRUE</constant>
+
+ on success or
+
+ <constant>FALSE</constant>
+
+ on failure.
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><link linkend="apis-php-mysqli.debug"><function>mysqli_debug</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.errno">
+
+ <title><literal>mysqli->errno</literal>, <literal>mysqli_errno</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->errno</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_errno</literal>
+ </para>
+
+ <para>
+ Returns the error code for the most recent function call
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>int</type><varname>errno</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_errno</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the last error code for the most recent MySQLi function
+ call that can succeed or fail.
+ </para>
+
+ <para>
+ Client error message numbers are listed in the MySQL
+ <filename>errmsg.h</filename> header file, server error message
+ numbers are listed in <filename>mysqld_error.h</filename>. In
+ the MySQL source distribution you can find a complete list of
+ error messages and error numbers in the file
+ <filename>Docs/mysqld_error.txt</filename>.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ An error code value for the last call, if it failed. zero means
+ no error occurred.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if (!$mysqli->query("SET a=1")) {
+ printf("Errorcode: %d\n", $mysqli->errno);
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if (!mysqli_query($link, "SET a=1")) {
+ printf("Errorcode: %d\n", mysqli_errno($link));
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Errorcode: 1193
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_connect_errno</function>
+
+ </member>
+
+ <member><function>mysqli_connect_error</function>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.error"><function>mysqli_error</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.sqlstate"><function>mysqli_sqlstate</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.error">
+
+ <title><literal>mysqli->error</literal>, <literal>mysqli_error</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->error</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_error</literal>
+ </para>
+
+ <para>
+ Returns a string description of the last error
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>string</type><varname>error</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_error</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the last error message for the most recent MySQLi
+ function call that can succeed or fail.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ A string that describes the error. An empty string if no error
+ occurred.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if (!$mysqli->query("SET a=1")) {
+ printf("Errormessage: %s\n", $mysqli->error);
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+if (!mysqli_query($link, "SET a=1")) {
+ printf("Errormessage: %s\n", mysqli_error($link));
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Errormessage: Unknown system variable 'a'
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_connect_errno</function>
+
+ </member>
+
+ <member><function>mysqli_connect_error</function>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.errno"><function>mysqli_errno</function></link>
+
+ </member>
+
+ <member><link linkend="apis-php-mysqli.sqlstate"><function>mysqli_sqlstate</function></link>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.field-count">
+
+ <title><literal>mysqli->field_count</literal>,
+ <literal>mysqli_field_count</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->field_count</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_field_count</literal>
+ </para>
+
+ <para>
+ Returns the number of columns for the most recent query
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli_result</classname></ooclass>
+ <fieldsynopsis>
+ <type>int</type><varname>field_count</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_field_count</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns the number of columns for the most recent query on the
+ connection represented by the <parameter>link</parameter>
+ parameter. This function can be useful when using the
+ <function>mysqli_store_result</function> function to determine
+ if the query should have produced a non-empty result set or not
+ without knowing the nature of the query.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ An integer representing the number of fields in a result set.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "test");
+
+$mysqli->query( "DROP TABLE IF EXISTS friends");
+$mysqli->query( "CREATE TABLE friends (id int, name varchar(20))");
+
+$mysqli->query( "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
+
+
+$mysqli->real_query("SELECT * FROM friends");
+
+if ($mysqli->field_count) {
+ /* this was a select/show or describe query */
+ $result = $mysqli->store_result();
+
+ /* process resultset */
+ $row = $result->fetch_row();
+
+ /* free resultset */
+ $result->close();
+}
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "test");
+
+mysqli_query($link, "DROP TABLE IF EXISTS friends");
+mysqli_query($link, "CREATE TABLE friends (id int, name varchar(20))");
+
+mysqli_query($link, "INSERT INTO friends VALUES (1,'Hartmut'), (2, 'Ulf')");
+
+mysqli_real_query($link, "SELECT * FROM friends");
+
+if (mysqli_field_count($link)) {
+ /* this was a select/show or describe query */
+ $result = mysqli_store_result($link);
+
+ /* process resultset */
+ $row = mysqli_fetch_row($result);
+
+ /* free resultset */
+ mysqli_free_result($result);
+}
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-charset">
+
+ <title><literal>mysqli::get_charset</literal>,
+ <literal>mysqli_get_charset</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::get_charset</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_charset</literal>
+ </para>
+
+ <para>
+ Returns a character set object
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>object</type><methodname>mysqli::get_charset</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <methodsynopsis>
+ <type>object</type><methodname>mysqli_get_charset</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns a character set object providing several properties of
+ the current active characer set.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ The function returns a character set object with the following
+ properties:
+
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter>charset</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Character set name
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>collation</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Collation name
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>dir</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Directory the charset description was fetched from (?)
+ or "" for builtin character sets
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>min_length</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Minimum character lenght in bytes
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>max_length</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Maximum character length in bytes
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>number</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Internal character set number
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <parameter>state</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Characer set status (?)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+ $db = mysqli_init();
+ $db->real_connect("localhost","root","","test");
+ var_dump($db->get_charset());
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+ $db = mysqli_init();
+ mysqli_real_connect($db, "localhost","root","","test");
+ var_dump($db->get_charset());
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+object(stdClass)#2 (7) {
+ ["charset"]=>
+ string(6) "latin1"
+ ["collation"]=>
+ string(17) "latin1_swedish_ci"
+ ["dir"]=>
+ string(0) ""
+ ["min_length"]=>
+ int(1)
+ ["max_length"]=>
+ int(1)
+ ["number"]=>
+ int(8)
+ ["state"]=>
+ int(801)
+}
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_characters_set_name</function>
+
+ </member>
+
+ <member><function>mysqli_set_charset</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-client-info">
+
+ <title><literal>mysqli::get_client_info</literal>,
+ <literal>mysqli_get_client_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::get_client_info</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_client_info</literal>
+ </para>
+
+ <para>
+ Returns the MySQL client version as a string
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli::get_client_info</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_get_client_info</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ The <function>mysqli_get_client_info</function> function is used
+ to return a string representing the client version being used in
+ the MySQLi extension.
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ A string that represents the MySQL client library version
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>mysqli_get_client_info</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+/* We don't need a connection to determine
+ the version of mysql client library */
+
+printf("Client library version: %s\n", mysqli_get_client_info());
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_get_client_version</function>
+
+ </member>
+
+ <member><function>mysqli_get_server_info</function>
+
+ </member>
+
+ <member><function>mysqli_get_server_version</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-client-version">
+
+ <title><literal>mysqli::get_client_version</literal>,
+ <literal>mysqli_get_client_version</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::get_client_version</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_client_version</literal>
+ </para>
+
+ <para>
+ Get MySQL client info
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli::get_client_version</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_get_client_version</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <para>
+ Returns client version number as an integer.
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ A number that represents the MySQL client library version in
+ format: <literal>main_version*10000 + minor_version *100 +
+ sub_version</literal>. For example, 4.1.0 is returned as 40100.
+ </para>
+
+ <para>
+ This is useful to quickly determine the version of the client
+ library to know if some capability exits.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>mysqli_get_client_version</title>
+
+<programlisting>
+<![CDATA[
+<?php
+
+/* We don't need a connection to determine
+ the version of mysql client library */
+
+printf("Client library version: %d\n", mysqli_get_client_version());
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_get_client_info</function>
+
+ </member>
+
+ <member><function>mysqli_get_server_info</function>
+
+ </member>
+
+ <member><function>mysqli_get_server_version</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-host-info">
+
+ <title><literal>mysqli->host_info</literal>,
+ <literal>mysqli_get_host_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->host_info</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_host_info</literal>
+ </para>
+
+ <para>
+ Returns a string representing the type of connection used
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>string</type><varname>host_info</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procdural style:
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_get_host_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ The <function>mysqli_get_host_info</function> function returns a
+ string describing the connection represented by the
+ <parameter>link</parameter> parameter is using (including the
+ server host name).
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ A character string representing the server hostname and the
+ connection type.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print host information */
+printf("Host info: %s\n", $mysqli->host_info);
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password", "world");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print host information */
+printf("Host info: %s\n", mysqli_get_host_info($link));
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Host info: Localhost via UNIX socket
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_get_proto_info</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-proto-info">
+
+ <title><literal>mysqli->protocol_version</literal>,
+ <literal>mysqli_get_proto_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->protocol_version</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_proto_info</literal>
+ </para>
+
+ <para>
+ Returns the version of the MySQL protocol used
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>string</type><varname>protocol_version</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_get_proto_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns an integer representing the MySQL protocol version used
+ by the connection represented by the <parameter>link</parameter>
+ parameter.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ Returns an integer representing the protocol version.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print protocol version */
+printf("Protocol version: %d\n", $mysqli->protocol_version);
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print protocol version */
+printf("Protocol version: %d\n", mysqli_get_proto_info($link));
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Protocol version: 10
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_get_host_info</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-server-info">
+
+ <title><literal>mysqli->server_info</literal>,
+ <literal>mysqli_get_server_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->server_info</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_server_info</literal>
+ </para>
+
+ <para>
+ Returns the version of the MySQL server
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>string</type><varname>server_info</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_get_server_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ Returns a string representing the version of the MySQL server
+ that the MySQLi extension is connected to.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ A character string representing the server version.
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print server version */
+printf("Server version: %s\n", $mysqli->server_info);
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print server version */
+printf("Server version: %s\n", mysqli_get_server_info($link));
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Server version: 4.1.2-alpha-debug
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_get_client_info</function>
+
+ </member>
+
+ <member><function>mysqli_get_client_version</function>
+
+ </member>
+
+ <member><function>mysqli_get_server_version</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-server-version">
+
+ <title><literal>mysqli->server_version</literal>,
+ <literal>mysqli_get_server_version</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->server_version</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_server_version</literal>
+ </para>
+
+ <para>
+ Returns the version of the MySQL server as an integer
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property):
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>int</type><varname>server_version</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>int</type><methodname>mysqli_get_server_version</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ The <function>mysqli_get_server_version</function> function
+ returns the version of the server connected to (represented by
+ the <parameter>link</parameter> parameter) as an integer.
+ </para>
+
+ <para>
+ <emphasis role="bold">Parameters</emphasis>
+ </para>
+
+ <para>
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <parameter> link</parameter>
+ </term>
+
+ <listitem>
+ <para>
+ Procedural style only: A link identifier returned by
+ <link linkend="apis-php-mysqli.connect"><function>mysqli_connect</function></link>
+ or
+ <link linkend="apis-php-mysqli.init"><function>mysqli_init</function></link>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Return Values</emphasis>
+ </para>
+
+ <para>
+ An integer representing the server version.
+ </para>
+
+ <para>
+ The form of this version number is <literal>main_version * 10000
+ + minor_version * 100 + sub_version</literal> (i.e. version
+ 4.1.0 is 40100).
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <example>
+
+ <title>Object oriented style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$mysqli = new mysqli("localhost", "my_user", "my_password");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print server version */
+printf("Server version: %d\n", $mysqli->server_version);
+
+/* close connection */
+$mysqli->close();
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <example>
+
+ <title>Procedural style</title>
+
+<programlisting>
+<![CDATA[
+<?php
+$link = mysqli_connect("localhost", "my_user", "my_password");
+
+/* check connection */
+if (mysqli_connect_errno()) {
+ printf("Connect failed: %s\n", mysqli_connect_error());
+ exit();
+}
+
+/* print server version */
+printf("Server version: %d\n", mysqli_get_server_version($link));
+
+/* close connection */
+mysqli_close($link);
+?>
+]]>
+ </programlisting>
+
+ </example>
+
+ <para>
+ The above example will output:
+ </para>
+
+ <screen>
+
+<![CDATA[
+Server version: 40102
+]]>
+
+ </screen>
+
+ <para>
+ <emphasis role="bold">See Also</emphasis>
+ </para>
+
+ <para>
+ <simplelist>
+
+ <member><function>mysqli_get_client_info</function>
+
+ </member>
+
+ <member><function>mysqli_get_client_version</function>
+
+ </member>
+
+ <member><function>mysqli_get_server_info</function>
+
+ </member>
+
+ </simplelist>
+ </para>
+
+ </section>
+
+ <section id="apis-php-mysqli.get-warnings">
+
+ <title><literal>mysqli::get_warnings</literal>,
+ <literal>mysqli_get_warnings</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli::get_warnings</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_get_warnings</literal>
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <methodsynopsis>
+ <type>object</type><methodname>mysqli::get_warnings</methodname>
+ <void/>
+ </methodsynopsis>
+
+ <methodsynopsis>
+ <type>object</type><methodname>mysqli_get_warnings</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <warning>
+ <simpara>This function is
+currently not documented; only its argument list is available.
+</simpara>
+ </warning>
+
+ </section>
+
+ <section id="apis-php-mysqli.info">
+
+ <title><literal>mysqli->info</literal>, <literal>mysqli_info</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the
+ PHP Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>mysqli->info</literal>
+ </para>
+
+ <para>
+ <literal>mysqli_info</literal>
+ </para>
+
+ <para>
+ Retrieves information about the most recently executed query
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ Object oriented style (property)
+ </para>
+
+ <classsynopsis>
+ <ooclass><classname>mysqli</classname></ooclass>
+ <fieldsynopsis>
+ <type>string</type><varname>info</varname>
+ </fieldsynopsis>
+ </classsynopsis>
+
+ <para>
+ Procedural style:
+ </para>
+
+ <methodsynopsis>
+ <type>string</type><methodname>mysqli_info</methodname>
+ <methodparam>
+ <type>mysqli</type><parameter>link</parameter>
+ </methodparam>
+ </methodsynopsis>
+
+ <para>
+ The
+ <link linkend="apis-php-mysqli.info"><function>mysqli_info</function></link>
+ function returns a string providing information about the last
+ query executed. The nature of this string is provided below:
+ </para>
+
+ <para>
+ <table>
+ <title>Possible mysqli_info return values</title>
+ <tgroup cols="2">
+ <colspec colwidth="50*"/>
+ <colspec colwidth="50*"/>
+ <thead>
+ <row>
+ <entry>Query type</entry>
+ <entry>Example result string</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>INSERT INTO...SELECT...</entry>
+ <entry>Records: 100 Duplicates: 0 Warnings: 0</entry>
+ </row>
+ <row>
+ <entry>INSERT INTO...VALUES (...),(...),(...)</entry>
+ <entry>Records: 3 Duplicates: 0 Warnings: 0</entry>
+ </row>
+ <row>
+ <entry>LOAD DATA INFILE ...</entry>
Added: trunk/refman-common/apis-php-pdo-mysql.xml
===================================================================
--- trunk/refman-common/apis-php-pdo-mysql.xml (rev 0)
+++ trunk/refman-common/apis-php-pdo-mysql.xml 2008-08-14 16:28:29 UTC (rev 11561)
Changed blocks: 1, Lines Added: 309, Lines Deleted: 0; 7726 bytes
@@ -0,0 +1,309 @@
+<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+<section id="apis-php-ref.pdo-mysql">
+
+ <title>MySQL Functions (PDO_MYSQL)</title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <para>
+ PDO_MYSQL is a driver that implements the
+ <ulink url="http://www.php.net/manual/en/intro.pdo.php">PHP Data
+ Objects (PDO) interface</ulink> to enable access from PHP to MySQL
+ 3.x, 4.x and 5.x databases.
+ </para>
+
+ <para>
+ PDO_MYSQL will take advantage of native prepared statement support
+ present in MySQL 4.1 and higher. If you're using an older
+ version of the mysql client libraries, PDO will emulate them for
+ you.
+ </para>
+
+ <warning>
+ <para>
+ Beware: Some MySQL table types (storage engines) do not support
+ transactions. When writing transactional database code using a
+ table type that does not support transactions, MySQL will pretend
+ that a transaction was initiated successfully. In addition, any
+ DDL queries issued will implicitly commit any pending
+ transactions.
+ </para>
+ </warning>
+
+ <simpara>The constants below are defined by
+this driver, and will only be available when the extension has been either
+compiled into PHP or dynamically loaded at runtime. In addition, these
+driver-specific constants should only be used if you are using this driver.
+Using mysql-specific attributes with the postgres driver may result in
+unexpected behaviour. <function>PDO::getAttribute</function> may be used to
+obtain the <constant>PDO_ATTR_DRIVER_NAME</constant> attribute to check the
+driver, if your code can run against multiple drivers.</simpara>
+
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ <constant>PDO::MYSQL_ATTR_USE_BUFFERED_QUERY</constant>
+
+ (<type>integer</type>)
+ </term>
+
+ <listitem>
+ <simpara>
+ If this attribute is set to <constant>TRUE</constant> on a
+ <classname>PDOStatement</classname>, the MySQL driver will use the
+ buffered versions of the MySQL API. If you're writing portable code, you
+ should use <function>PDOStatement::fetchAll</function> instead.
+ </simpara>
+
+ <para>
+ <example>
+
+ <title>Forcing queries to be buffered in mysql</title>
+
+<programlisting>
+<![CDATA[
+<?php
+if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
+ $stmt = $db->prepare('select * from foo',
+ array(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
+} else {
+ die("my application only works with mysql; I should use \$stmt->fetchAll() instead");
+}
+?>
+]]>
+ </programlisting>
+
+ </example>
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>PDO::MYSQL_ATTR_LOCAL_INFILE</constant>
+
+ (<type>integer</type>)
+ </term>
+
+ <listitem>
+ <para>
+ Enable <literal>LOAD LOCAL INFILE</literal>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>PDO::MYSQL_ATTR_INIT_COMMAND</constant>
+
+ (<type>integer</type>)
+ </term>
+
+ <listitem>
+ <para>
+ Command to execute when connecting to the MySQL server. Will
+ automatically be re-executed when reconnecting.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>PDO::MYSQL_ATTR_READ_DEFAULT_FILE</constant>
+
+ (<type>integer</type>)
+ </term>
+
+ <listitem>
+ <para>
+ Read options from the named option file instead of from
+ <filename>my.cnf</filename>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>PDO::MYSQL_ATTR_READ_DEFAULT_GROUP</constant>
+
+ (<type>integer</type>)
+ </term>
+
+ <listitem>
+ <para>
+ Read options from the named group from
+ <filename>my.cnf</filename> or the file specified with
+
+ <constant>MYSQL_READ_DEFAULT_FILE</constant>
+
+ .
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>PDO::MYSQL_ATTR_MAX_BUFFER_SIZE</constant>
+
+ (<type>integer</type>)
+ </term>
+
+ <listitem>
+ <para>
+ Maximum buffer size. Defaults to 1 MiB.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>PDO::MYSQL_ATTR_DIRECT_QUERY</constant>
+
+ (<type>integer</type>)
+ </term>
+
+ <listitem>
+ <para>
+ Perform direct queries, don't use prepared statements.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ <section id="apis-php-ref.pdo-mysql.connection">
+
+ <title><literal>PDO_MYSQL DSN</literal></title>
+
+ <para>
+ <link linkend="php-api-copyright">Copyright (c) 1997-2008 the PHP
+ Documentation Group.</link>
+ </para>
+
+ <itemizedlist>
+
+ <listitem>
+ <para>
+ <literal>PDO_MYSQL DSN</literal>
+ </para>
+
+ <para>
+ Connecting to MySQL databases
+ </para>
+ </listitem>
+
+ </itemizedlist>
+
+ <para>
+ <emphasis role="bold">Description</emphasis>
+ </para>
+
+ <para>
+ The PDO_MYSQL Data Source Name (DSN) is composed of the following
+ elements:
+
+ <variablelist>
+
+ <varlistentry>
+ <term>
+ DSN prefix
+ </term>
+
+ <listitem>
+ <para>
+ The DSN prefix is <userinput>mysql:</userinput>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>host</constant>
+ </term>
+
+ <listitem>
+ <para>
+ The hostname on which the database server resides.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>port</constant>
+ </term>
+
+ <listitem>
+ <para>
+ The port number where the database server is listening.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>dbname</constant>
+ </term>
+
+ <listitem>
+ <para>
+ The name of the database.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
+ <constant>unix_socket</constant>
+ </term>
+
+ <listitem>
+ <para>
+ The MySQL Unix socket (shouldn't be used with
+ <literal>host</literal> or <literal>port</literal>).
+ </para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+ </para>
+
+ <para>
+ <emphasis role="bold">Examples</emphasis>
+ </para>
+
+ <para>
+ <example>
+
+ <title>PDO_MYSQL DSN examples</title>
+
+ <para>
+ The following example shows a PDO_MYSQL DSN for connecting to
+ MySQL databases:
+
+<programlisting>
+<![CDATA[
+mysql:host=localhost;dbname=testdb
+]]>
+ </programlisting>
+
+ More complete examples:
+
+<programlisting>
+<![CDATA[
+mysql:host=localhost;port=3307;dbname=testdb
+mysql:unix_socket=/tmp/mysql.sock;dbname=testdb
+]]>
+ </programlisting>
+ </para>
+
+ </example>
+ </para>
+
+ </section>
+
+</section>
Modified: trunk/refman-common/apis-php.xml
===================================================================
--- trunk/refman-common/apis-php.xml 2008-08-14 15:40:39 UTC (rev 11560)
+++ trunk/refman-common/apis-php.xml 2008-08-14 16:28:29 UTC (rev 11561)
Changed blocks: 3, Lines Added: 22, Lines Deleted: 4; 2342 bytes
@@ -42,7 +42,7 @@
<listitem>
<para>
- <literal>mysqli</literal> - Stands for <quote>MySQL,
+ <xref linkend="apis-php-mysqli"/> - Stands for <quote>MySQL,
Improved</quote>; this extension is available only in PHP 5. It
is intended for use with MySQL 4.1.1 and later. This extension
fully supports the authentication protocol used in MySQL 5.0, as
@@ -51,9 +51,8 @@
programming interface. You can read the documentation for the
<literal>mysqli</literal> extension at
<ulink url="http://php.net/mysqli"/>. Helpful article can be
- found at
- <ulink url="http://devzone.zend.com/node/view/id/686"/> and
- <ulink url="http://devzone.zend.com/node/view/id/687"/>.
+ found at <ulink url="http://devzone.zend.com/node/view/id/686"/>
+ and <ulink url="http://devzone.zend.com/node/view/id/687"/>.
</para>
</listitem>
@@ -87,6 +86,25 @@
</formalpara>
+ <para id="php-api-copyright">
+ <emphasis>Portions of this section are Copyright (c) 1997-2008 the
+ PHP Documentation Group</emphasis> This material may be distributed
+ only subject to the terms and conditions set forth in the Creative
+ Commons Attribution 3.0 License or later. A copy of the Creative
+ Commons Attribution 3.0 license is distributed with this manual. The
+ latest version is presently available at This material may be
+ distributed only subject to the terms and conditio\ ns set forth in
+ the Open Publication License, v1.0.8 or later (the latest version is
+ presently available at
+ <ulink url="http://www.opencontent.org/openpub/">http://www.opencontent.org/openpub/</ulink>).
+ </para>
+
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../refman-common/apis-php-mysql.xml"/>
+
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../refman-common/apis-php-mysqli.xml"/>
+
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="../refman-common/apis-php-pdo-mysql.xml"/>
+
<section id="php-problems">
<title>Common Problems with MySQL and PHP</title>
| Thread |
|---|
| • svn commit - mysqldoc@docsrva: r11561 - in trunk: refman-4.1 refman-5.0 refman-common | mcbrown | 14 Aug |