欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

函数代码详细求解

程序员文章站 2024-02-10 16:27:10
...
请高手帮忙详细解释下段代码
public function fetch_all_by_sql($where, $order = '', $start = 0, $limit = 0, $count = 0, $alias = '')
{
$where = $where && !is_array($where) ? " WHERE $where" : '';
if(is_array($order)) {
$order = '';
}
if($count) {
return DB::result_first('SELECT count(*) FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order));
}
return DB::fetch_all('SELECT * FROM '.DB::table($this->_table).' %i %i %i '.DB::limit($start, $limit), array($alias, $where, $order));
}

回复讨论(解决方案)

那里不清楚你可以标出来

都不清楚哟

public function fetch_all_by_sql($where, $order = '', $start = 0, $limit = 0, $count = 0, $alias = '')

一个数据库搜索函数,可返回总数量

参数:$where 同sql WHERE
$order 同sql ORDER
$start 同sql 从哪一条记录开始返回
$limit 返回多少条记录
$count 是否直接返回搜索结果记录条数
alias 不太明白是个什么作用

不简单看到条正儿八经的的回复

楼上+1