12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-10-29 16:06:41
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-12-31 17:46:42
- */
- namespace app\index\model;
- use think\Model;
- class scorebusinessmodel extends Model
- {
- protected $table = 't_scorebusiness';
- public function insertData($data)
- {
- $id = $this->insertGetId($data);
- return empty($id) ? false : $id;
- }
- public function getInfo($where, $field = "*", $row = true)
- {
- $info = $this->field($field)->where($where);
- if ($row) {
- $info = $info->find();
- } else {
- $info = $info->select();
- }
- return empty($info) ? false : $info;
- }
- public function updateinfo($where, $updateData)
- {
- $row = $this->where($where)->update($updateData);
- return empty($row) ? false : $row;
- }
- public function deleteinfo($where)
- {
- $row = $this->where($where)->delete();
- return empty($row) ? false : $row;
- }
- public function getList($where = [], $field = "*", $page = 1, $size = 10, $order = "id desc", $group = "", $row = false)
- {
- $sqlObj = $this->where($where);
- if ("count" != $field) {
- $sqlObj = $sqlObj->field($field)->order($order)->group($group)->page($page, $size);
- if ($row) {
- $data = $sqlObj->find();
- } else {
- $data = $sqlObj->select();
- }
- } else {
- $data = $sqlObj = $sqlObj->count();
- }
- return $data;
- }
- public function getinfobyweight($where)
- {
- $sql = "select * from " . $this->table . " where typeid='" . $where['typeid'] . "' and type='" . $where['type'] . "' and isactive=1 and
- (
- (starttime<='" . $where['time'] . "' and endtime>='" . $where['time'] . "') or
- (starttime is null or endtime is null)
- )
- order by weight desc limit 0,1";
- $data = $this->query("select * from (" . $sql . ") as t");
- return empty($data) ? false : $data[0];
- }
- }
|