123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- /**
- * Created by PhpStorm.
- * User: sicilon_IT
- * Date: 2020/1/22
- * Time: 21:08
- */
- namespace app\common\model;
- use think\Model;
- class webusermodel extends Model
- {
- protected $table = 't_webuser';
- public function insertData($data)
- {
- $id = $this->insertGetId($data);
- return empty($id) ? false : $id;
- }
- public function getlogininfo($lname, $lpwd)
- {
- $where_arr['user_password'] = $lpwd;
- $where_arr['user_name'] = $lname;
- $uinfo = $this->where($where_arr)->find();
- //var_dump($uinfo);
- return $uinfo;
- }
- /***
- * 用户密码md5登录
- */
- public function getlogininfomd5($lname, $lpwd)
- {
- $where_arr['user_password'] = md5($lname . $lpwd);
- $where_arr['user_name'] = $lname;
- $uinfo = $this->where($where_arr)->find();
- return $uinfo;
- }
- 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;
- }
- /**
- * 根据id获取信息
- * wj
- * 20220420
- */
- public function getinfobyid($id)
- {
- $where = ['id' => $id];
- $info = $this->where($where)->find();
- return $info ? $info : false;
- }
- /**获取多个id通过用户名 */
- public function getidsbyusername($name, $like = true)
- {
- if ($like) {
- $where = ['user_name' => ['like', '%' . $name . '%']];
- } else {
- $where = ['user_name' => $name];
- }
- $list = $this->field('id')->where($where)->select();
- return $list ? $list : false;
- }
- }
|