Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Pager constructor is deprecated. You must use the "Pager::factory($params) / 2 сообщений из 2, страница 1 из 1
13.10.2015, 09:27
    #39075098
son456
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Pager constructor is deprecated. You must use the "Pager::factory($params)
Здравствуйте! Пишу pager выдает ошибку!
Pager constructor is deprecated. You must use the "Pager::factory($params)" method instead of "new Pager($params)"
Код: php
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
<?php
class Pager {
	
	protected $page;
	
	protected $tablename;
	
	protected $where;
	
	protected $order;
	
	protected $napr;
	
	protected $operand;
	
	protected $match;
	
	protected $post_number;
	
	protected $number_link;
	
	protected $db;
	
	protected $total_count;
	
	
	public function __construct(
								$page,
								$tablename,
								$where = array(),
								$order = '',
								$napr = '',
								$post_number,
								$number_link,
								$operand  = "=",
								$match = array()
								) 
	{
		$this->page = $page;
		$this->tablename = $tablename;	
		$this->where = $where;	
		$this->order = $order;
		$this->napr = $napr;
		$this->post_number = $post_number;	
		$this->number_link = $number_link;	
		$this->operand = $operand;
		$this->match = $match;	
		$this->db = Model_Driver::get_instance();									
	}
	public function get_total() {
		
		
		if(!$this->total_count) {
		
			$result = $this->db->select(
										array("COUNT(*) as count"),
										$this->tablename,
										$this->where,
										$this->order,
										$this->napr,
										FALSE,
										$this->operand,
										$this->match
										);
										
			$this->total_count = $result[0]['count'];
		}
		return $this->total_count;								
	}
	
	public function get_posts() {
		$total_post = $this->get_total();
		
		$number_pages = (int)($total_post/$this->post_number);
		
		if(($total_post%$this->post_number) != 0) {
			$number_pages++;
		}
		
		if($this->page <= 0 || $this->page > $number_pages) {
			return FALSE;
		}
		$start = ($this->page-1)*$this->post_number;
		
		
		$result = $this->db->select(
									array('*'),
									$this->tablename,
									$this->where,
									$this->order,
									$this->napr,
									$start.','.$this->post_number,
									$this->operand,
									$this->match
									);
		return $result;
	}
	
	public function get_navigation() {
		$total_post = $this->get_total();
		
		$number_pages = (int)($total_post/$this->post_number);
		
		if(($total_post%$this->post_number) != 0) {
			$number_pages++;
		}
		
		if($total_post < $this->post_number || $this->page > $number_pages) {
			return FALSE;
		}
		
		$result = array();
		
		if($this->page != 1) {
			$result['first'] = 1;
			$result['last_page'] = $this->page - 1;
			
		}
		
		if($this->page > $this->number_link + 1) {
			for($i = $this->page-$this->number_link;$i < $this->page; $i++) {
				$result['previous'][] = $i;
				
			}
		}
		else {
			for($i = 1; $i < $this->page;$i++) {
				$result['previous'][] = $i;
			}
		}
		
		$result['current'] = $this->page;	
		if($this->page+$this->number_link < $number_pages) {
			for($i = $this->page+1;$i <= $this->page + $this->number_link;$i++) {
				$result['next'][] = $i;
			}
		}
		else {
			for($i = $this->page+1; $i <= $number_pages;$i++) {
				$result['next'][] = $i;
			}
		}
		
		if($this->page != $number_pages) {
			$result['next_pages'] = $this->page + 1;
			$result['end'] = $number_pages;
		}
		
		return $result;
	}
}
?>
...
Рейтинг: 0 / 0
13.10.2015, 09:46
    #39075116
kunaksergey
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Pager constructor is deprecated. You must use the "Pager::factory($params)
son456,
Pager это вообще ваш класс? Может такой класс существует в подключаемых библиотеках, тогда используйте namespace.
...
Рейтинг: 0 / 0
Форумы / PHP, Perl, Python [игнор отключен] [закрыт для гостей] / Pager constructor is deprecated. You must use the "Pager::factory($params) / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]