cvs: peardoc /en/package/database db.xml /en/package/database/db overview-get.xml

From: Date: Thu, 10 Apr 2008 19:56:29 +0000
Subject: cvs: peardoc /en/package/database db.xml /en/package/database/db overview-get.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-10647@lists.php.net to get a copy of this message
cweiske Thu Apr 10 19:56:29 2008 UTC Added files: /peardoc/en/package/database/db overview-get.xml Modified files: /peardoc/en/package/database db.xml Log: DB get* overview and result comparison http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/db.xml?r1=1.23&r2=1.24&diff_format=u Index: peardoc/en/package/database/db.xml diff -u peardoc/en/package/database/db.xml:1.23 peardoc/en/package/database/db.xml:1.24 --- peardoc/en/package/database/db.xml:1.23 Sun Jun 24 17:18:39 2007 +++ peardoc/en/package/database/db.xml Thu Apr 10 19:56:29 2008 @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.23 $ --> +<!-- $Revision: 1.24 $ --> <sect1 id="package.database.db"> <title>DB</title> - + <warning> <para> This package has been superseded. Please use @@ -24,6 +24,8 @@ &package.database.db.intro-portability; &package.database.db.intro-sequences; + &package.database.db.overview-get; + &package.database.db.db; &package.database.db.db.connect; &package.database.db.db.iserror; http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/db/overview-get.xml?view=markup&rev=1.1 Index: peardoc/en/package/database/db/overview-get.xml +++ peardoc/en/package/database/db/overview-get.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <refentry id="package.database.db.overview-get"> <refnamediv> <refname>Overview - get* methods</refname> <refpurpose>Comparison of get* methods</refpurpose> </refnamediv> <refsect1 id="package.database.db.overview-get.desc"> &title.desc; <para> This page gives an overview about the methods that allow you to fetch entire result sets without looping over single result rows: <link linkend="package.database.db.db-common.getone"> <function>getOne</function></link>, <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> and <link linkend="package.database.db.db-common.getall"> <function>getAll</function></link>. </para> <para> Our data source is the following table: <table> <title>Data used in this example</title> <tgroup cols="3"> <thead> <row> <entry>id</entry> <entry>nickname</entry> <entry>email</entry> </row> </thead> <tbody> <row> <entry>1</entry> <entry>pinky</entry> <entry>pinky@domination.org</entry> </row> <row> <entry>2</entry> <entry>thebrain</entry> <entry>brain@dominators.net</entry> </row> </tbody> </tgroup> </table> </para> <para> A simple <function>var_dump</function> is used to make clear in which use cases the methods can be used: <programlisting role="php"><![CDATA[ <?php require_once 'DB.php'; $db = DB::connect('mysql://user:pass@localhost/example'); var_dump( $db->getOne('SELECT nickname, id, email FROM users') ); ?>]]></programlisting> </para> </refsect1> <refsect1 id="package.database.db.overview-get.getone"> <title>getOne</title> <para> <link linkend="package.database.db.db-common.getone"> <function>getOne</function></link> fetches the first column of the first row. <screen><![CDATA[ string(5) "pinky" ]]></screen> </para> </refsect1> <refsect1 id="package.database.db.overview-get.getrow"> <title>getRow</title> <para> <link linkend="package.database.db.db-common.getrow"> <function>getRow</function></link> fetches the first row. <screen><![CDATA[ array(3) { [0] => string(5) "pinky" [1] => string(1) "1" [2] => string(20) "pinky@domination.org" } ]]></screen> </para> </refsect1> <refsect1 id="package.database.db.overview-get.getcol"> <title>getCol</title> <para> <link linkend="package.database.db.db-common.getcol"> <function>getCol</function></link> fetches the first column of all rows. <screen><![CDATA[ array(2) { [0]=> string(5) "pinky" [1]=> string(8) "thebrain" } ]]></screen> </para> </refsect1> <refsect1 id="package.database.db.overview-get.getassoc"> <title>getAssoc</title> <para> <link linkend="package.database.db.db-common.getassoc"> <function>getAssoc</function></link> fetches all rows into an array, using the first colum of the rows as array key. This column is removed from the array itself. <screen><![CDATA[ array(2) { ["pinky"] => array(2) { [0] => string(1) "1" [1] => string(20) "pinky@domination.org" } ["thebrain"] => array(2) { [0] => string(1) "2" [1] => string(20) "brain@dominators.net" } } ]]></screen> </para> </refsect1> <refsect1 id="package.database.db.overview-get.getall"> <title>getAll</title> <para> <link linkend="package.database.db.db-common.getall"> <function>getAll</function></link> fetches all columns from all rows into an array. <screen><![CDATA[ array(2) { [0] => array(3) { [0] => string(5) "pinky" [1] => string(1) "1" [2] => string(20) "pinky@domination.org" } [1] => array(3) { [0] => string(8) "thebrain" [1] => string(1) "2" [2] => string(20) "brain@dominators.net" } } ]]></screen> </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-quote-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 (#10647) next »