38 lines
898 B
PHP
38 lines
898 B
PHP
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
|
|
|
class User_Model extends ORM
|
|
{
|
|
protected $table_name = 'user';
|
|
protected $primary_val = 'username';
|
|
|
|
public function unique_key($id)
|
|
{
|
|
if (!empty($id) && is_string($id) && !ctype_digit($id))
|
|
{
|
|
return 'username';
|
|
}
|
|
return parent::unique_key($id);
|
|
}
|
|
|
|
public function unique_key_exists($value)
|
|
{
|
|
return (bool) $this->db
|
|
->where($this->unique_key($value), $value)
|
|
->count_records($this->table_name);
|
|
}
|
|
|
|
public function username_not_exists()
|
|
{
|
|
return (bool) ! $this->db
|
|
->where(array('username' => $this->username, 'id !=' => $this->id))
|
|
->count_records($this->table_name);
|
|
}
|
|
|
|
public function email_not_exists()
|
|
{
|
|
return (bool) ! $this->db
|
|
->where(array('email' => $this->email, 'id !=' => $this->id))
|
|
->count_records($this->table_name);
|
|
}
|
|
|
|
} |