31 lines
665 B
PHP
31 lines
665 B
PHP
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
|
|
|
class Page_Model extends ORM
|
|
{
|
|
protected $table_names_plural = FALSE;
|
|
|
|
public function unique_key($id)
|
|
{
|
|
if (!empty($id) && is_string($id) && !ctype_digit($id))
|
|
{
|
|
return 'name';
|
|
}
|
|
|
|
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 name_not_exists()
|
|
{
|
|
return (bool) ! $this->db
|
|
->where(array('name' => $this->name, 'id !=' => $this->id))
|
|
->count_records($this->table_name);
|
|
}
|
|
|
|
} |