cvs: peardoc /en/package/structures/structures-datagrid/structures-datagrid bind.xml
| From: | Andrew Nagy | Date: | Thu, 09 Dec 2004 18:36:06 +0000 |
| Subject: | cvs: peardoc /en/package/structures/structures-datagrid/structures-datagrid bind.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-5253@lists.php.net to get a copy of this message | ||
asnagy Thu Dec 9 13:36:06 2004 EDT
Modified files:
/peardoc/en/package/structures/structures-datagrid/structures-datagrid
bind.xml
Log:
Added examples, copied the syntax from DB_DataObject->fetch
http://cvs.php.net/diff.php/peardoc/en/package/structures/structures-datagrid/structures-datagrid/bind.xml?r1=1.4&r2=1.5&ty=u
Index: peardoc/en/package/structures/structures-datagrid/structures-datagrid/bind.xml
diff -u peardoc/en/package/structures/structures-datagrid/structures-datagrid/bind.xml:1.4
peardoc/en/package/structures/structures-datagrid/structures-datagrid/bind.xml:1.5
--- peardoc/en/package/structures/structures-datagrid/structures-datagrid/bind.xml:1.4 Tue Nov 2
02:26:41 2004
+++ peardoc/en/package/structures/structures-datagrid/structures-datagrid/bind.xml Thu Dec 9
13:36:06 2004
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.4 $ -->
+<!-- $Revision: 1.5 $ -->
<refentry id="package.structures.structures_datagrid.structures_datagrid.bind">
<refnamediv>
@@ -11,7 +11,7 @@
<funcprototype>
<funcdef>mixed <function>bind</function></funcdef>
<paramdef>
- mixed <parameter>$rs</parameter>
+ mixed <parameter>$data</parameter>
</paramdef>
</funcprototype>
</funcsynopsis>
@@ -36,12 +36,13 @@
<variablelist>
<varlistentry>
<term>
- &type.array;
- <parameter>$rs</parameter>
+ &type.mixed;
+ <parameter>$data</parameter>
</term>
<listitem>
<para>
The record set in any of the supported data source types
+ (i.e. DB_DataObject, DB_Result, XML, RSS, Array)
</para>
</listitem>
</varlistentry>
@@ -52,10 +53,68 @@
<refsect1
id="package.structures.structures_datagrid.structures_datagrid.bind.return">
&title.returns;
<para>
- &type.mixed; - True upon success otherwise a &class.pear-error; upon failure
+ &type.mixed; - &true; upon success otherwise a &class.pear-error; upon failure
</para>
</refsect1>
+ <refsect1
id="package.structures.structures_datagrid.structures_datagrid.bind.example">
+ &title.example;
+ <example>
+ <title>Bind datagrid to a DB_DataObject</title>
+ <programlisting role="php">
+ <![CDATA[
+$dg = new Structures_DataGrid(20);
+
+$person = new DataObjects_Person;
+
+$person->hair = 'red';
+$person->has_glasses = 1;
+
+// The datagrid will bind the dataobject and only select the first 20 records
+$dg->bind($person);
+
+$dg->render();
+
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Bind datagrid to a DB_Result Object with DataGrid paging</title>
+ <programlisting role="php">
+ <![CDATA[
+$dg = new Structures_DataGrid(20);
+
+$result = $db->query("SELECT * FROM person WHERE hair='red' AND
has_glasses=1");
+
+// The datagrid will bind the db_result object and only show the first 20 records
+// This is not the most optimal way, because the datagrid will load all of the
+// records and then limit down to 20, but will allow for paging.
+$dg->bind($result);
+
+$dg->render();
+
+]]>
+ </programlisting>
+ </example>
+ <example>
+ <title>Bind datagrid to a DB_Result Object with Database paging</title>
+ <programlisting role="php">
+ <![CDATA[
+$dg = new Structures_DataGrid();
+
+$result = $db->query("SELECT * FROM person WHERE hair='red' AND has_glasses=1
LIMIT 20");
+
+// The datagrid will bind the db_result object and show all of the first 20 records
+// In order to use paging, you must use a seperate Pager object.
+$dg->bind($result);
+
+$dg->render();
+
+]]>
+ </programlisting>
+ </example>
+ </refsect1>
+
</refentry>
<!-- Keep this comment at the end of the file