cvs: peardoc /en/package/structures/structures-datagrid example-advanced.xml example-simple.xml
| From: | Olivier Guilyardi | Date: | Tue, 02 May 2006 21:04:24 +0000 |
| Subject: | cvs: peardoc /en/package/structures/structures-datagrid example-advanced.xml example-simple.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-7862@lists.php.net to get a copy of this message | ||
olivierg Tue May 2 21:04:24 2006 UTC
Modified files:
/peardoc/en/package/structures/structures-datagrid
example-advanced.xml
example-simple.xml
Log:
Added binding and rendering error checking
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/structures/structures-datagrid/example-advanced.xml?r1=1.18&r2=1.19&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/example-advanced.xml
diff -u peardoc/en/package/structures/structures-datagrid/example-advanced.xml:1.18
peardoc/en/package/structures/structures-datagrid/example-advanced.xml:1.19
--- peardoc/en/package/structures/structures-datagrid/example-advanced.xml:1.18 Thu Apr 27 13:03:48
2006
+++ peardoc/en/package/structures/structures-datagrid/example-advanced.xml Tue May 2 21:04:24 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.18 $ -->
+<!-- $Revision: 1.19 $ -->
<refentry id="package.structures.structures-datagrid.example-advanced">
<refnamediv>
@@ -31,18 +31,21 @@
$user = new User_DataObject();
// Create the DataGrid, and bind the DataSource container
-$dg =& new Structures_DataGrid(20); // Display 20 records per page
-$dg->bind($user);
+$datagrid =& new Structures_DataGrid(20); // Display 20 records per page
+$test = $datagrid->bind($user);
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
// Specify how the DataGrid should be sorted by default
-$dg->setDefaultSort(array('lname' => 'ASC'));
+$datagrid->setDefaultSort(array('lname' => 'ASC'));
// Define columns
-$dg->addColumn(new Structures_DataGrid_Column(null, null, null, array('width' =>
'10'), null, 'printCheckbox()'));
-$dg->addColumn(new Structures_DataGrid_Column('Name', null, 'lname',
array('width' => '40%'), null, 'printFullName()'));
-$dg->addColumn(new Structures_DataGrid_Column('Username', 'username',
'username', array('width' => '20%')));
-$dg->addColumn(new Structures_DataGrid_Column('Role', null, null,
array('width' => '20%'), null, 'printRoleSelector()'));
-$dg->addColumn(new Structures_DataGrid_Column('Edit', null, null,
array('width' => '20%'), null, 'printEditLink()'));
+$datagrid->addColumn(new Structures_DataGrid_Column(null, null, null, array('width'
=> '10'), null, 'printCheckbox()'));
+$datagrid->addColumn(new Structures_DataGrid_Column('Name', null, 'lname',
array('width' => '40%'), null, 'printFullName()'));
+$datagrid->addColumn(new Structures_DataGrid_Column('Username', 'username',
'username', array('width' => '20%')));
+$datagrid->addColumn(new Structures_DataGrid_Column('Role', null, null,
array('width' => '20%'), null, 'printRoleSelector()'));
+$datagrid->addColumn(new Structures_DataGrid_Column('Edit', null, null,
array('width' => '20%'), null, 'printEditLink()'));
// Define the Look and Feel
$tableAttribs = array(
@@ -71,7 +74,11 @@
$tableBody =& $table->getBody();
// Ask the DataGrid to fill the HTML_Table with data, using rendering options
-$dg->fill($table, $rendererOptions);
+$test = $datagrid->fill($table, $rendererOptions);
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
+
// Set attributes for the header row
$tableHeader->setRowAttributes(0, $headerAttribs);
@@ -83,7 +90,11 @@
echo $table->toHtml();
// Display paging links
-$datagrid->render(DATAGRID_RENDER_PAGER);
+$test = $datagrid->render(DATAGRID_RENDER_PAGER);
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
+
function printCheckbox($params)
{
http://cvs.php.net/viewcvs.cgi/peardoc/en/package/structures/structures-datagrid/example-simple.xml?r1=1.13&r2=1.14&diff_format=u
Index: peardoc/en/package/structures/structures-datagrid/example-simple.xml
diff -u peardoc/en/package/structures/structures-datagrid/example-simple.xml:1.13
peardoc/en/package/structures/structures-datagrid/example-simple.xml:1.14
--- peardoc/en/package/structures/structures-datagrid/example-simple.xml:1.13 Sun Apr 23 21:52:27
2006
+++ peardoc/en/package/structures/structures-datagrid/example-simple.xml Tue May 2 21:04:24 2006
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
-<!-- $Revision: 1.13 $ -->
+<!-- $Revision: 1.14 $ -->
<refentry id="package.structures.structures-datagrid.example-simple">
<refnamediv>
@@ -35,10 +35,21 @@
$options = array('dsn' => 'mysql://user:password@host/db_name');
// Bind a basic SQL statement as datasource
-$datagrid->bind('SELECT * FROM my_table', $options);
+$test = $datagrid->bind('SELECT * FROM my_table', $options);
+
+// Print binding error if any
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
// Print the DataGrid with the default renderer (HTML Table)
-$datagrid->render();
+$test = $datagrid->render();
+
+// Print rendering error if any
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
+
?>
]]>
</programlisting>
@@ -64,13 +75,23 @@
// Setup your datasource
$options = array('dsn' => 'mysql://user:password@host/db_name');
-$datagrid->bind("SELECT * FROM my_table", $options);
+$test = $datagrid->bind("SELECT * FROM my_table", $options);
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
// Print the DataGrid with the default renderer (HTML Table)
-$datagrid->render();
+$test = $datagrid->render();
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
// Print the HTML paging links
-$datagrid->render(DATAGRID_RENDER_PAGER);
+$test = $datagrid->render(DATAGRID_RENDER_PAGER);
+if (PEAR::isError($test)) {
+ echo $test->getMessage();
+}
+
?>
]]>
</programlisting>