|
本帖最后由 630088892 于 2012-5-24 11:12 编辑
function get_list($opt=array(),$limit=10,$offset=0)
{
$data = array();
//缓存查询条件
$this->db->start_cache();
foreach($opt as $key=>$val)
{
$this->db->where($key,$val);
}
$this->db->from('node');
//停止缓存
$this->db->stop_cache();
//取记录总数
$data['count'] = $this->db->count_all_results();
//指定记录区间
$this->db->limit($limit,$offset);
$query = $this->db->get();
$data['list'] = $query->result_array();
//debug($data['list'],1);
foreach($data['list'] as $key=>$val)
{
$this->db->select('idc_id')->from('cluster')->where('id', $val['cluster_id']);
$querys = $this->db->get('cluster');
}
exit;
$this->db->flush_cache();
return $data;
}
报错如下:
A Database Error OccurredError Number: 1052
Column 'id' in where clause is ambiguous
SELECT `idc_id` FROM (`node`, `cluster`) WHERE `id` = '9'
Filename: D:\www\trunk\system\database\DB_driver.php
Line Number: 330
|
|