cvs: peardoc /en/package/structures/structures-datagrid example-advanced.xml example-simple.xml
| From: | Andrew Nagy | Date: | Wed, 29 Sep 2004 14:33:09 +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-4898@lists.php.net to get a copy of this message | ||
asnagy Wed Sep 29 10:33:09 2004 EDT
Added files:
/peardoc/en/package/structures/structures-datagrid
example-advanced.xml
example-simple.xml
Log:
Initial Checkin
http://cvs.php.net/co.php/peardoc/en/package/structures/structures-datagrid/example-advanced.xml?r=1.1&p=1
Index: peardoc/en/package/structures/structures-datagrid/example-advanced.xml
+++ peardoc/en/package/structures/structures-datagrid/example-advanced.xml
<?xml version="1.0" encoding="iso-8859-1" ?>
<!-- $Revision: 1.1 $ -->
<refentry id="package.structures.structures-datagrid.intro-simple">
<refnamediv>
<refname>Introduction - Advanced</refname>
<refpurpose>How to bind a data source object</refpurpose>
</refnamediv>
<refsect1 id="package.structures.structures-datagrid.intro-simple.desc">
&title.desc;
<refsect2 id="package.structures.structures-datagrid.intro-simple.desc.bind">
<para>
Follow this example if you are using data objects or more complex data
sources other than arrays. This example will show you how to bind to a
data source that is not an array using the
<link
linkend="package.structures.structures-datagrid.structures_datagrid.bindDataSource">
<function>bindDataSource</function>
</link> method.
</para>
<example>
<title>Binding to a DB_DataObject</title>
<programlisting role="php">
<![CDATA[
<?php
require('Structures/DataGrid.php');
require('myclasses/User.php');
// Define the DataObject
$user = new User();
$user->whereAdd("height > 6");
// Print the DataGrid
$dg = new Structures_DataGrid();
$source &= Structures_DataGrid_Source::create($user);
$dg->bindDataSource($source);
$dg->render();
?>
]]>
</programlisting>
Another way of doing this which is slightly less efficient but is simpler is:
<programlisting role="php">
<![CDATA[
<?php
require('Structures/DataGrid.php');
require('myclasses/User.php');
// Define the DataObject
$user = new User();
$user->whereAdd("height > 6");
// Print the DataGrid
$dg = new Structures_DataGrid();
$dg->bind($user);
$dg->render();
?>
]]>
</programlisting>
The bind method will attempt to determine the nature of the object that you
are passing. If it is able to determine that it is something that it
recognizes, the datagrid will do the rest for you.
</example>
</refsect2>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
http://cvs.php.net/co.php/peardoc/en/package/structures/structures-datagrid/example-simple.xml?r=1.1&p=1
Index: peardoc/en/package/structures/structures-datagrid/example-simple.xml
+++ peardoc/en/package/structures/structures-datagrid/example-simple.xml
<?xml version="1.0" encoding="iso-8859-1" ?>
<!-- $Revision: 1.1 $ -->
<refentry id="package.structures.structures-datagrid.intro-simple">
<refnamediv>
<refname>Introduction - For Beginners</refname>
<refpurpose>Quickly bind a database record set</refpurpose>
</refnamediv>
<refsect1 id="package.structures.structures-datagrid.intro-simple.desc">
&title.desc;
<refsect2 id="package.structures.structures-datagrid.intro-simple.desc.bind">
<para>
To begin binding an existing record set of data to a DataGrid you can
easiy use the
<link
linkend="package.structures.structures-datagrid.structures_datagrid.bind">
<function>bind</function>
</link> method.
</para>
<example>
<title>Binding a result set</title>
<programlisting role="php">
<![CDATA[
<?php
require('Structures/DataGrid.php');
// Get my data
$result = mysql_query('SELECT * FROM users');
while ($rs = mysql_fetch_assoc($result)) {
$dataSet[] = $rs;
}
// Print the DataGrid
$dg = new Structures_DataGrid();
$dg->bind($dataSet);
$dg->render();
?>
]]>
</programlisting>
Or, another way of doing the same thing but more effecient is:
<programlisting role="php">
<![CDATA[
<?php
require('Structures/DataGrid.php');
$dg = new Structures_DataGrid();
// Get my data
$result = mysql_query('SELECT * FROM users');
while ($rs = mysql_fetch_assoc($result)) {
$record = new Structures_DataGrid_Record($rs);
$dg->addRecord($record);
}
// Print the DataGrid
$dg->render();
?>
]]>
</programlisting>
</example>
</refsect2>
</refsect2>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->