cvs: peardoc /en/package/structures/structures-datagrid/structures-datagrid addrecord.xml

From: Date: Thu, 24 Mar 2005 15:48:52 +0000
Subject: cvs: peardoc /en/package/structures/structures-datagrid/structures-datagrid addrecord.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-5724@lists.php.net to get a copy of this message
asnagy Thu Mar 24 10:48:52 2005 EDT Modified files: /peardoc/en/package/structures/structures-datagrid/structures-datagrid addrecord.xml Log: Updated doc http://cvs.php.net/diff.php/peardoc/en/package/structures/structures-datagrid/structures-datagrid/addrecord.xml?r1=1.3&r2=1.4&ty=u Index: peardoc/en/package/structures/structures-datagrid/structures-datagrid/addrecord.xml diff -u peardoc/en/package/structures/structures-datagrid/structures-datagrid/addrecord.xml:1.3 peardoc/en/package/structures/structures-datagrid/structures-datagrid/addrecord.xml:1.4 --- peardoc/en/package/structures/structures-datagrid/structures-datagrid/addrecord.xml:1.3 Sat Jan 29 06:40:40 2005 +++ peardoc/en/package/structures/structures-datagrid/structures-datagrid/addrecord.xml Thu Mar 24 10:48:52 2005 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1" ?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <refentry id="package.structures.structures_datagrid.structures_datagrid.addrecord"> <refnamediv> @@ -11,7 +11,7 @@ <refsynopsisdiv> <funcsynopsis> <funcprototype> - <funcdef>array <function>Structures_DataGrid::addRecord</function></funcdef> + <funcdef>mixed <function>Structures_DataGrid::addRecord</function></funcdef> <paramdef> Structures_DataGrid_Record <parameter>$record</parameter> </paramdef> @@ -22,12 +22,14 @@ <refsect1 id="package.structures.structures_datagrid.structures_datagrid.addrecord.desc"> &title.desc; <para> - This method adds a record in array format, prefferably an assosiative array, - to the Record Collection. If you have an array of associative arrays, such - as a record set from a database or an <acronym>XML</acronym> or - <acronym>CSV</acronym> document, you will be better of to use the - <link linkend="package.structures.structures_datagrid.structures_datagrid.bind"><function>bind</function></link> - method. + This method is used to add a Structures_DataGrid_Record object to the + DataGrid's Record Set. This is not the only method of getting data into + the DataGrid. Commonly, the + <link linkend="package.structures.structures_datagrid.structures_datagrid.bind"><function>Bind()</function></link> + method is used, unleass you need to add individual records to the DataGrid. + The Structures_DataGrid_Record object accepts an array of values. This + method works best for looping through a result set from a database query + or a XML or CSV data file. </para> </refsect1> @@ -37,12 +39,16 @@ <variablelist> <varlistentry> <term> - <classname>Structures_DataGrid_Record</classname> + &type.object; <parameter>$record</parameter> </term> <listitem> <para> - The &class.structures-datagrid-record; object to be added to the Record Collection. + The record must be of type Structures_DataGrid_Record to be added to the + DataGrid. Currently their are 2 other available record classes, a DB and + a DB_DataObject record class, that exist in the package as well. This + will allow you to extend the existing record class for a custom record + driver. </para> </listitem> </varlistentry> @@ -50,44 +56,12 @@ </para> </refsect1> - <refsect1 id="package.structures.structures_datagrid.structures_datagrid.addrecord.note"> - &title.note; + <refsect1 id="package.structures.structures_datagrid.structures_datagrid.addrecord.return"> + &title.returns; <para> - If you would like to add a <classname>DB_DataObject</classname> or &class.db-result; record, you can use - this method but you will need to use the - Structures_DataGrid_Record_DataObject or Structures_DataGrid_Record_DB class - respectively. However, this practice for the DB_DataObject and DB_Result - should only be used if absolutely necessary as the bind method is the - preferred method. + &type.mixed; - &true; upon success otherwise a &class.pear-error; upon failure. </para> </refsect1> - - <refsect1 id="package.structures.structures_datagrid.structures_datagrid.addrecord.example"> - &title.example; - <example> - <title>Adding a record set from a MySql database</title> - <programlisting role="php"> - <![CDATA[ -<?php -require_once 'Structures/DataGrid.php'; - -$conn = mysql_connect(...my database connection...); -$db = mysql_select_db(... my db ...); - -$dg =& new Structures_DataGrid(); - -$result = mysql_query("SELECT * FROM user WHERE hair = 'Red'"); -while ($record = mysql_fetch_assoc($result)) { - $dg->addRecord(new Structures_DataGrid_Record($record)); -} - -$dg->render(); -?> - ]]> - </programlisting> - </example> - </refsect1> - </refentry> @@ -109,4 +83,4 @@ vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 ---> \ No newline at end of file +-->

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