这样每次添加where条件直接在数组中添加就好,不用更改具体的代码。
implode()的巧妙应用
if(intval($_GET['type']))
$where[]='type='.intval($_GET['type']);
else $where=null;
if(!intval($_GET['limit']))
$_GET['limit']=10;
if($_GET['category_id']<1)
$_GET['category_id']=1;
$where[]='category_id='.intval($_GET['category_id']);
if(intval($_GET['flag_ch']))
$where[]='flag_ch='.intval($_GET['flag_ch']);
$where1 = implode(' AND ', $where);
if ($topics_list = $this->model('topic')->get_topic_list($where1, $order,$_GET['limit'], $_GET['page']))