<?php
/* project: Class gridform demo, file: index.php */
//Include pclib framework
require 'pclib/pclib.php';
use pclib\extensions\GridForm;
//Create pclib application
$app = new PCApp('demo');
$datasource = 'pdo_mysql://user:password@localhost/test';
$app->db = new PCDb($datasource);
//Initialize gridform template
$gridForm = new GridForm('tpl/gridform.tpl');
//Set grid query and write grid out
$gridForm->setQuery('select *,if(quantityInStock > 1000,1,0) inStock from PRODUCTS');
//If grid has been submitted, update table PRODUCTS
if ($gridForm->submitted) {
printf("<h3>Submitted values in 'rowdata':</h3> <pre>%s</pre>",
json_encode($gridForm->values /*, JSON_PRETTY_PRINT*/)
);
//$gridForm->update('PRODUCTS');
}
print $gridForm;
?>
Elapsed time: 5.75 ms