CI中自定义SQL查询,LIKE模糊查询的处理

参考:

/**
* 据用户输入的关键字查询相册信息;照片墙搜索框功能
* @param $keyWord 关键字
* @param $pageNum 页码,第几页
* @param $pageSize 单页记录数,偏移量
*/
public function getUserAlbumsByDesc($keyWord, $pageNum, $pageSize)
{
$keyWord = trim(urldecode($keyWord));
$sql = "SELECT a.*,b.user_nickname, b.user_head_url from qk_user_album a, qk_user b where a.album_user_id = b.user_id and a.album_desc like '%".$keyWord."%' ORDER BY a.album_create_date desc LIMIT ?, ?;";
$query = $this->db->query($sql, array(($pageNum - 1)*$pageSize,intval($pageSize) ));

//返回多行
return $query->result_array();
}

posted @ 2015-01-28 21:07  谦信君  阅读(4515)  评论(0编辑  收藏  举报