first commit
This commit is contained in:
33
application/models/gallery.php
Normal file
33
application/models/gallery.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
class Gallery_Model extends ORM
|
||||
{
|
||||
protected $table_names_plural = FALSE;
|
||||
protected $has_many = array('gallery_images');
|
||||
protected $sorting = array('created_at' => 'ASC');
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
9
application/models/gallery_image.php
Normal file
9
application/models/gallery_image.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
class Gallery_Image_Model extends ORM
|
||||
{
|
||||
protected $table_names_plural = FALSE;
|
||||
protected $belongs_to = array('gallery');
|
||||
protected $sorting = array('id' => 'ASC');
|
||||
|
||||
}
|
||||
32
application/models/news.php
Normal file
32
application/models/news.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php defined('SYSPATH') OR die('No direct access allowed.');
|
||||
|
||||
class News_Model extends ORM
|
||||
{
|
||||
protected $table_names_plural = FALSE;
|
||||
protected $sorting = array('created_at' => 'DESC');
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
31
application/models/page.php
Normal file
31
application/models/page.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
38
application/models/user.php
Normal file
38
application/models/user.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user