50 lines
1.1 KiB
PHP
Executable File
50 lines
1.1 KiB
PHP
Executable File
<?php if (!defined('BASEPATH')) {
|
|
exit('No direct script access allowed');
|
|
}
|
|
|
|
|
|
class User_model extends MY_Model
|
|
{
|
|
|
|
private $db;
|
|
private $table = 'cm_user';
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->db = &get_instance()->db;
|
|
}
|
|
|
|
private function init()
|
|
{
|
|
return $this->db->from('cm_user');
|
|
}
|
|
|
|
public function getOne($seq)
|
|
{
|
|
return self::init()->where_in("seq", $seq)->get()->row();
|
|
}
|
|
|
|
public function findByUserName($userName)
|
|
{
|
|
return $this->init()->where('userName', $userName)
|
|
->get()->result();
|
|
}
|
|
|
|
public function findByEmail($email)
|
|
{
|
|
return $this->init()->where('email', $email)
|
|
->get()->result();
|
|
}
|
|
|
|
public function save($data)
|
|
{
|
|
return $this->db->insert_batch('cm_user', is_array($data) ? $data : [$data]);
|
|
}
|
|
|
|
public function getAdminSiteUsers()
|
|
{
|
|
return $this->db->where_in('roleID', [2, 5, 7])->get($this->table)->result();
|
|
}
|
|
}
|