sql_get_field_distinct改为支持可变参数个数
This commit is contained in:
parent
9142cc7482
commit
2202784f25
@ -403,15 +403,33 @@
|
|||||||
return sql_get_field_term($sql,$table_name,$field,"AVG",$where);
|
return sql_get_field_term($sql,$table_name,$field,"AVG",$where);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sql_get_field_distinct($sql,$table_name,$field,$where)
|
function sql_get_field_distinct()//$sql,$table_name,$field,$where,$start,$count)
|
||||||
{
|
{
|
||||||
if(!$sql)return null;
|
$sql =func_get_arg(0);
|
||||||
|
$table_name =func_get_arg(1);
|
||||||
|
$field =func_get_arg(2);
|
||||||
|
|
||||||
|
if(!$sql||!$table_name||!$field)return null;
|
||||||
|
|
||||||
|
if(func_num_args()>3)
|
||||||
|
$where=func_get_arg(3);
|
||||||
|
|
||||||
if($where)
|
if($where)
|
||||||
$sql_string="select DISTINCT(".$field.") from ".$table_name.' WHERE '.$where.' ORDER BY '.$field;
|
$sql_string="select DISTINCT(".$field.") from ".$table_name.' WHERE '.$where.' ORDER BY '.$field;
|
||||||
else
|
else
|
||||||
$sql_string="select DISTINCT(".$field.") from ".$table_name.' ORDER BY '.$field;
|
$sql_string="select DISTINCT(".$field.") from ".$table_name.' ORDER BY '.$field;
|
||||||
|
|
||||||
|
if(func_num_args()>5)
|
||||||
|
{
|
||||||
|
$start=func_get_arg(4);
|
||||||
|
$count=func_get_arg(5);
|
||||||
|
|
||||||
|
if($start>0||$count>0)
|
||||||
|
{
|
||||||
|
$sql_string=$sql_string.' LIMIT '.$start.','.$count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$sql_result=$sql->query($sql_string);
|
$sql_result=$sql->query($sql_string);
|
||||||
|
|
||||||
if(!$sql_result)
|
if(!$sql_result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user