cvs: peardoc /en/package/database/db/db-common getone.xml

From: Date: Sat, 28 Apr 2007 08:31:28 +0000
Subject: cvs: peardoc /en/package/database/db/db-common getone.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-9686@lists.php.net to get a copy of this message
wiesemann Sat Apr 28 08:31:28 2007 UTC Modified files: /peardoc/en/package/database/db/db-common getone.xml Log: - fix line endings

http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/db/db-common/getone.xml?r1=1.29&r2=1.30&diff_format=u Index: peardoc/en/package/database/db/db-common/getone.xml diff -u peardoc/en/package/database/db/db-common/getone.xml:1.29 peardoc/en/package/database/db/db-common/getone.xml:1.30 --- peardoc/en/package/database/db/db-common/getone.xml:1.29 Thu Feb 17 18:42:06 2005 +++ peardoc/en/package/database/db/db-common/getone.xml Sat Apr 28 08:31:28 2007 @@ -1,267 +1,267 @@ -<?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.29 $ --> - -<refentry id="package.database.db.db-common.getone"> - <refnamediv> - <refname>DB_common::getOne()</refname> - <refpurpose>Runs a query and returns the first column of the first row</refpurpose> - </refnamediv> - - <refsynopsisdiv> - <funcsynopsis> - <funcprototype> - <funcdef>mixed <function>&amp;getOne</function></funcdef> - <paramdef> - string <parameter>$query</parameter> - </paramdef> - <paramdef> - mixed <parameter><optional>$params = array()</optional></parameter> - </paramdef> - </funcprototype> - </funcsynopsis> - </refsynopsisdiv> - - <refsect1 id="package.database.db.db-common.getone.desc"> - &title.desc; - <para> - Runs the query provided and returns the - data from the first column of the first row - then frees the result set. - </para> - </refsect1> - - <refsect1 id="package.database.db.db-common.getone.parameter"> - &title.param; - <para> - <variablelist> - <varlistentry> - <term> - &type.string; - <parameter>$query</parameter> - </term> - <listitem> - <para> - the SQL query or the statement to prepare - </para> - </listitem> - </varlistentry> - <varlistentry> - <term> - &type.mixed; - <parameter>$params</parameter> - </term> - <listitem> - <para> - array, string or numeric data to be added to the prepared statement. - Quantity of items passed must match quantity of placeholders in the - prepared statement: meaning 1 placeholder for non-array - parameters or 1 placeholder per array element. - </para> - <para> - If supplied, - <link linkend="package.database.db.intro-execute"> - <function>prepare</function>/ - <function>execute</function></link> is used. - </para> - </listitem> - </varlistentry> - </variablelist> - </para> - </refsect1> - - <refsect1 id="package.database.db.db-common.getone.return"> - &title.returns; - <para> - &type.mixed; - the first column's data - or a &class.db-error; object on failure - </para> - </refsect1> - - <refsect1 id="package.database.db.db-common.getone.throws"> - &title.throws; - <para> - <table> - <title>&title.throws.errortable;</title> - <tgroup cols="4"> - <thead> - <row> - <entry>Error code</entry> - <entry>Error message</entry> - <entry>Reason</entry> - <entry>Solution</entry> - </row> - </thead> - <tbody> - <row> - <entry><constant>DB_ERROR_INVALID</constant></entry> - <entry> - invalid - </entry> - <entry> - SQL statment for preparing is not valid. - </entry> - <entry> - See the <link linkend="package.database.db.db-common.prepare"> - <function>prepare</function> documentation</link>, - if you want to use a SQL statemt using placeholders. - </entry> - </row> - <row> - <entry><constant>DB_ERROR_MISMATCH</constant></entry> - <entry> - mismatch - </entry> - <entry> - Quantity of parameters didn't match quantity of placeholders in - the prepared statment. - </entry> - <entry> - Check that the number of placeholders in the - <link linkend="package.database.db.db-common.prepare"> - <function>prepare</function></link> statement passed to - <parameter>$query</parameter> equals the count of entries - passed to <parameter>$params</parameter>. - </entry> - </row> - <row> - <entry><constant>DB_ERROR_NODBSELECTED</constant></entry> - <entry> - no database selected - </entry> - <entry> - No database was choosen. - </entry> - <entry> - Check the <link linkend="package.database.db.intro-dsn">DSN</link> - in <link linkend="package.database.db.db.connect"> - <function>connect</function></link>. - </entry> - </row> - <row> - <entry>every other error code</entry> - <entry></entry> - <entry> - Database specific error - </entry> - <entry> - Check the database related section of - <ulink url="&url.php.manual;">PHP-Manual</ulink> - to detect the reason for this error. In the most cases - a misformed SQL statment. Ie. using LIMIT in a SQL-Statment - for an Oracle database. - </entry> - </row> - </tbody> - </tgroup> - </table> - </para> - </refsect1> - - <refsect1 id="package.database.db.db-common.getone.note"> - &title.note; - &note.notstatic; - </refsect1> - - <refsect1 id="package.database.db.db-common.getOne.example"> - &title.example; - <example> - <title>Using <function>getOne</function></title> - <programlisting role="php"> - <![CDATA[ -<?php -// Once you have a valid DB object named $db... -$data =& $db->getOne('SELECT cf FROM foo'); - -if (PEAR::isError($data)) { - die($data->getMessage()); -} - -echo "$data\n"; -?> - ]]> - </programlisting> - </example> - - <example> - <title> - Using <function>getOne</function> - with one placeholder - </title> - <programlisting role="php"> - <![CDATA[ -<?php -// Once you have a valid DB object named $db... -$data =& $db->getOne('SELECT cf FROM foo WHERE nf = ?', - 5); - -if (PEAR::isError($data)) { - die($data->getMessage()); -} - -echo "$data\n"; -?> - ]]> - </programlisting> - </example> - - <example> - <title> - Using <function>getOne</function> - with two placeholders - </title> - <programlisting role="php"> - <![CDATA[ -<?php -// Once you have a valid DB object named $db... -$data =& $db->getOne('SELECT cf FROM foo WHERE nf IN (?, ?)', - array(5, 10)); - -if (PEAR::isError($data)) { - die($data->getMessage()); -} - -echo "$data\n"; -?> - ]]> - </programlisting> - </example> - </refsect1> - - <refsect1 id="package.database.db.db-common.getone.see"> - &title.see; - <para> - <link linkend="package.database.db.db-common.getrow"> - <function>getRow</function></link>, - <link linkend="package.database.db.db-common.getcol"> - <function>getCol</function></link>, - <link linkend="package.database.db.db-common.getassoc"> - <function>getAssoc</function></link>, - <link linkend="package.database.db.db-common.getall"> - <function>getAll</function></link>, - <link linkend="package.database.db.db-common.query"> - <function>query</function></link>, - <link linkend="package.database.db.intro-execute"> - <quote>Intro - Prepare &amp; Execute</quote></link> - </para> - </refsect1> -</refentry> - -<!-- 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-executeMultiple-attributes:t -sgml-indent-step:1 -sgml-indent-data:t -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 ---> +<?xml version="1.0" encoding="iso-8859-1" ?> +<!-- $Revision: 1.30 $ --> + +<refentry id="package.database.db.db-common.getone"> + <refnamediv> + <refname>DB_common::getOne()</refname> + <refpurpose>Runs a query and returns the first column of the first row</refpurpose> + </refnamediv> + + <refsynopsisdiv> + <funcsynopsis> + <funcprototype> + <funcdef>mixed <function>&amp;getOne</function></funcdef> + <paramdef> + string <parameter>$query</parameter> + </paramdef> + <paramdef> + mixed <parameter><optional>$params = array()</optional></parameter> + </paramdef> + </funcprototype> + </funcsynopsis> + </refsynopsisdiv> + + <refsect1 id="package.database.db.db-common.getone.desc"> + &title.desc; + <para> + Runs the query provided and returns the + data from the first column of the first row + then frees the result set. + </para> + </refsect1> + + <refsect1 id="package.database.db.db-common.getone.parameter"> + &title.param; + <para> + <variablelist> + <varlistentry> + <term> + &type.string; + <parameter>$query</parameter> + </term> + <listitem> + <para> + the SQL query or the statement to prepare + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + &type.mixed; + <parameter>$params</parameter> + </term> + <listitem> + <para> + array, string or numeric data to be added to the prepared statement. + Quantity of items passed must match quantity of placeholders in the + prepared statement: meaning 1 placeholder for non-array + parameters or 1 placeholder per array element. + </para> + <para> + If supplied, + <link linkend="package.database.db.intro-execute"> + <function>prepare</function>/ + <function>execute</function></link> is used. + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + + <refsect1 id="package.database.db.db-common.getone.return"> + &title.returns; + <para> + &type.mixed; - the first column's data + or a &class.db-error; object on failure + </para> + </refsect1> + + <refsect1 id="package.database.db.db-common.getone.throws"> + &title.throws; + <para> + <table> + <title>&title.throws.errortable;</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Error code</entry> + <entry>Error message</entry> + <entry>Reason</entry> + <entry>Solution</entry> + </row> + </thead> + <tbody> + <row> + <entry><constant>DB_ERROR_INVALID</constant></entry> + <entry> + invalid + </entry> + <entry> + SQL statment for preparing is not valid. + </entry> + <entry> + See the <link linkend="package.database.db.db-common.prepare"> + <function>prepare</function> documentation</link>, + if you want to use a SQL statemt using placeholders. + </entry> + </row> + <row> + <entry><constant>DB_ERROR_MISMATCH</constant></entry> + <entry> + mismatch + </entry> + <entry> + Quantity of parameters didn't match quantity of placeholders in + the prepared statment. + </entry> + <entry> + Check that the number of placeholders in the + <link linkend="package.database.db.db-common.prepare"> + <function>prepare</function></link> statement passed to + <parameter>$query</parameter> equals the count of entries + passed to <parameter>$params</parameter>. + </entry> + </row> + <row> + <entry><constant>DB_ERROR_NODBSELECTED</constant></entry> + <entry> + no database selected + </entry> + <entry> + No database was choosen. + </entry> + <entry> + Check the <link linkend="package.database.db.intro-dsn">DSN</link> + in <link linkend="package.database.db.db.connect"> + <function>connect</function></link>. + </entry> + </row> + <row> + <entry>every other error code</entry> + <entry></entry> + <entry> + Database specific error + </entry> + <entry> + Check the database related section of + <ulink url="&url.php.manual;">PHP-Manual</ulink> + to detect the reason for this error. In the most cases + a misformed SQL statment. Ie. using LIMIT in a SQL-Statment + for an Oracle database. + </entry> + </row> + </tbody> + </tgroup> + </table> + </para> + </refsect1> + + <refsect1 id="package.database.db.db-common.getone.note"> + &title.note; + &note.notstatic; + </refsect1> + + <refsect1 id="package.database.db.db-common.getOne.example"> + &title.example; + <example> + <title>Using <function>getOne</function></title> + <programlisting role="php"> + <![CDATA[ +<?php +// Once you have a valid DB object named $db... +$data =& $db->getOne('SELECT cf FROM foo'); + +if (PEAR::isError($data)) { + die($data->getMessage()); +} + +echo "$data\n"; +?> + ]]> + </programlisting> + </example> + + <example> + <title> + Using <function>getOne</function> + with one placeholder + </title> + <programlisting role="php"> + <![CDATA[ +<?php +// Once you have a valid DB object named $db... +$data =& $db->getOne('SELECT cf FROM foo WHERE nf = ?', + 5); + +if (PEAR::isError($data)) { + die($data->getMessage()); +} + +echo "$data\n"; +?> + ]]> + </programlisting> + </example> + + <example> + <title> + Using <function>getOne</function> + with two placeholders + </title> + <programlisting role="php"> + <![CDATA[ +<?php +// Once you have a valid DB object named $db... +$data =& $db->getOne('SELECT cf FROM foo WHERE nf IN (?, ?)', + array(5, 10)); + +if (PEAR::isError($data)) { + die($data->getMessage()); +} + +echo "$data\n"; +?> + ]]> + </programlisting> + </example> + </refsect1> + + <refsect1 id="package.database.db.db-common.getone.see"> + &title.see; + <para> + <link linkend="package.database.db.db-common.getrow"> + <function>getRow</function></link>, + <link linkend="package.database.db.db-common.getcol"> + <function>getCol</function></link>, + <link linkend="package.database.db.db-common.getassoc"> + <function>getAssoc</function></link>, + <link linkend="package.database.db.db-common.getall"> + <function>getAll</function></link>, + <link linkend="package.database.db.db-common.query"> + <function>query</function></link>, + <link linkend="package.database.db.intro-execute"> + <quote>Intro - Prepare &amp; Execute</quote></link> + </para> + </refsect1> +</refentry> + +<!-- 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-executeMultiple-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +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 +-->
« previous php.pear.doc (#9686) next »