public static function getCount($table, $condition = null, $host = 'slave')
{
self::connect($host);
if (!empty($condition) && is_array($condition)){
$where = '';
foreach ($condition as $key=>$val) {
self::parseKey($key);
$val = self::parseValue($val);
$where .= ' AND '.$key.'='.$val;
}
$where = ' WHERE '.substr($where,4);
}elseif(is_string($condition)){
if (strtoupper(substr(trim($condition),0,3)) == 'AND'){
$where = ' WHERE '.substr(trim($condition),4);
}else{
$where = ' WHERE '.$condition;
}
}//var_dump(($where));exit;
if(trim($where) == 'WHERE'){$where = false;}
//$sql = 'SELECT COUNT(*) as `count` FROM `'.DBPRE.$table.'` as `'.$table.'` '.(isset($where) ? $where : '');
$sql = 'SELECT COUNT(*) as `count` FROM `'.DBPRE.$table.'` as `'.$table.'` '.($where ? $where : '');
$result = mysqli_fetch_array(self::query($sql,$host));
return $result['count'];
}
本文作者
:
admin
@
邮箱
版权声明
除非注明,本文由 admin 原创编译
转载请注明出处:
http://qg66.cn/?id=18