<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {fetch} plugin
 *
 * Type:     function<br>
 * Name:     fetch<br>
 * Purpose:  fetch file, web or ftp data and display results
 * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
 *       (Smarty online manual)
 * @author Monte Ohrt <monte at ohrt dot com>
 * @param array
 * @param Smarty
 * @return string|null if the assign parameter is passed, Smarty assigns the
 *                     result to a template variable
 */

function smarty_function_gettotal($params, &$smarty){
 extract($params); 
 $table = isset($params['intable']) ? $params['intable'] : '';     
 $where = isset($params['inif']) ? $params['inif'] : '';
 if(is_null($table) || is_null($where)){
 return '传入数据不正确';
 	 	}
	$total = 0;  //总记录数
	if($where=="all"){
		$psql = "select * from $table";
		}else{
	$psql = "select * from $table where $where";
}
	$prs = mysql_query($psql);
	if(!$prs){
 	die('参数错误:'.mysql_error());
 	}else{
 	$total = mysql_num_rows($prs);
	if($total){  
   $total = $total;
    }
     else{
    $total = 0;
    }	
	}	
 	
return $total;
    
    
    }  

/* vim: set expandtab: */

?>
