{"id":214383,"date":"2014-03-03T02:44:03","date_gmt":"2014-03-02T22:44:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=214383"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=214383","title":{"rendered":"<span class=\"post_title\">\u041f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0430\u044f \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f \u043d\u0430 PHP \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e<\/span>"},"content":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0430\u0439\u0442\u043e\u0432 \u0438\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u2014 \u043f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0443\u044e \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0432\u043e\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u043b\u0438 \u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043d\u0430\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439.<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h4>\n<p>  \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043b\u0435\u0436\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SQL \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <b>LIMIT<\/b>. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438, \u043d\u0443\u0436\u043d\u043e: \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0442\u0441\u0447\u0451\u0442\u0430 \u2014 START \u0438 \u0447\u0438\u0441\u043b\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 LIMIT. <\/p>\n<p>  <i>\u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 ???<\/i><br \/>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e 3 \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0435 \u043c\u044b \u043f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 <b>n<\/b> \u043f\u043e <b>n + 3 (\u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430)<\/b>. \u0412\u043e\u0442 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/357\/655\/890\/35765589044f4ef9a89ed7503dc2fccf.png\" \/><\/div>\n<p>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c 3 \u2014 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b:  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/fb3\/7e8\/d39\/fb37e8d39b53e041c4774c2f9e9bff2c.png\" \/><\/div>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432:<br \/>  <b>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 1<\/b> \u2014 <b>LIMIT 0,3<\/b> (\u0412\u0437\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 0 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 3)<br \/>  <b>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 2<\/b> \u2014 <b>LIMIT 3,3<\/b> (\u0412\u0437\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 3 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 3)<br \/>  <b>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 3<\/b> \u2014 <b>LIMIT 6,3<\/b> (\u0412\u0437\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 6 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c 3)<br \/>  \u0438 \u0442.\u0434.<br \/>  \u041f\u043e \u044d\u0442\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u043e\u0442 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043a \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438 \u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c:   <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/869\/832\/cf9\/869832cf97d4472c8c5670ce73ab9261.png\" \/><\/div>\n<p>  <b>1<\/b> \u2014 \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043e\u0442 \u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0439.<br \/>  <b>2<\/b> \u2014 \u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0438\u043b\u0438 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u043e\u0442 \u043a\u0440\u0430\u0439\u043d\u0435\u0439 \u0432\u043d\u0443\u0442\u0440\u0438.<br \/>  <b>3<\/b> \u2014 \u0410\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430.<br \/>  <b>4<\/b> \u2014 \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430.<br \/>  <b>5<\/b> \u2014 \u0421\u0434\u0432\u0438\u0433 \u0432\u043b\u0435\u0432\u043e \u0438\u043b\u0438 \u0432\u043f\u0440\u0430\u0432\u043e \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0439.<\/p>\n<h4>\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430<\/h4>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0440\u0430\u043b \u0443\u0436\u0435 \u0434\u0430\u0432\u043d\u043e. \u0412\u043e\u0442 \u0435\u0433\u043e \u043b\u0438\u0441\u0442\u0438\u043d\u0433. \u0414\u0443\u043c\u0430\u044e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430. \u0427\u0435\u043b\u043e\u0432\u0435\u043a \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0445\u043e\u0442\u044c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0432 PHP \u0432\u0441\u0435 \u043f\u043e\u0439\u043c\u0435\u0442.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \u043a\u043b\u0430\u0441\u0441\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">class Paging {   \tprivate $next = 'NEXT';  \tprivate $prev = 'PREV';  \t \tprivate $sql; \tprivate $base;  \tprivate $cur_pg;  \tprivate $max_pages;  \tprivate $lr_page = 2;  \tprivate $in_page = 10; \t  \tpublic function __construct($base, $page = 'page')  \t{  \t\t$this-&gt;base   \t= $base;  \t\t$this-&gt;page   \t= $page;  \t\t$this-&gt;cur_pg \t= isset($_GET[$this-&gt;page]) && (int)$_GET[$this-&gt;page] &gt; 0 ? (int)$_GET[$this-&gt;page] : 1;  \t}  \tpublic function set_in_page($psize)  \t{  \t\t$this-&gt;in_page = abs((int)$psize);  \t}   \tprivate function parse_sql()  \t{  \t\t$query = $this-&gt;sql;  \t\t \t\tif ($this-&gt;in_page != 0) {  \t\t\t$limit = ($this-&gt;cur_pg - 1) * $this-&gt;in_page;  \t\t\t$query = preg_replace('\/^SELECT\\s+\/i', 'SELECT SQL_CALC_FOUND_ROWS ', $this-&gt;sql).&quot; LIMIT $limit,&quot;.$this-&gt;in_page;  \t\t}  \t\treturn $query;  \t}   \tpublic function load_list()  \t{  \t\tif (!isset($this-&gt;max_pages)) return '';  \t\t$lnk_list = array();   \t\t$start = $this-&gt;cur_pg - $this-&gt;lr_page;   \t\t$end   = $this-&gt;cur_pg + $this-&gt;lr_page;  \t\tif ( $start &lt; 1 ) $start = 1; \t\t \t\tif ( $end &gt; $this-&gt;max_pages ) $end = $this-&gt;max_pages;   \t\tif ( $start &gt; 1 )  $lnk_list[] = $this-&gt;parse_url($start-1, $start - 2 &gt; 0 ? '...' : '' );  \t\tfor ($i = $start;  $i &lt;= $end; $i++) $lnk_list[] = $this-&gt;parse_url($i);  \t\tif ( $end + 1 &lt;  $this-&gt;max_pages )  $lnk_list[] = $this-&gt;parse_url($end +1, $end + 2 == $this-&gt;max_pages ? '' : '...');  \t\tif ( $end + 1 &lt;= $this-&gt;max_pages )  $lnk_list[] = $this-&gt;parse_url($this-&gt;max_pages);   \t\treturn implode(' ', $lnk_list);  \t}   \tprivate function parse_url($page, $text = '')  \t{  \t\tif (!$text) $text = $page;  \t\tif ($page != $this-&gt;cur_pg) { \t\t\tparse_str($_SERVER['QUERY_STRING'], $qstr); \t\t\t$qstr[$this-&gt;page] = $page; \t\t\treturn '&lt;a href=&quot;?'.http_build_query($qstr).'&quot; class=&quot;next_page&quot;&gt;'.$text.'&lt;\/a&gt;'; \t\t} else { \t\treturn '&lt;span class=&quot;current_page&quot;&gt;'.$text.'&lt;\/span&gt;'; } \t}   \tpublic function show_table_tpl($sql, $tpl, $paging = true) \t{ \t\t$html \t\t= ''; \t\t$this-&gt;sql \t= $sql;  \t\t$table \t\t= $this-&gt;base-&gt;query($this-&gt;parse_sql());  \t\t$row \t\t= mysqli_fetch_row($this-&gt;base-&gt;query('SELECT FOUND_ROWS()')); \t\tif ($this-&gt;in_page !== 0) $this-&gt;max_pages = ceil(array_pop($row) \/ $this-&gt;in_page);  \t\t  \t\tif ($this-&gt;cur_pg &gt; $this-&gt;max_pages) { $this-&gt;cur_pg = $this-&gt;max_pages; } \t  \t\t \t\t$fields = $table-&gt;fetch_fields(); \t\twhile($row = $table-&gt;fetch_assoc()) \t\t{ \t\t\t$template = $tpl; \t\t\tforeach ($fields as $val) { \t\t\t\t$template = preg_replace('#{'.$val-&gt;name.'}#', $row[$val-&gt;name], $template); \t\t\t} \t\t\t$html .= $template; \t\t} \t\tif ($paging == true) {  \t\t\t$html .= isset($this-&gt;max_pages) && $this-&gt;cur_pg &gt; 1 ? $this-&gt;parse_url($this-&gt;cur_pg - 1, $this-&gt;prev) : '';  \t\t\t$html .= ' '.$this-&gt;load_list().' '; \t\t\t$html .= isset($this-&gt;max_pages) && $this-&gt;cur_pg &lt; $this-&gt;max_pages ? $this-&gt;parse_url($this-&gt;cur_pg + 1, $this-&gt;next) : '';  \t\t}\t\t \t\treturn $html;\t \t}    }  <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"php\">$PAGE = new Paging($base); \/\/ \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0435\u043c\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0430\u0437\u044b $PAGE-&gt;set_in_page(5);\t\/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435  $tpl = &quot;&lt;div&gt;&lt;h1&gt;{title} [{id}]&lt;\/h1&gt; {title} {title} {title}&lt;br&gt;{title} {title} {title}&lt;\/div&gt;&lt;br&gt;&quot;;  \/\/ \u0448\u0430\u0431\u043b\u043e\u043d \u0432\u044b\u0432\u043e\u0434\u0430 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430  echo $PAGE-&gt;show_table_tpl('SELECT * FROM news ORDER BY `id` ASC', $tpl); \/\/ \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 <\/code><\/pre>\n<p>  \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 <b>{}<\/b> \u044d\u0442\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. <br \/>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f 2 \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b <br \/>   \u2014 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0431\u0430\u0437\u044b;<br \/>   \u2014 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043d\u043e\u043c\u0435\u0440 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<p>  \u0412 <b>show_table_tpl<\/b> \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f 3 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b:<br \/>   \u2014 \u0437\u0430\u043f\u0440\u043e\u0441;<br \/>   \u2014 \u0448\u0430\u0431\u043b\u043e\u043d \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f;<br \/>   \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <b>paging<\/b> \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446.<\/p>\n<h4>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442<\/h4>\n<p>  \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438:<br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/b62\/6fe\/c44\/b626fec4436a885a88d222b6893b5e85.png\"\/><br \/>  \u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0435. \u0412\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!!!    \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/214383\/\"> http:\/\/habrahabr.ru\/post\/214383\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">\n<h4>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h4>\n<p>  \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u0430\u0439\u0442\u043e\u0432 \u0438\u043b\u0438 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u2014 \u043f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u0443\u044e \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e. \u041a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0432\u043e\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0438\u043b\u0438 \u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438, \u043d\u043e \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u043d\u0430\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439.<\/p>\n<h4>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h4>\n<p>  \u0412 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043b\u0435\u0436\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SQL \u2014 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u043c \u0441\u043b\u043e\u0432\u043e\u043c <b>LIMIT<\/b>. \u0414\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043d\u043e\u0439 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438, \u043d\u0443\u0436\u043d\u043e: \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u043e\u0442\u0441\u0447\u0451\u0442\u0430 \u2014 START \u0438 \u0447\u0438\u0441\u043b\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u2014 LIMIT. <\/p>\n<p>  <i>\u041a\u0430\u043a \u0436\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 ???<\/i><br \/>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u043e 3 \u2014 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430. \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u0435 \u043c\u044b \u043f\u043e\u043e\u0447\u0435\u0440\u0435\u0434\u043d\u043e \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441 <b>n<\/b> \u043f\u043e <b>n + 3 (\u0440\u0430\u0437\u043c\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0430)<\/b>. \u0412\u043e\u0442 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"http:\/\/habrastorage.org\/getpro\/habr\/post_images\/357\/655\/890\/35765589044f4ef9a89ed7503dc2fccf.png\" \/><\/div>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-214383","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/214383","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=214383"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/214383\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=214383"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=214383"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=214383"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}