123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- /**
-
- *
-
- *
- * ----------------------------------------------------------------------------
- *
-
- * 数据层模型
- */
- class Activity extends BaseModel
- {
- public $page_info;
- /**
- * 活动列表
- * @author csdeshang
- * @param type $condition 查询条件
- * @param type $pagesize 分页页数
- * @param type $order 排序
- * @return type
- */
- public function getActivityList($condition, $pagesize = '', $order = 'activity_sort asc')
- {
- if ($pagesize) {
- $res = Db::name('activity')->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
- $this->page_info = $res;
- return $res->items();
- } else {
- return Db::name('activity')->where($condition)->order($order)->select()->toArray();
- }
- }
- /**
- * 添加活动
- * @author csdeshang
- * @param type $data 查询数据
- * @return array 一维数组
- */
- public function addActivity($data)
- {
- return Db::name('activity')->insertGetId($data);
- }
- /**
- * 更新活动
- * @author csdeshang
- * @param type $data 活动数据
- * @param type $id 活动id
- * @return type
- */
- public function editActivity($data, $id)
- {
- return Db::name('activity')->where("activity_id='$id' ")->update($data);
- }
- /**
- * 删除活动
- * @author csdeshang
- * @param type $condition 删除条件
- * @return type
- */
- public function delActivity($condition)
- {
- return Db::name('activity')->where($condition)->delete();
- }
- /**
- * 根据id查询一条活动
- * @author csdeshang
- * @param int $id 活动id
- * @return array 一维数组
- */
- public function getOneActivityById($id)
- {
- return Db::name('activity')->where('activity_id', $id)->find();
- }
- }
|