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

From: Date: Tue, 27 Jan 2004 22:15:40 +0000
Subject: cvs: peardoc /en/package/database/db/db-common tableinfo.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-2222@lists.php.net to get a copy of this message
danielc Tue Jan 27 17:15:40 2004 EDT Modified files: /peardoc/en/package/database/db/db-common tableinfo.xml Log: Really document the method. http://cvs.php.net/diff.php/peardoc/en/package/database/db/db-common/tableinfo.xml?r1=1.2&r2=1.3&ty=u Index: peardoc/en/package/database/db/db-common/tableinfo.xml diff -u peardoc/en/package/database/db/db-common/tableinfo.xml:1.2 peardoc/en/package/database/db/db-common/tableinfo.xml:1.3 --- peardoc/en/package/database/db/db-common/tableinfo.xml:1.2 Tue Jan 27 13:57:30 2004 +++ peardoc/en/package/database/db/db-common/tableinfo.xml Tue Jan 27 17:15:39 2004 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <refentry id="package.database.db.db-common.tableinfo"> <refnamediv> <refname>DB_result::tableInfo()</refname> @@ -7,8 +7,8 @@ <refsynopsisdiv> <funcsynopsis> <funcprototype> - <funcdef>boolean <function>tableInfo</function></funcdef> - <paramdef>resource <parameter>$result</parameter></paramdef> + <funcdef>array <function>tableInfo</function></funcdef> + <paramdef>mixed <parameter>$result</parameter></paramdef> <paramdef>int <parameter><optional>$mode = &null;</optional></parameter></paramdef> </funcprototype> </funcsynopsis> @@ -16,23 +16,196 @@ <refsect1 id="package.database.db.db-common.tableinfo.desc"> &title.desc; <para> - Fetch table information from <parameter>result</parameter> query. + Get information about columns in a table or a query result. </para> </refsect1> + <refsect1 id="package.database.db.db-common.getone.parameter"> + &title.param; + <para> + <variablelist> + <varlistentry> + <term> + &type.mixed; + <parameter>$result</parameter> + </term> + <listitem> + <para> + &class.db-result; object from a query + or a string containing the name of a table + </para> + <para> + This can also be a query result resource identifier, + but doing so is deprecated. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + &type.int; + <parameter>$mode</parameter> + </term> + <listitem> + <para> + one of the tableInfo mode constants + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + <refsect1 id="package.database.db.db-common.tableinfo.return"> &title.returns; <para> - Returns an associative array of table and field information. + Returns an associative array of column information. + &class.db-error; object if problems arise. </para> + <para> + The array's contents depends on the <parameter>mode</parameter> + parameter. + </para> + </refsect1> - &warn.undocumented.func; - + <refsect1 id="package.database.db.db-common.tableinfo.modes"> + <title>tableInfo Modes</title> + <para> + This section describes the format of the returned array and how + it varies depending on which <parameter>mode</parameter> was used + when the function was called. + </para> + <para> + The sample output below is based on this query: + <programlisting role="php"> + <![CDATA[ +SELECT tblFoo.fldID, tblFoo.fldPhone, tblBar.fldId + FROM tblFoo + JOIN tblBar ON tblFoo.fldId = tblBar.fldId; +]]> + </programlisting> + </para> + <para> + <variablelist> + <varlistentry> + <term> + &null; + </term> + <listitem> + <para> + </para> + <para> + <programlisting role="php"> + <![CDATA[ +[0] => Array ( + [table] => tblFoo + [name] => fldId + [type] => int + [len] => 11 + [flags] => primary_key not_null +) +[1] => Array ( + [table] => tblFoo + [name] => fldPhone + [type] => string + [len] => 20 + [flags] => +) +[2] => Array ( + [table] => tblBar + [name] => fldId + [type] => int + [len] => 11 + [flags] => primary_key not_null +) +]]> + </programlisting> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>DB_TABLEINFO_ORDER</constant> + </term> + <listitem> + <para> + In addition to the information found in the default output, + a notation of the number of columns is provided by the + <literal>num_fields</literal> element while the + <literal>order</literal> + element provides an array with the column names as the keys and + their location index number (corresponding to the keys in the + the default output) as the values. + </para> + <para> + If a result set has identical field names, the last one is + used. + </para> + <para> + <programlisting role="php"> + <![CDATA[ +[num_fields] => 3 +[order] => Array ( + [fldId] => 2 + [fldTrans] => 1 +) +]]> + </programlisting> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>DB_TABLEINFO_ORDERTABLE</constant> + </term> + <listitem> + <para> + Similar to <constant>DB_TABLEINFO_ORDER</constant> but adds more + dimensions to the array in which the table names are keys and + the field names are sub-keys. This is helpful for queries that + join tables which have identical field names. + </para> + <para> + <programlisting role="php"> + <![CDATA[ +[num_fields] => 3 +[ordertable] => Array ( + [tblFoo] => Array ( + [fldId] => 0 + [fldPhone] => 1 + ) + [tblBar] => Array ( + [fldId] => 2 + ) +) +]]> + </programlisting> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>DB_TABLEINFO_FULL</constant> + </term> + <listitem> + <para> + Contains the information from both + <constant>DB_TABLEINFO_ORDER</constant> and + <constant>DB_TABLEINFO_ORDERTABLE</constant> + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + <para> + The tableInfo mode constants are bitwised, so they can be + combined using <screen>|</screen>. + </para> </refsect1> <refsect1 id="package.database.db.db-common.tableinfo.note"> &title.note; &note.notstatic; </refsect1> </refentry> + <!-- Keep this comment at the end of the file Local variables: mode: sgml

« previous php.pear.doc (#2222) next »