duanraotun1674 2017-03-01 16:13 采纳率: 100%
浏览 23

发生数据库错误用户模型

My web site showing this error from admin login:

"A Database Error Occurred Error Number: 1146 Table 'hgsds65.WS_ws_user' doesn't exist"

I can't log in to my web site. Why is it showing this message? I don't understand anything..

this is User-model.php

<?php defined('BASEPATH') OR exit('No direct script access allowed');

class User_model extends WS_model
{
    public function validateLogin($user_email, $password)
    {
        $this->db->from('ws_user');
        $this->db->join('user_status us', 'us.user_status_seq_id = u.user_status_seq_id', 'left');
        $this->db->join('user_type ut', 'ut.user_type_seq_id = u.user_type_seq_id', 'left');
        $this->db->where('user_email', $user_email);
        $this->db->where('user_password', ws_password_hash($password));
        $query = $this->db->get();
        if ($query->num_rows())
            return $query->row();
        return false;
    }

    public function validateLoginBYID($user_id, $password)
    {
        $this->db->from('user u');
        $this->db->join('user_status us', 'us.user_status_seq_id = u.user_status_seq_id', 'left');
        $this->db->join('user_type ut', 'ut.user_type_seq_id = u.user_type_seq_id', 'left');
        $this->db->where('user_seq_id', $user_id);
        $this->db->where('user_password', $password);
        $query = $this->db->get();
        if ($query->num_rows())
            return $query->row();
        return false;
    }

    public function get_userById($id)
    {
        $this->db->from('user u');
        $this->db->join('user_status us', 'us.user_status_seq_id = u.user_status_seq_id', 'left');
        $this->db->join('user_type ut', 'ut.user_type_seq_id = u.user_type_seq_id', 'left');
        $this->db->where('user_seq_id', $id);

        $query = $this->db->get();
        if ($query->num_rows())
            return $query->row();
        return false;
    }

    public function get_userByEmail($email)
    {
        $this->db->from('user u');
        $this->db->join('user_status us', 'us.user_status_seq_id = u.user_status_seq_id', 'left');
        $this->db->join('user_type ut', 'ut.user_type_seq_id = u.user_type_seq_id', 'left');
        $this->db->where('user_email', $email);

        return $this->row();
    }

    public function users_count($filter)
    {
        $this->db->from('user u');
        $this->db->join('user_status us', 'us.user_status_seq_id = u.user_status_seq_id', 'left');
        $this->db->join('user_type ut', 'ut.user_type_seq_id = u.user_type_seq_id', 'left');

        if (isset($filter['status']))
            $this->db->where('u.user_status_seq_id', $filter['status']);
        if (isset($filter['access_type']))
            $this->db->where('u.user_type_seq_id', $filter['access_type']);
        if (isset($filter['name'])) {
            $where = " (u.user_email LIKE '%{$filter['name']}%' OR u.user_name LIKE '%{$filter['name']}%')";
            $this->db->where($where, NULL, false);
        }

        return $this->db->count_all_results();
    }

    public function get_all_users($filter)
    {
        $this->db->from('user u');
        $this->db->join('user_status us', 'us.user_status_seq_id = u.user_status_seq_id', 'left');
        $this->db->join('user_type ut', 'ut.user_type_seq_id = u.user_type_seq_id', 'left');

        if (isset($filter['status']))
            $this->db->where('u.user_status_seq_id', $filter['status']);
        if (isset($filter['access_type']))
            $this->db->where('u.user_type_seq_id', $filter['access_type']);
        if (isset($filter['name'])) {
            $where = " (u.user_email LIKE '%{$filter['name']}%' OR u.user_name LIKE '%{$filter['name']}%')";
            $this->db->where($where, NULL, false);
        }
        if (isset($filter['order_by']) && isset($filter['order_type']))
            $this->db->order_by($filter['order_by'], $filter['order_type']);
        else  $this->db->order_by('user_seq_id', 'desc');
        $this->db->limit($filter['per_page'], $filter['offset']);
        $query = $this->db->get();
        if ($query->num_rows())
            return $query->result();
        return false;
    }

    public function get_all_status($convert = true)
    {
        $this->db->from('user_status');
        $query = $this->db->get();
        if ($query->num_rows()) {
            if ($convert) {
                return $this->get_all_status_convert($query->result());
            } else {
                return $query->result();
            }
        }
        return false;
    }

    private function get_all_status_convert($data)
    {
        $return = array();
        foreach ($data as $d) {
            $return[$d->user_status_seq_id] = $d->user_status_name;
        }
        return $return;
    }

    public function get_all_user_type($convert = true)
    {
        $this->db->from('user_type');
        $query = $this->db->get();
        if ($query->num_rows()) {
            if ($convert) {
                return $this->get_all_user_type_convert($query->result());
            } else {
                return $query->result();
            }
        }
        return false;
    }

    private function get_all_user_type_convert($data)
    {
        $return = array();
        foreach ($data as $d) {
            $return[$d->user_type_seq_id] = $d->user_type_name;
        }
        return $return;
    }

    public function insert($data, $bulk = false)
    {
        if ($bulk) {
            $this->insert_batch('user', $data);
        } else {
            $this->db->insert('user', $data);
            return $this->db->insert_id();
        }
    }

    public function update_user($data, $where)
    {
        $this->db->update('user', $data, $where);
        return $this->db->affected_rows();
    }

    public function delete_userByID($id)
    {
        $this->db->delete('user', array('user_seq_id' => $id));
        return $this->db->affected_rows();
    }

    public function delete_bulkUsers($user_ids)
    {
        $this->db->where_in('user_seq_id', $user_ids);
        $this->db->delete('user');
        return $this->db->affected_rows();
    }
}

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题