2004-11-10 05:26:38 +00:00
|
|
|
<?xml version='1.0' encoding='iso-8859-1'?>
|
2005-02-10 19:03:03 +00:00
|
|
|
<!-- $Revision: 1.20 $ -->
|
2004-11-10 22:21:24 +00:00
|
|
|
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
|
|
|
|
<reference id="ref.pdo">
|
2004-11-13 22:28:28 +00:00
|
|
|
<title>PDO Functions</title>
|
2005-01-18 03:16:39 +00:00
|
|
|
<titleabbrev>PDO</titleabbrev>
|
2004-11-10 22:21:24 +00:00
|
|
|
|
|
|
|
<partintro>
|
|
|
|
<section id="pdo.intro">
|
2004-11-10 05:26:38 +00:00
|
|
|
&reftitle.intro;
|
|
|
|
<para>
|
2004-11-10 22:21:24 +00:00
|
|
|
&warn.experimental;
|
2004-11-24 22:47:56 +00:00
|
|
|
The PHP Data Objects (PDO) extension defines a lightweight, consistent interface
|
2004-11-10 22:21:24 +00:00
|
|
|
for accessing databases in PHP. Each database driver that
|
|
|
|
implements the PDO interface can expose database-specific
|
2004-11-13 22:28:28 +00:00
|
|
|
features as regular extension functions. Note that you cannot
|
|
|
|
perform any database functions using the PDO extension by
|
|
|
|
itself; you must use a <link linkend="pdo.drivers">database-specific
|
|
|
|
PDO driver</link> to access a database server.
|
2004-11-10 22:21:24 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
<section id="pdo.installation">
|
|
|
|
&reftitle.install;
|
2005-02-09 17:20:15 +00:00
|
|
|
<!-- Uncomment this section when PDO actually stabilizes and PEAR method
|
|
|
|
works -->
|
|
|
|
<!--
|
2004-11-10 22:21:24 +00:00
|
|
|
<para>
|
|
|
|
PDO is currently available as a PECL extension from
|
|
|
|
<ulink url='&url.pecl.package;pdo'>&url.pecl.package;pdo</ulink>.
|
2005-02-09 17:20:15 +00:00
|
|
|
Ensure you have installed the CLI version of PHP and that the
|
2004-11-10 22:21:24 +00:00
|
|
|
<command>pear</command> and <command>phpize</command> scripts are
|
|
|
|
available in your current path.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Run the following command to download, build, and install the
|
|
|
|
latest stable version of PDO:
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
pear install pdo
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
The <command>pear</command> command automatically installs the
|
|
|
|
PDO module into your PHP extensions directory. To enable the
|
2004-11-19 19:02:31 +00:00
|
|
|
PDO extension on Linux or Unix operating systems, you must add
|
2004-11-10 22:21:24 +00:00
|
|
|
the following line to &php.ini;:
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
extension=pdo.so
|
|
|
|
]]>
|
|
|
|
</screen>
|
2005-02-09 17:20:15 +00:00
|
|
|
</para>
|
|
|
|
-->
|
|
|
|
<procedure id='installwindows'>
|
|
|
|
<title>Windows</title>
|
2005-02-09 17:28:36 +00:00
|
|
|
<para>
|
|
|
|
Follow the same steps to install and enable the PDO drivers of your
|
|
|
|
choice.
|
|
|
|
</para>
|
2005-02-09 17:20:15 +00:00
|
|
|
<step>
|
|
|
|
<para>
|
|
|
|
Windows users can download the extension DLL <filename>php_pdo.dll</filename>
|
|
|
|
as part of the PECL collection binaries from
|
2005-02-10 17:23:58 +00:00
|
|
|
<ulink url='&url.php.downloads;'>&url.php.downloads;</ulink> or a more
|
2005-02-10 18:26:27 +00:00
|
|
|
recent version from a <ulink url="&url.pecl.get.win.php5.0;">PHP 5 PECL
|
|
|
|
Snapshot</ulink>.
|
2005-02-09 17:20:15 +00:00
|
|
|
</para>
|
|
|
|
</step>
|
|
|
|
<step>
|
|
|
|
<para>
|
|
|
|
To enable the PDO extension on Windows operating systems, you must
|
|
|
|
add the following line to &php.ini;:
|
|
|
|
<screen>
|
2004-11-10 22:21:24 +00:00
|
|
|
<![CDATA[
|
2004-11-19 15:55:49 +00:00
|
|
|
extension=php_pdo.dll
|
2004-11-10 22:21:24 +00:00
|
|
|
]]>
|
2005-02-09 17:20:15 +00:00
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
</step>
|
2005-02-10 19:03:03 +00:00
|
|
|
<step>
|
|
|
|
<para>
|
|
|
|
Next, choose the other DB specific DLL files and either use
|
|
|
|
<function>dl</function> to load them at runtime, or enable them in
|
|
|
|
&php.ini; below <filename>pdo_pdo.dll</filename>. For example:
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
extension=php_pdo.dll
|
|
|
|
extension=php_firebird.dll
|
|
|
|
extension=php_mssql.dll
|
|
|
|
extension=php_mysql.dll
|
|
|
|
extension=php_oci.dll
|
|
|
|
extension=php_oci8.dll
|
|
|
|
extension=php_odbc.dll
|
|
|
|
extension=php_pgsql.dll
|
|
|
|
extension=php_sqlite.dll
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
These DLL's should exist in the systems
|
|
|
|
<link linkend="ini.extension-dir">extension_dir</link>.
|
|
|
|
</para>
|
|
|
|
</step>
|
2005-02-09 17:20:15 +00:00
|
|
|
</procedure>
|
|
|
|
<procedure id='installunix'>
|
|
|
|
<title>Linux and UNIX</title>
|
|
|
|
<para>
|
|
|
|
Due to a bug in the <command>pear</command> installer you should install
|
|
|
|
the PDO package manually using the following steps:
|
|
|
|
</para>
|
2005-02-09 17:28:36 +00:00
|
|
|
<para>
|
|
|
|
Follow the same steps to install and enable the PDO drivers of your
|
|
|
|
choice.
|
|
|
|
</para>
|
2005-02-09 17:20:15 +00:00
|
|
|
<step>
|
|
|
|
<para>Download the PDO package to your local machine:
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
bash$ wget http://pecl.php.net/get/PDO
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
</step>
|
|
|
|
<step>
|
|
|
|
<para>
|
|
|
|
Determine your PHP <filename>bin</filename> directory. If your
|
|
|
|
PHP 5 CLI binary lives at <filename>/usr/local/php5/bin/php</filename>
|
|
|
|
then the bin dir is <filename>/usr/local/php5/bin</filename>.
|
|
|
|
</para>
|
|
|
|
</step>
|
|
|
|
<step>
|
|
|
|
<para>
|
|
|
|
Set your path so that your PHP <filename>bin</filename> directory
|
|
|
|
is at the front:
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
export PATH="/usr/local/php5/bin:$PATH"
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
</step>
|
|
|
|
<step>
|
|
|
|
<para>
|
|
|
|
Manually build and install the PDO extension:
|
|
|
|
<screen>
|
|
|
|
<![CDATA[
|
|
|
|
bash$ tar xzf PDO-0.2.tgz
|
|
|
|
bash$ cd PDO-0.2
|
|
|
|
bash$ phpize
|
|
|
|
bash$ ./configure
|
|
|
|
bash$ make
|
|
|
|
bash$ sudo -s
|
|
|
|
bash# make install
|
|
|
|
bash# echo extension=pdo.so >> /usr/local/php5/lib/php.ini
|
|
|
|
]]>
|
|
|
|
</screen>
|
|
|
|
</para>
|
|
|
|
</step>
|
|
|
|
</procedure>
|
2004-11-10 05:26:38 +00:00
|
|
|
</section>
|
2004-11-13 22:28:28 +00:00
|
|
|
<section id="pdo.drivers">
|
|
|
|
<title>PDO Drivers</title>
|
|
|
|
<para>
|
|
|
|
The following drivers currently implement the PDO interface:
|
2004-11-24 22:47:56 +00:00
|
|
|
<informaltable>
|
2004-11-24 22:58:47 +00:00
|
|
|
<tgroup cols='2'>
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry>Driver name</entry>
|
|
|
|
<entry>Supported databases</entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2005-02-09 17:20:15 +00:00
|
|
|
<row>
|
|
|
|
<entry>PDO_DBLIB</entry>
|
|
|
|
<entry>FreeTDS / Microsoft SQL Server / Sybase</entry>
|
|
|
|
</row>
|
2004-11-24 22:58:47 +00:00
|
|
|
<row>
|
|
|
|
<entry>PDO_FIREBIRD</entry>
|
|
|
|
<entry>Firebird/Interbase 6</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>PDO_MYSQL</entry>
|
|
|
|
<entry>MySQL 3.x/4.0</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>PDO_OCI</entry>
|
|
|
|
<entry>Oracle Call Interface</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>PDO_ODBC</entry>
|
|
|
|
<entry>ODBC v3 (IBM DB2 and unixODBC)</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>PDO_PGSQL</entry>
|
|
|
|
<entry>PostgreSQL</entry>
|
|
|
|
</row>
|
|
|
|
<row>
|
|
|
|
<entry>PDO_SQLITE</entry>
|
|
|
|
<entry>SQLite 3.x</entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
|
|
|
</tgroup>
|
2004-11-24 22:47:56 +00:00
|
|
|
</informaltable>
|
2004-11-13 22:28:28 +00:00
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
2004-11-10 22:21:24 +00:00
|
|
|
<section id='pdo.classes'>
|
|
|
|
&reftitle.classes;
|
|
|
|
<section id='pdo.class.PDO'>
|
|
|
|
<title><classname>PDO</classname></title>
|
|
|
|
<para>
|
|
|
|
Represents a connection between PHP and a database server.
|
|
|
|
</para>
|
|
|
|
<section id='pdo.class.PDO.constructor'>
|
|
|
|
&reftitle.constructor;
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-construct'>PDO</link> - constructs a new
|
|
|
|
PDO object
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</section>
|
|
|
|
<section id='pdo.class.PDO.methods'>
|
|
|
|
&reftitle.methods;
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-beginTransaction'>beginTransaction</link>
|
|
|
|
- begins a transaction
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-commit'>commit</link>
|
|
|
|
- commits a transaction
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-exec'>exec</link>
|
|
|
|
- issues an SQL statement and returns the number of affected rows
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-errorCode'>errorCode</link>
|
|
|
|
- retrieves an error code, if any, from the database
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-errorInfo'>errorInfo</link>
|
|
|
|
- retrieves an array of error information, if any, from the
|
|
|
|
database
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
2005-01-18 03:16:39 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-getAttribute'>getAttribute</link>
|
|
|
|
- retrieves a database connection attribute
|
|
|
|
</para>
|
2005-01-18 03:16:39 +00:00
|
|
|
</listitem>
|
2004-11-10 22:21:24 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-lastInsertId'>lastInsertId</link>
|
|
|
|
- retrieves the value of the last row that was inserted into a table
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-prepare'>prepare</link>
|
|
|
|
- prepares an SQL statement for execution
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
2005-01-18 03:16:39 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-query'>query</link>
|
|
|
|
- issues an SQL statement and returns a result set
|
|
|
|
</para>
|
2005-01-18 03:16:39 +00:00
|
|
|
</listitem>
|
2005-02-10 04:30:50 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-quote'>quote</link>
|
|
|
|
- returns a quoted version of a string for use in SQL statements
|
|
|
|
</para>
|
2005-02-10 04:30:50 +00:00
|
|
|
</listitem>
|
2004-11-10 22:21:24 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-rollBack'>rollBack</link>
|
|
|
|
- roll back a transaction
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDO-setAttribute'>setAttribute</link>
|
|
|
|
- sets a database connection attribute
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</section>
|
|
|
|
</section>
|
|
|
|
<section id='pdo.class.PDOStatement'>
|
|
|
|
<title><classname>PDOStatement</classname></title>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
Represents a prepared statement and, after the statement is executed, an
|
|
|
|
associated result set.
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
<section id='pdo.class.Statement.methods'>
|
|
|
|
&reftitle.methods;
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-bindColumn'>bindColumn</link>
|
|
|
|
- binds a PHP variable to an output column in a result set
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-bindParam'>bindParam</link>
|
|
|
|
- binds a PHP variable to a parameter in the prepared statement
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
2005-01-18 03:16:39 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-columnCount'>columnCount</link>
|
|
|
|
- returns the number of columns in the result set
|
|
|
|
</para>
|
2005-01-18 03:16:39 +00:00
|
|
|
</listitem>
|
2004-11-10 22:21:24 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-errorCode'>errorCode</link>
|
|
|
|
- retrieves an error code, if any, from the statement
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-errorInfo'>errorInfo</link>
|
|
|
|
- retrieves an array of error information, if any, from the statement
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-execute'>execute</link>
|
|
|
|
- executes a prepared statement
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-fetch'>fetch</link>
|
|
|
|
- fetches a row from a result set
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-fetchAll'>fetchAll</link>
|
|
|
|
- fetches an array containing all of the rows from a result set
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-fetchSingle'>fetchSingle</link>
|
|
|
|
- returns the data from the first column in a result set
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
2005-01-18 03:16:39 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-getAttribute'>getAttribute</link>
|
|
|
|
- retrieves a PDOStatement attribute
|
|
|
|
</para>
|
2005-01-18 03:16:39 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-getColumnMeta'>getColumnMeta</link>
|
|
|
|
- retrieves metadata for a column in the result set
|
|
|
|
</para>
|
2005-01-18 03:16:39 +00:00
|
|
|
</listitem>
|
2004-11-10 22:21:24 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-rowCount'>rowCount</link>
|
|
|
|
- returns the number of rows that were affected by the execution of
|
|
|
|
an SQL statement
|
|
|
|
</para>
|
2004-11-10 22:21:24 +00:00
|
|
|
</listitem>
|
2005-01-18 03:16:39 +00:00
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-setAttribute'>setAttribute</link>
|
|
|
|
- sets a PDOStatement attribute
|
|
|
|
</para>
|
2005-01-18 03:16:39 +00:00
|
|
|
</listitem>
|
|
|
|
<listitem>
|
2005-02-10 17:32:42 +00:00
|
|
|
<para>
|
|
|
|
<link linkend='function.PDOStatement-setFetchMode'>setFetchMode</link>
|
|
|
|
- sets the fetch mode for a PDOStatement
|
|
|
|
</para>
|
2005-01-18 03:16:39 +00:00
|
|
|
</listitem>
|
2004-11-10 22:21:24 +00:00
|
|
|
</itemizedlist>
|
|
|
|
</section>
|
2004-11-10 05:26:38 +00:00
|
|
|
</section>
|
|
|
|
</section>
|
2004-11-10 22:21:24 +00:00
|
|
|
&reference.pdo.constants;
|
|
|
|
</partintro>
|
2004-11-10 05:26:38 +00:00
|
|
|
&reference.pdo.functions;
|
2004-11-10 22:21:24 +00:00
|
|
|
</reference>
|
2004-11-10 05:26:38 +00:00
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|