|
发表于 2012-11-6 12:48:20
|
显示全部楼层
PHP复制代码 function search ($data,$limit,$offset) {
$i = 0;
$sql = 'SELECT * FROM ' . $this->bold_data . " WHERE ";
foreach($data as $key => $value)
{
$sql .= $key . " LIKE '%" . $value ."%'";
if($i != count($data)-1){
$sql .= " AND ";
}
$i++;
}
$sql .= " LIMIT " . $limit ." OFFSET " . $offset;
$rs = $this->db->query($sql);
if($rs->num_rows()>0)
return $rs->result_array();
else
return false;
} 复制代码
如果是很多搜索条件 可以用 SQL拼接 然后在C中 控制分页~ |
|