cvs: peardoc /en/package/structures/structures-datagrid faq.xml /en/package/structures/structures-datagrid/structures-datagrid-datasource dbtable.xml

[email protected] ("Mark Wiesemann")
Newsgroups php.pear.doc
Message-ID <cvswiesemann1197927537@cvsserver>
wiesemann		Mon Dec 17 21:38:57 2007 UTC

  Modified files:              
    /peardoc/en/package/structures/structures-datagrid	faq.xml 
    /peardoc/en/package/structures/structures-datagrid/structures-datagrid-datasource	
                                                                                     	dbtable.xml 
  Log:
  - new example for DB_Table DataSource driver
  - update FAQ: intendation optimized, mention new PDO driver in answer
  
http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures/structures-datagrid/faq.xml?r1=1.9&r2=1.10&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/faq.xml
diff -u peardoc/en/package/structures/structures-datagrid/faq.xml:1.9 peardoc/en/package/structures/structures-datagrid/faq.xml:1.10
--- peardoc/en/package/structures/structures-datagrid/faq.xml:1.9	Tue Dec 11 16:18:06 2007
+++ peardoc/en/package/structures/structures-datagrid/faq.xml	Mon Dec 17 21:38:56 2007
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.9 $ --> 
+<!-- $Revision: 1.10 $ --> 
 <refentry id="package.structures.structures-datagrid.faq">
  <refnamediv>
   <refname>FAQ</refname>
@@ -63,7 +63,7 @@
     </question>
     <answer>
      <para>
-      Currently there are four DataSource drivers that are recommended in the
+      Currently there are five DataSource drivers that are recommended in the
       sense of efficiency:
      </para>
      <itemizedlist>
@@ -87,6 +87,11 @@
         MDB2
        </para>
       </listitem>
+      <listitem>
+       <para>
+        PDO
+       </para>
+      </listitem>
      </itemizedlist>
      <para>
       These four drivers will only fetch the needed records from the database.
@@ -208,7 +213,7 @@
    <qandaentry>
     <question>
      <para>
-     All the rows are displayed on one page. Why isn't it paging the data?
+      All the rows are displayed on one page. Why isn't it paging the data?
      </para>
     </question>
     <answer>
http://cvs.php.net/viewvc.cgi/peardoc/en/package/structures/structures-datagrid/structures-datagrid-datasource/dbtable.xml?r1=1.9&r2=1.10&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/structures-datagrid-datasource/dbtable.xml
diff -u peardoc/en/package/structures/structures-datagrid/structures-datagrid-datasource/dbtable.xml:1.9 peardoc/en/package/structures/structures-datagrid/structures-datagrid-datasource/dbtable.xml:1.10
--- peardoc/en/package/structures/structures-datagrid/structures-datagrid-datasource/dbtable.xml:1.9	Sun Jul 22 14:41:39 2007
+++ peardoc/en/package/structures/structures-datagrid/structures-datagrid-datasource/dbtable.xml	Mon Dec 17 21:38:57 2007
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.9 $ -->
+<!-- $Revision: 1.10 $ -->
 <refentry id="package.structures.structures-datagrid.structures-datagrid-datasource.dbtable">
  <refnamediv>
   <refname>Structures_DataGrid_DataSource_DBTable</refname>
@@ -125,6 +125,79 @@
    for example, created your database table yourself and did not setup the $idx
    array, you can use the 'primaryKey' option to define the primary key field.
   </para>
+  <para>
+  </para>
+ </refsect1>
+ <refsect1 id="package.structures.structures-datagrid.structures-datagrid-datasource.dbtable.examples">
+  <title>Examples</title>
+  <example>
+   <title>Bind a DB_Table class to Structures_DataGrid</title>
+   <programlisting role="php">
+<![CDATA[
+<?php
+// basic guestbook class that extends DB_Table
+class GuestBook_Table extends DB_Table
+{
+    var $col = array(
+        // unique row ID
+        'id' => array(
+            'type'    => 'integer',
+            'require' => true
+        ),
+        // first name
+        'fname' => array(
+            'type'    => 'varchar',
+            'size'    => 32
+        ),
+        // last name
+        'lname' => array(
+            'type'    => 'varchar',
+            'size'    => 64
+        ),
+        // email address
+        'email' => array(
+            'type'    => 'varchar',
+            'size'    => 128,
+            'require' => true
+        ),
+        // date signed
+        'signdate' => array(
+            'type'    => 'date',
+            'require' => true
+        )
+    );
+    var $idx = array();  // indices don't matter here
+    var $sql = array(
+        // multiple rows for a list 
+        'list' => array( 
+            'select' => 'id, signdate, CONCAT(fname, " ", lname) AS fullname',
+            'order'  => 'signdate DESC'
+        )
+    );
+}
+
+// instantiate the extended DB_Table class
+// (using an existing database connection and the table name 'guestbook')
+$guestbook =& new GuestBook_Table($db, 'guestbook');
+
+// Options for the bind() call
+// (using the predefined query 'list' from the $sql array and a where
+// condition)
+$options = array('view' => 'list', 'where' => 'YEAR(signdate) = 2100');
+
+// bind the guestbook object
+// (if you don't generate any column yourself before rendering, three
+// columns will be generated: id, signdate, fullname)
+$test = $datagrid->bind($guestbook, $options);
+
+// print binding error if any
+if (PEAR::isError($test)) {
+    echo $test->getMessage(); 
+}
+?>
+]]>
+   </programlisting>
+  </example>
  </refsect1>
 </refentry>
 <!-- Keep this comment at the end of the file
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.