在sql语句中使用{}将php变量扩起来,php就会解析{}中的内容。
//案件统计
function getCount($dsql,$tableName,$year){
//诉讼案件总数,总金额
$year_="20".$year."%";
$sqlcount = "select count(*) as num,sum(charge) as money from $tableName where number like '{$year_}'"; //字符串要用单引号引起来
//每一年的诉讼案件总数,总金额
$countssaj = $dsql->getOne($sqlcount);
return $countssaj;
}