{"id":226741,"date":"2014-06-19T03:45:03","date_gmt":"2014-06-18T23:45:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=226741"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=226741","title":{"rendered":"<span class=\"post_title\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438 \u0434\u0435\u0440\u0435\u0432\u044c\u0435\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e Materialized Path<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t\u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0432 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0441\u0432\u043e\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h4>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432) \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0411\u0414 MySQL<\/li>\n<li>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0437\u043b\u043e\u0432\/\u0432\u0435\u0442\u0432\u0435\u0439<\/li>\n<li>\u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043e\u0434\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u0441 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u0435\u0442\u0432\u044f\u043c\u0438<\/li>\n<\/ul>\n<p>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f, \u0438 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0435\u0451 \u0440\u0435\u0448\u0438\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/post\/46659\/\">Adjacency List \u0438 Materialized Path<\/a>. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043e\u043b\u043e\u043d\u043a\u0438<\/p>\n<pre><code class=\"sql\">id INT(11) parentid INT(11) mpath VARCHAR(255)<\/code><\/pre>\n<p>  \u0412 mpath \u0445\u0440\u0430\u043d\u0438\u043b\u0441\u044f \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432\u0435\u0442\u043a\u0438 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <b>\/1\/3\/4\/5\/8\/9<\/b>, \u0433\u0434\u0435 \u0447\u0435\u0440\u0435\u0437 \u0437\u043d\u0430\u043a &quot;\/&quot; \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u043b\u0438\u0441\u044c ID \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f.<\/p>\n<p>  \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c:<\/p>\n<pre><code class=\"sql\">SELECT * FROM messages WHERE postid=$postid ORDER BY mpath ASC<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043f\u0440\u0438 \u0440\u043e\u0441\u0442\u0435 \u0447\u0438\u0441\u043b\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. <a name=\"habracut\"><\/a>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0435\u0440\u0435\u0432\u043e \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0443\u0442\u044f\u043c\u0438:<\/p>\n<pre><code class=\"html\">1 1.2 1.2.10 1.2.3 1.2.7 4 4.8 4.8.9 5 5.6<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0446\u0438\u0444\u0440\u0430\u043c\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u044b ID, \u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0442\u0430\u043a\u043e\u0439, \u043a\u0430\u043a\u043e\u0439 \u0431\u044b \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>ORDER BY mpath ASC<\/code>.<br \/>  \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 1.2.10 \u0438\u0434\u0451\u0442 \u0434\u043e 1.2.3 \u0438 \u0434\u0440, \u0445\u043e\u0442\u044f \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043f\u043e\u0437\u0436\u0435 (\u0441\u0443\u0434\u044f \u043f\u043e ID). <\/p>\n<h4>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h4>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0437\u0434\u0435\u0441\u044c: <a href=\"http:\/\/habrahabr.ru\/post\/125729\/\">http:\/\/habrahabr.ru\/post\/125729\/<\/a>. \u0418\u0434\u0435\u044f \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u0434\u0435\u0441\u044f\u0442\u0438\u0447\u043d\u044b\u0435 ID \u0432 \u043f\u0443\u0442\u0438, \u0430 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u0435\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u0432 \u0434\u043b\u0438\u043d\u0435 \u043f\u0443\u0442\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0442\u043e\u0447\u0435\u043a \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e\u043b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0438.<\/p>\n<p>  \u042f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0435 95, \u044d\u0442\u043e \u043a\u0430\u043a \u0440\u0430\u0437 \u0447\u0438\u0441\u043b\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 ASCII.<\/p>\n<pre><code>!&quot;#$%&\\'()*+,-.\/0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0443\u0442\u0438 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0434\u043b\u0438\u043d\u0443, \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0435\u0440\u0445\u043d\u0438\u0439 \u043f\u043e\u0440\u043e\u0433 ID:<br \/>  1 \u2014 95^1 \u2014 1 = 94<br \/>  2 \u2014 95^2 \u2014 1 = 9 024<br \/>  3 \u2014 95^3 \u2014 1 = 857 374<br \/>  4 \u2014 95^4 \u2014 1 = 81 450 624<br \/>  5 \u2014 95^5 \u2014 1 = 7 737 809 374<\/p>\n<p>  5-\u0442\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432\u043f\u043e\u043b\u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u043e\u043b\u043d\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432.<br \/>  \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0434\u043b\u044f VARCHAR 255\/5 = 51<\/p>\n<p>  \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u0431\u0440\u0430\u0442\u044c \u043d\u0435 BASE95, \u0430 BASE256 (\u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0435\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c\u044b\u043c\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438), \u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u044d\u0442\u043e \u0432\u0441\u0451 \u0431\u0438\u043d\u0430\u0440\u043d\u043e \u0432 BLOB, \u043f\u0440\u0430\u0432\u0434\u0430 \u0442\u0443\u0442 \u044f \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438 \u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0435 (\u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c). \u0422\u043e\u0433\u0434\u0430 \u0443\u0436\u0435 3 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c 16 777 215 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432, \u0430 4 \u2014 4 294 967 295. <\/p>\n<h4>\u041a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435<\/h4>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u0441\u0432\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u0442\u0435\u043e\u0440\u0438\u0438.<\/p>\n<pre><code class=\"php\">\/\/ $mpath - \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 materialized path \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c &quot;\/&quot;  \/\/ \u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f: $db-&gt;Execute(&quot; \tUPDATE messages SET  \tmpath=?,  \tbpath=?, \tdepth=?  \tWHERE id=? &quot;, array( \t$mpath,  \tbpath($mpath), \t$depth,  \t$messid ));  \/\/ . . .   \/\/ \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u0430\u043c\u0438 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f define('BASE95', '!&quot;#$%&\\'()*+,-.\/0123456789:;&lt;=&gt;?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~');  \/\/ . . .   \/\/ \u0444\u0443\u043d\u043a\u0446\u0438\u044f bpath function bpath($mpath, $sep = '\/', $max_len = 5) { \t$bpath = ''; \t$chunks = explode($sep, trim($mpath, $sep)); \t$zero = substr(BASE95, 0, 1);      \tforeach($chunks as $chunk)  \t\t$bpath .= str_pad(dec2base($chunk, 95, BASE95), $max_len, $zero, STR_PAD_LEFT);      \treturn $bpath; } <\/code><\/pre>\n<p>  \u0418 \u0434\u0430\u043b\u0435\u0435 \u0432\u044b\u0431\u043e\u0440\u043a\u0430:<\/p>\n<pre><code class=\"sql\">SELECT * FROM messages WHERE postid=$postid ORDER BY bpath ASC<\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f dec2base \u0432\u0437\u044f\u0442\u0430 <a href=\"http:\/\/www.php.net\/manual\/en\/ref.bc.php#25336\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>.<\/p>\n<p>  \u0422\u0430\u043a\u043e\u0435 \u0432\u043e\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0432 \u0430\u0440\u0441\u0435\u043d\u0430\u043b\u0435 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c \u0438\u043c\u0438 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.      \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\/226741\/\"> http:\/\/habrahabr.ru\/post\/226741\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t\u0421\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0432 \u044d\u0442\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e \u0441\u0432\u043e\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<h4>\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u0425\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 (\u0434\u0440\u0435\u0432\u043e\u0432\u0438\u0434\u043d\u044b\u0445 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432) \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u0411\u0414 MySQL<\/li>\n<li>\u041f\u0440\u043e\u0441\u0442\u043e\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0443\u0437\u043b\u043e\u0432\/\u0432\u0435\u0442\u0432\u0435\u0439<\/li>\n<li>\u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u0440\u0435\u0432\u0430 \u043e\u0434\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u0441 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u0432\u0435\u0442\u0432\u044f\u043c\u0438<\/li>\n<\/ul>\n<p>  \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u0430\u044f, \u0438 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0435\u0451 \u0440\u0435\u0448\u0438\u043b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f <a href=\"http:\/\/habrahabr.ru\/post\/46659\/\">Adjacency List \u0438 Materialized Path<\/a>. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043e\u043b\u043e\u043d\u043a\u0438<\/p>\n<pre><code class=\"sql\">id INT(11) parentid INT(11) mpath VARCHAR(255)<\/code><\/pre>\n<p>  \u0412 mpath \u0445\u0440\u0430\u043d\u0438\u043b\u0441\u044f \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u0432\u0435\u0442\u043a\u0438 \u0432 \u0434\u0435\u0440\u0435\u0432\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 <b>\/1\/3\/4\/5\/8\/9<\/b>, \u0433\u0434\u0435 \u0447\u0435\u0440\u0435\u0437 \u0437\u043d\u0430\u043a &quot;\/&quot; \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u043b\u0438\u0441\u044c ID \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f.<\/p>\n<p>  \u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043e\u0447\u0435\u043d\u044c \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b\u0430\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c:<\/p>\n<pre><code class=\"sql\">SELECT * FROM messages WHERE postid=$postid ORDER BY mpath ASC<\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043f\u0440\u0438 \u0440\u043e\u0441\u0442\u0435 \u0447\u0438\u0441\u043b\u0430 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432. <\/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-226741","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/226741","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=226741"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/226741\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=226741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=226741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=226741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}