示例#1
0
function smarty_function_getone($params, &$smarty)
{
    $record_name = $params['_name'];
    if (!array_key_exists($record_name, $smarty->_tpl_vars) or array_key_exists('_force', $params)) {
        global $php;
        $select = new SelectDB($php->db);
        $select->call_by = 'func';
        $select->put($params);
        $record = $select->getone();
        $smarty->_tpl_vars[$record_name] = $record;
    }
    //if(array_key_exists('_field',$params)) return $smarty->_tpl_vars[$record_name][$params['_field']];
}
 function proc_record($tag, $tag_head)
 {
     $param = self::parse_param($tag);
     $record_name = $param['_name'];
     $record_field = $param['_field'];
     if ($this->{$record_name} != false) {
         $record = $this->{$record_name};
     } else {
         $select = new SelectDB($this->db);
         $select->put($param);
         $record = $select->getone();
         $this->{$record_name} = $record;
     }
     $this->out_content .= $record[$record_field];
     $this->c_content = str_replace($tag_head, '', $this->c_content);
 }