下面是我一个同事写的程序,大家评判一下好与坏
/**
 * 通用分组计算高级查询
 * @return multitype:multitype: 
 */
function getListByGroup(){
$condition = $this->getSearchFV();
if ($condition) $condition = "WHERE " . $condition;

$columns = $this->getColumns();
$base_tb = self::$base_tb;
$orderBy = $this->getOrderBy();
$groupBy = $this->getGroupBy();
$joinTables = $this->getJoinTables();
$joinTableCondition = $this->getJoinTablesCondition();
if ($joinTableCondition && $condition) $condition .= ' AND ';
if ($joinTableCondition && !$condition) $condition .= ' WHERE ';

//封装分页查询条件
$startRow = $this->page->getStartRow();
$size = $this->page->getPageSize();
$this->page->setAllInfo($this->getCount(" $joinTables  $condition $joinTableCondition "));
$by_page = " LIMIT $startRow, $size ";

$this->sql = "SELECT  $columns FROM $this->table $base_tb $joinTables  $condition $joinTableCondition $groupBy $orderBy $by_page";
Logger::log('sql', $this->sql);
$rsts = $this->query($this->sql);
$result_datas = array();
while ($obj = mysql_fetch_assoc($rsts)){
$result_datas[] = $obj;
}
return array($result_datas, $this->page);
}
/**
 * 通用高级查询 无分页
 * @return multitype:multitype: 
 */
function getListNoPage(){
$condition = $this->getSearchFV();
if ($condition) $condition = "WHERE " . $condition;

$columns = $this->getColumns();
$base_tb = self::$base_tb;
$orderBy = $this->getOrderBy();
$joinTables = $this->getJoinTables();
$joinTableCondition = $this->getJoinTablesCondition();
if ($joinTableCondition && $condition) $condition .= ' AND ';
if ($joinTableCondition && !$condition) $condition .= ' WHERE ';

$this->sql = "SELECT  $columns FROM $this->table $base_tb $joinTables  $condition $joinTableCondition $orderBy";
Logger::log('sql', $this->sql);
$rsts = $this->query($this->sql);
$result_datas = array();
while ($obj = mysql_fetch_assoc($rsts)){
$result_datas[] = $obj;
}
return $result_datas;
}