Structures_DataGrid
[ class tree: Structures_DataGrid ] [ index: Structures_DataGrid ] [ all elements ]

Source for file bind-dbtable.php

Documentation is available at bind-dbtable.php

  1. <?php
  2. // basic guestbook class that extends DB_Table
  3. class GuestBook_Table extends DB_Table
  4. {
  5.     var $col = array(
  6.         // unique row ID
  7.         'id' => array(
  8.             'type'    => 'integer',
  9.             'require' => true
  10.         ),
  11.         // first name
  12.         'fname' => array(
  13.             'type'    => 'varchar',
  14.             'size'    => 32
  15.         ),
  16.         // last name
  17.         'lname' => array(
  18.             'type'    => 'varchar',
  19.             'size'    => 64
  20.         ),
  21.         // email address
  22.         'email' => array(
  23.             'type'    => 'varchar',
  24.             'size'    => 128,
  25.             'require' => true
  26.         ),
  27.         // date signed
  28.         'signdate' => array(
  29.             'type'    => 'date',
  30.             'require' => true
  31.         )
  32.     );
  33.     var $idx = array();  // indices don't matter here
  34.     var $sql = array(
  35.         // multiple rows for a list 
  36.         'list' => array
  37.             'select' => 'id, signdate, CONCAT(fname, " ", lname) AS fullname',
  38.             'order'  => 'signdate DESC'
  39.         )
  40.     );
  41. }
  42.  
  43. // instantiate the extended DB_Table class
  44. // (using an existing database connection and the table name 'guestbook')
  45. $guestbook =new GuestBook_Table($db'guestbook');
  46.  
  47. // Options for the bind() call
  48. // (using the predefined query 'list' from the $sql array and a where
  49. // condition)
  50. $options = array('view' => 'list''where' => 'YEAR(signdate) = 2100');
  51.  
  52. // bind the guestbook object
  53. // (if you don't generate any column yourself before rendering, three
  54. // columns will be generated: id, signdate, fullname)
  55. $test $datagrid->bind($guestbook$options);
  56.  
  57. // print binding error if any
  58. if (PEAR::isError($test)) {
  59.     echo $test->getMessage()
  60. }
  61. ?>

Documentation generated on Mon, 11 Mar 2019 15:47:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.