Correct constants.xml typo.

Migrate construct to new template.
Correct rowCount example.
Add setFetchMode documentation.


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@178285 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Dan Scott 2005-01-26 05:35:40 +00:00
parent bd012a6f76
commit e05f5d938a
4 changed files with 141 additions and 110 deletions

View file

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.2 $ -->
<!-- $Revision: 1.3 $ -->
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
<section id="pdo.constants">
&reftitle.constants;
@ -133,7 +133,7 @@
<simpara>
Specifies that the fetch method shall return TRUE and assign the values of
the columns in the result set to the PHP variables to which they were
bound with the <function>PDOStatement::bindParam()</function> method.
bound with the <function>PDOStatement::bindParam</function> method.
</simpara>
</listitem>
</varlistentry>

View file

@ -1,10 +1,10 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.5 $ -->
<!-- $Revision: 1.6 $ -->
<refentry id="function.PDO-construct">
<refnamediv>
<refname>PDO::__construct</refname>
<refpurpose>
Creates a PDO instance to represent a connection to a database
Creates a PDO instance representing a connection to a database
</refpurpose>
</refnamediv>
<refsect1>
@ -19,49 +19,101 @@
&warn.experimental.func;
<para>
Creates a PDO instance to represent a connection to the requested
database. The <parameter>dsn</parameter> parameter supports three
different methods of specifying the arguments required to create
a database connection:
database.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry><term>Driver invocation</term>
<varlistentry><term>dsn</term>
<listitem>
<para>
<parameter>dsn</parameter> consists of the PDO driver name, followed
by a colon, followed by the PDO driver-specific connection syntax.
For example, <userinput>'odbc:DSN=SAMPLE;UID=db2inst1;PWD=ibmdb2'</userinput>
would create a PDO_ODBC connection to an ODBC database, while
<userinput>'mysql:host=127.0.0.1;dbname=testdb'</userinput> would create
a PDO_MYSQL connection to a MySQL database.
The <parameter>dsn</parameter> parameter supports three
different methods of specifying the arguments required to create
a database connection:
<variablelist>
<varlistentry><term>Driver invocation</term>
<listitem>
<para>
<parameter>dsn</parameter> consists of the PDO driver name, followed
by a colon, followed by the PDO driver-specific connection syntax.
For example, <userinput>'odbc:DSN=SAMPLE;UID=db2inst1;PWD=ibmdb2'</userinput>
would create a PDO_ODBC connection to an ODBC database, while
<userinput>'mysql:host=127.0.0.1;dbname=testdb'</userinput> would create
a PDO_MYSQL connection to a MySQL database.
</para>
</listitem>
</varlistentry>
<varlistentry><term>URI invocation</term>
<listitem>
<para>
<parameter>dsn</parameter> consists of <userinput>uri:</userinput>
followed by a URI that defines the location of a file containing
the DSN string. The URI can specify a local file or a remote URL.
</para>
</listitem>
</varlistentry>
<varlistentry><term>Aliasing</term>
<listitem>
<para>
<parameter>dsn</parameter> consists of a name
<parameter>name</parameter> that maps to
<literal>pdo.dsn.<parameter>name</parameter></literal> in &php.ini;
defining the DSN string. <parameter>name</parameter> can not contain
a colon.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</listitem>
</varlistentry>
<varlistentry><term>URI invocation</term>
<varlistentry><term>username</term>
<listitem>
<para>
<parameter>dsn</parameter> consists of <userinput>uri:</userinput>
followed by a URI that defines the location of a file containing
the DSN string. The URI can specify a local file or a remote URL.
The user name, if required, for the DSN string.
</para>
</listitem>
</varlistentry>
<varlistentry><term>Aliasing</term>
<varlistentry><term>password</term>
<listitem>
<para>
<parameter>dsn</parameter> consists of a name
<parameter>name</parameter> that maps to
<literal>pdo.dsn.<parameter>name</parameter></literal> in &php.ini;
defining the DSN string. <parameter>name</parameter> can not contain
a colon.
The password, if required, for the DSN string.
</para>
</listitem>
</varlistentry>
<varlistentry><term>driver_opts</term>
<listitem>
<para>
A key =&gt; value array of driver-specific connection options.
</para>
</listitem>
</varlistentry>
</variablelist>
If <parameter>username</parameter> or <parameter>password</parameter>
are not required to complete the connection, you must pass empty strings
or the constructor will throw a PDOException exception.
</para>
<example><title>Create a PDO instance via driver invocation</title>
<programlisting role="php">
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a PDO object on success.
</para>
</refsect1>
<refsect1 role="exceptions">
&reftitle.exceptions;
<para>
<function>PDO::construct</function> throws a PDOException if the attempt
to connect to the requested database fails.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example><title>Create a PDO instance via driver invocation</title>
<programlisting role="php">
<![CDATA[
<?php
/* Connect to an ODBC database using driver invocation */
@ -77,26 +129,26 @@ catch (PDOException $e) {
}
?>
]]>
</programlisting>
</example>
<example><title>Create a PDO instance via URI invocation</title>
<para>
The following example assumes that the file
<filename>/usr/local/dbconnect</filename> exists with file permissions
that enable PHP to read the file. The file contains the PDO DSN to
connect to a DB2 database through the PDO_ODBC driver:
</para>
<programlisting>
</programlisting>
</example>
<example><title>Create a PDO instance via URI invocation</title>
<para>
The following example assumes that the file
<filename>/usr/local/dbconnect</filename> exists with file permissions
that enable PHP to read the file. The file contains the PDO DSN to
connect to a DB2 database through the PDO_ODBC driver:
</para>
<programlisting>
<![CDATA[
odbc:DSN=SAMPLE;UID=db2inst1;PWD=password
]]>
</programlisting>
<para>
The PHP script can then create a database connection by simply
passing the <literal>uri:</literal> parameter and pointing to
the file URI:
</para>
<programlisting role="php">
</programlisting>
<para>
The PHP script can then create a database connection by simply
passing the <literal>uri:</literal> parameter and pointing to
the file URI:
</para>
<programlisting role="php">
<![CDATA[
<?php
/* Connect to an ODBC database using driver invocation */
@ -112,16 +164,16 @@ catch (PDOException $e) {
}
?>
]]>
</programlisting>
</example>
<example><title>Create a PDO instance using an alias</title>
<para>
The following example assumes that &php.ini; contains the following
entry to enable a connection to a MySQL database using only the
alias <literal>mydb</literal>:
<screen>pdo.dsn.mydb=mysql:dbname=testdb;host=127.0.0.1</screen>
</para>
<programlisting role="php">
</programlisting>
</example>
<example><title>Create a PDO instance using an alias</title>
<para>
The following example assumes that &php.ini; contains the following
entry to enable a connection to a MySQL database using only the
alias <literal>mydb</literal>:
<screen>pdo.dsn.mydb=mysql:dbname=testdb;host=127.0.0.1</screen>
</para>
<programlisting role="php">
<![CDATA[
<?php
/* Connect to an ODBC database using an alias */
@ -137,8 +189,9 @@ catch (PDOException $e) {
}
?>
]]>
</programlisting>
</example>
</programlisting>
</example>
</para>
</refsect1>
</refentry>

