1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-10-29 16:06:41
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-11-09 17:42:32
- */
- namespace app\index\model;
- use think\Model;
- class roleusermodel extends Model
- {
- protected $table = 't_roleuser';
- 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 getinfoforuser($uid)
- {
- $sql = "select r.* from t_roleuser as ru join t_roles as r on r.id = ru.rid where ru.uid='" . $uid . "' and r.is_active=1";
- $result = $this->query($sql);
- return $result;
- }
- }
|