Этот коммит содержится в:
2017-01-26 05:21:02 +03:00
родитель a52e24ae45
Коммит b6f7196aa5
21 изменённых файлов: 681 добавлений и 12 удалений

Просмотреть файл

@@ -28,6 +28,13 @@ class AdModel extends Model{
protected $table_pdate;
/**
* @return mixed
*/
public function getId() {
return (int) $this->table_id;
}
/**
* @param $username
*
@@ -74,7 +81,7 @@ class AdModel extends Model{
*/
public function setHomepage( $homepage ) {
if ( preg_match('|https?://.*\..*|i', $homepage ) ) {
$this->table_homepage = $homepage;
$this->table_homepage = strip_tags( $homepage );
return true;
} else {
return "Введите коректный адрес";
@@ -143,4 +150,21 @@ class AdModel extends Model{
public function getDate() {
return $this->table_pdate;
}
public function countPages() {
return ceil($this->count()/25);
}
/**
* @param int $page_number
* @param string $sort_by
* @param string $order
*
* @return mixed
*/
static public function getForPage( $page_number = 1, $sort_by = 'pdate', $order = 'ASC' ) {
$class_name = __CLASS__;
$offset = ($page_number - 1) * 25;
return $class_name::find(" 1 ORDER BY $sort_by $order LIMIT $offset,25");
}
}