View file

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='iso-8859-1'?>
<!-- $Revision: 1.3 $ -->
<!-- $Revision: 1.4 $ -->
<!-- Generated by xml_proto.php v2.1. Found in /scripts directory of phpdoc. -->
<refentry id="function.PDOStatement-rowCount">
<refnamediv>
@ -31,6 +31,7 @@
<example><title>Return the number of deleted rows</title>
<programlisting role="php">
<![CDATA[
<?php
/* Delete all rows from the FRUIT table */
$del = $dbh->prepare('DELETE FROM fruit');
$del->execute();
@ -39,6 +40,7 @@ $del->execute();
print("Return number of rows that were deleted:\n");
$count = $del->rowCount();
print("Deleted $count rows.\n");
?>
]]>
</programlisting>
</example>

View file

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<!-- $Revision: 1.2 $ -->
<!-- Generated by xml_proto.php v2.2. Found in /scripts directory of phpdoc. -->
<refentry id="function.PDOStatement-setFetchMode">
<refnamediv>
<refname>PDOStatement::setFetchMode</refname>
<refpurpose>
Returns meta data for a numbered column
Set the default fetch mode for this statement
</refpurpose>
</refnamediv>
<refsect1 role="description">
@ -15,7 +15,7 @@
<methodparam><type>int</type><parameter>mode</parameter></methodparam>
</methodsynopsis>
&warn.undocumented.func;
&warn.experimental.func;
</refsect1>
<refsect1 role="parameters">
@ -26,72 +26,44 @@
<term><parameter>mode</parameter></term>
<listitem>
<para>
Its description
The fetch mode must be one of the <literal>PDO_FETCH_*</literal> constants.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
What the function returns, first on success, then on failure. See
also the &return.success; entity
Returns <literal>1</literal> on success or &false; on failure.
</para>
</refsect1>
<!-- Use when EXCEPTIONS exist
<refsect1 role="exceptions">
&reftitle.exceptions;
<para>
When does this function throw exceptions?
</para>
</refsect1>
-->
<!-- Use when a CHANGELOG exists
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description</entry>
</row>
</thead>
<tbody>
<row>
<entry>Enter the PHP version of change here
<entry>Description of change
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
-->
<!-- Use when examples exist
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>A PDOStatement-setFetchMode example</title>
<title>Setting the fetch mode</title>
<para>
Any text that describes the purpose of the example, or
what goes on in the example should go here (inside the
<example> tag, not out
The following example demonstrates how
<function>PDOStatement::setFetchMode</function> changes the default fetch
mode for a PDOStatement object.
</para>
<programlisting role="php">
<![CDATA[
<?php
if ($anexample === true) {
echo 'Use the PEAR Coding Standards';
$sql = 'SELECT name, colour, calories FROM fruit';
try {
$stmt = $dbh->query($sql);
$result = $stmt->setFetchMode(PDO_FETCH_NUM);
while ($row = $stmt->fetch()) {
print $row[0] . "\t" . $row[1] . "\t" . $row[2] . "\n";
}
}
catch (PDOException $e) {
print $e->getMessage();
}
?>
]]>
@ -99,14 +71,18 @@ if ($anexample === true) {
&example.outputs;
<screen>
<![CDATA[
Use the PEAR Coding Standards
apple red 150
banana yellow 250
orange orange 300
kiwi brown 75
lemon yellow 25
pear green 150
watermelon pink 90
]]>
</screen>
</example>
</para>
</refsect1>
-->
<!-- Use when adding See Also links
<refsect1 role="seealso">