| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace App\Models;
- use DB;
- class Advert extends BaseModel {
- protected $table = "advert";
- public $timestamps = false;
- function getlist($list = 10, $where = '') {
- $data = $this->orderBy('add_time', 'desc');
- if (!empty($where) && is_array($where)) {
- $data = $data->where($where);
- }
- $data = $data->paginate($list);
- if (!$data) {
- return -4010010022; //没有数据
- }
- return $data->toArray();
- }
- //获取信息
- function getMsg($value, $type) {
- $fild = $this->getfild($type);
- $data = $this->where($fild, $value)->orderBy('add_time', 'desc')->limit(10)->get();
- if (!$data) {
- return -4010010122; //没有数据
- }
- return $data->toArray();
- }
- function getDmsg($value, $type) {
- $fild = $this->getfild($type);
- $data = $this->where($fild, $value)->first();
- if (!$data) {
- return -4010010122; //没有数据
- }
- return $data->toArray();
- }
- function getfild($k) {
- $a = array(
- 1 => 'id',
- 2 => 'type',
- );
- return $a[$k];
- }
- function updateMsg($data, $id) {
- $res = $this->where('id', $id)->update($data);
- if (!$res) {
- return -4010011122;
- }
- return 1;
- }
- //添加公告数据
- function addNotice($data){
- // DB::connection()->enableQueryLog();
- $res=$this->insert($data);
- // $queries = DB::getQueryLog();
- // print_r($queries);
- if(!$res){
- return -6030001222;
- }
- }
- function getlistd($where) {
- $data = $this->where($where[0], $where[1])->orderBy('add_time', 'desc')->limit(5)->get();
- if (!$data) {
- return -4010011122;
- }
- return $data->toArray();
- }
- }
|