update example to not be misleading with unnecessarily detailed example code

This commit is contained in:
monte.ohrt
2009-02-25 20:13:38 +00:00
parent 22ffa6944c
commit bf27d80052

View File

@@ -94,32 +94,20 @@
function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty) function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
{ {
// do database call here to fetch your template, // do database call here to fetch your template,
// populating $tpl_source // populating $tpl_source with actual template contents
$sql = new SQL; $tpl_source = "This is the template text";
$sql->query("select tpl_source // return true on success, false to generate failure notification
from my_table return true;
where tpl_name='$tpl_name'");
if ($sql->num_rows) {
$tpl_source = $sql->record['tpl_source'];
return true;
} else {
return false;
}
} }
function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty) function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
{ {
// do database call here to populate $tpl_timestamp. // do database call here to populate $tpl_timestamp
$sql = new SQL; // with unix epoch time value of last template modification.
$sql->query("select tpl_timestamp // This is used to determine if recompile is necessary.
from my_table $tpl_timestamp = time(); // this example will always recompile!
where tpl_name='$tpl_name'"); // return true on success, false to generate failure notification
if ($sql->num_rows) { return true;
$tpl_timestamp = $sql->record['tpl_timestamp'];
return true;
} else {
return false;
}
} }
function smarty_resource_db_secure($tpl_name, &$smarty) function smarty_resource_db_secure($tpl_name, &$smarty)