where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false); $this->page_info = $result; return $result->items(); } else { return Db::name('link')->where($condition)->order($order)->select()->toArray(); } } /** * 取单个友情链接 * @access public * @author csdeshang * @param type $id 链接ID * @return type */ public function getOneLink($id) { return Db::name('link')->where('link_id', $id)->find(); } /** * 新增友情链接 * @access public * @author csdeshang * @param type $data 参数内容 * @return type */ public function addLink($data) { return Db::name('link')->insertGetId($data); } /** * 更新友情链接 * @access public * @author csdeshang * @param type $data 更新数据 * @param type $link_id 链接id * @return type */ public function editLink($data, $link_id) { return Db::name('link')->where('link_id', $link_id)->update($data); } /** * 删除 * @access public * @author csdeshang * @param array $id 链接id * @return bool */ public function delLink($id) { $link = $this->getOneLink($id); //删除友情链接图片 @unlink(BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . DIR_ADMIN . DIRECTORY_SEPARATOR . 'link' . DIRECTORY_SEPARATOR . $link['link_pic']); return Db::name('link')->where('link_id', intval($id))->delete(); } }