{"id":154865,"date":"2012-10-18T21:28:06","date_gmt":"2012-10-18T17:28:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=154865"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=154865","title":{"rendered":"<span class=\"post_title\">\u0418\u0437\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 Kohana ORM \u043e\u0442 \u043b\u0438\u0448\u043d\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0411\u0414<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \tORM, \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u043c\u043e\u0449\u043d\u0430\u044f \u0438 \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435, \u043d\u043e \u0435\u0449\u0435 \u0438 \u043b\u0438\u0448\u043d\u0438\u0435. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 ORM \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044f\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0411\u0414. \u0427\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043a \u0411\u0414.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h4>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430<\/h4>\n<p>  \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ORM \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441 <i>SHOW FULL COLUMNS FROM `tablename`<\/i> \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <i>protected $_table_columns<\/i> \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043e \u043f\u043e\u043b\u044f\u0445.   <\/p>\n<pre><code class=\"php\">\tprotected _table_columns =&gt; array(8) (         &quot;id&quot; =&gt; array(4) (             &quot;type&quot; =&gt; string(3) &quot;int&quot;             &quot;is_nullable&quot; =&gt; bool FALSE         )         &quot;email&quot; =&gt; array(4) (             &quot;type&quot; =&gt; string(6) &quot;string&quot;             &quot;is_nullable&quot; =&gt; bool FALSE         ) \t... <\/code><\/pre>\n<p>  \u041d\u0430 \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u0432\u0438\u0434\u043d\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0411\u0414 (\u043a\u043b\u0438\u043a\u0430\u0431\u0435\u043b\u044c\u043d\u043e)<br \/>  <a href=\"http:\/\/www.habrastorage.com\/images\/20120913iv.png\"><img decoding=\"async\" src=\"http:\/\/www.habrastorage.com\/images\/20120913iv.png\" alt=\"image\"\/><\/a><\/p>\n<p>  \u041f\u0440\u0438\u0447\u0435\u043c ORM::factory() \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0432\u044b\u0437\u043e\u0432 \u043f\u043e\u0434\u0440\u044f\u0434 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438  <\/p>\n<pre><code class=\"php\">ORM::factory('model_name')-&gt;method_1() ORM::factory('model_name')-&gt;method_2() <\/code><\/pre>\n<p>  \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 2 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 <i>SHOW FULL COLUMNS FROM<\/i> (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 <i>$_table_columns<\/i> \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435). \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0438\u0437 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u2014 \u0432\u044b\u0437\u043e\u0432 <i>ORM::factory(&#8216;user&#8217;)-&gt;with(&#8216;profile&#8217;)-&gt;with(&#8216;photo&#8217;)<\/i>. \u0412\u044b\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0411\u0414 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 (\u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u043c ORM) \u2014 <i>SHOW FULL COLUMNS FROM<\/i>.<\/p>\n<h4>\u041e\u0434\u043d\u043e \u0438\u0437 \u0440\u0435\u0448\u0435\u043d\u0438\u0439<\/h4>\n<p>  \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0435, \u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043d\u0438\u0433\u0434\u0435 \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u2014 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 (\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043a\u043e\u043d\u0446\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430). \u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0432 \u0440\u0443\u0447\u043d\u0443\u044e \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e\u0434\u043e\u0431\u043d\u0430 \u0432\u044b\u0441\u0442\u0440\u0435\u043b\u0443 \u0441\u0435\u0431\u0435 \u0432 \u043d\u043e\u0433\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Optimize, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0432\u043d\u043e \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e \u043f\u0430\u043f\u043a\u0435 \u0441 \u043c\u043e\u0434\u0435\u043b\u044f\u043c\u0438, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u044c <i>extends ORM<\/i> \u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0437\u0430\u043f\u0438\u0441\u044c <i>protected $_table_columns<\/i> \u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0434\u043b\u044f \u043c\u043e\u0434\u0435\u043b\u0438 \u044d\u0442\u043e\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f <i>ORM::factory(&#8216;model&#8217;)-&gt;list_columns() <\/i> \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u043d\u043d\u044b\u0439 \u00ab\u0440\u043e\u0434\u043d\u043e\u0439\u00bb \u043c\u0435\u0442\u043e\u0434 Debug::vars();<br \/>  <b>\u041a\u043e\u0434 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u2014 \u043f\u043e\u0434 \u0441\u043f\u043e\u0439\u043b\u0435\u0440\u043e\u043c<\/b><\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 Optimize<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"php\">class Optimize{      private static $files = array();      \/**      * Returns database tables columns list      *       * @uses find_models()      * @uses _dump_simple()      *\/     public static function list_columns()     {         $dir = APPPATH . &quot;classes\/model&quot;;          self::find_models($dir);                  foreach (self::$files as $model) {             $file_text = file_get_contents($model);             if(preg_match('\/extends +ORM\/i', $file_text) && !preg_match('\/_table_columns\/i', $file_text)){                  preg_match(&quot;\/(class\\sModel_)(\\w+)?(\\sextends)\/&quot;, $file_text, $match);                 $model_name = preg_replace(&quot;\/(class\\sModel_)(.*?)(\\sextends)\/&quot;, &quot;$2&quot;, $match[0]);                                  echo '&lt;h3&gt;Model_'.ucfirst($model_name).'&lt;\/h3&gt;';                                  $columns[] = ORM::factory(strtolower($model_name))-&gt;list_columns();                 $output = array();                 foreach ($columns as $var) {                     $output[] = self::_dump_simple($var, 1024);                 }                  echo '&lt;pre&gt;protected $_table_columns = ' . substr(implode(&quot;\\n&quot;, $output), 0, -1) . ';&lt;\/pre&gt;';                 echo '========================================================';             }         }     }      public static function find_models($in_dir)     {          if (preg_match(&quot;\/_vti[.]*\/i&quot;, $in_dir)) {             return;         }         if ($dir_handle = @opendir($in_dir)) {             while ($file = readdir($dir_handle)) {                 $path = $in_dir . &quot;\/&quot; . $file;                 if ($file != &quot;..&quot; && $file != &quot;.&quot; && is_dir($path) && $file != '.svn') {                     self::find_models($path);                 }                  if (is_file($path) && $file != &quot;..&quot; && $file != &quot;.&quot; &&  strtolower(substr(strrchr($path, '.'), 1))=='php') {                     self::$files[] = $path;                 }             }         }     }      protected static function _dump_simple(& $var, $length = 128, $limit = 10, $level = 0)     {         if ($var === NULL) {             return 'NULL,';         }         elseif (is_bool($var)) {             return ($var ? 'TRUE' : 'FALSE') . ',';         }         elseif (is_float($var)) {             return $var . ',';         }         elseif (is_string($var)) {             return &quot;'&quot; . $var . &quot;',&quot;;         }         elseif (is_array($var)) {             $output = array();              $space = str_repeat($s = '    ', $level);              static $marker;              if ($marker === NULL) {                 $marker = uniqid(&quot;\\x00&quot;);             }              if ($level &lt; $limit) {                 $output[] = &quot;array(&quot;;                  $var[$marker] = TRUE;                 foreach ($var as $key =&gt; & $val) {                     if ($level == 1 && !in_array($key, array('type', 'is_nullable')))                          continue;                     if ($key === $marker)                         continue;                     if (!is_int($key)) {                         $key = &quot;'&quot; . htmlspecialchars($key, ENT_NOQUOTES, Kohana::$charset) . &quot;'&quot;;                     }                      $output[] = &quot;$space$s$key =&gt; &quot; . self::_dump_simple($val, $length, $limit, $level + 1);                 }                 unset($var[$marker]);                  $output[] = &quot;$space),&quot;;             }              return implode(&quot;\\n&quot;, $output);         }         else {             return htmlspecialchars(print_r($var, TRUE), ENT_NOQUOTES, Kohana::$charset) . ',';         }     }  } \/\/ End Optimize <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0430\u043f\u0438\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043a\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u044b\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u043e \u043d\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u2014 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0441 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043a\u043e\u0434\u0430 \u043d\u0435 \u0443\u0433\u0430\u0434\u0430\u0435\u0448\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0435 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0432 \u0432\u0438\u0434\u0435:  <\/p>\n<pre><code class=\"php\">Model_Option protected $_table_columns = array(     'id' =&gt; array(         'type' =&gt; 'int',         'is_nullable' =&gt; FALSE,     ),     'name' =&gt; array(         'type' =&gt; 'string',         'is_nullable' =&gt; FALSE,     ), <\/code><\/pre>\n<p>  \u0421\u0430\u043c \u043a\u043b\u0430\u0441\u0441 (\u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \/application\/classes\/optimize.php ). \u0412\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u0438\u0437 \u043b\u044e\u0431\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430:  <\/p>\n<pre><code class=\"php\"> echo Optimize::list_columns(); <\/code><\/pre>\n<p>  \u0414\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 \u043e\u0442\u0441\u0443\u0442\u0432\u0438\u0435 last_query \u0432 \u0440\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u0430\u043d\u043d\u043e\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u043c\u043e\u0434\u0435\u043b\u0438. <br \/>  <a href=\"http:\/\/cdn.habrastorage.com\/images\/20120913b2.png\"><img decoding=\"async\" src=\"http:\/\/cdn.habrastorage.com\/images\/20120913b2.png\" alt=\"image\"\/><\/a><\/p>\n<p>  \u0414\u0440\u0443\u0433\u0438\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0440\u0435\u0449\u0435\u043d\u0438\u044f \u2014 <a href=\"http:\/\/blogocms.ru\/2011\/05\/kohana-uskoryaem-orm\/\">blogocms.ru\/2011\/05\/kohana-uskoryaem-orm\/<\/a> \u2014 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0430\u0431\u043b\u0438\u0446. \u0411\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u043e \u0438 \u043c\u0435\u043d\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438.<\/p>\n<h4>\u041f\u0440\u043e\u0444\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0442\u0435\u0441\u0442\u044b<\/h4>\n<p>  \u0411\u044b\u043b\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 (\u043d\u0430 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e). \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u0438\u043d\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0435\u0441\u0442  <\/p>\n<pre><code class=\"php\">$token = Profiler::start('Model', 'User'); ORM::factory('user')-&gt;with('profile')-&gt;with('profile:file');   Profiler::stop($token); echo View::factory('profiler\/stats');  <\/code><\/pre>\n<p>  \u0418 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u0435\u0433\u043e 10 \u0440\u0430\u0437. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0442\u043e \u0431\u0435\u0437 \u0437\u0430\u043f\u043e\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 <i>$_table_columns<\/i> \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0443\u0445\u043e\u0434\u0438\u0442 0.15 \u0441\u0435\u043a \u0438\u0437 \u043d\u0438\u0445 0.005 \u0441\u0435\u043a. \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b SHOW FULL COLUMNS FROM.<br \/>  \u0421 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u043c <i>$_table_columns<\/i> \u2014 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c 0.145 \u0441\u0435\u043a. \u041f\u0440\u0438\u0440\u043e\u0441\u0442 <b>3.3%<\/b><\/p>\n<p>  \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442 c \u0432\u044b\u0431\u043e\u0440\u043a\u043e\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043c\u043e\u0434\u0435\u043b\u0435\u0439.  <\/p>\n<pre><code class=\"php\">$token = Profiler::start('Model', 'User'); for ($index = 0; $index &lt; 10; $index++) {     ORM::factory('user')-&gt;with('profile')-&gt;with('profile:file')-&gt;get_user(array(rand(1,100), rand(1,100)));    } Profiler::stop($token); echo View::factory('profiler\/stats');  <\/code><\/pre>\n<p>  \u0411\u0435\u0437 \u0437\u0430\u043f\u043e\u043b\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 <i>$_table_columns<\/i> \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430 \u0432\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0443\u0445\u043e\u0434\u0438\u0442 0.18 \u0441\u0435\u043a \u0438\u0437 \u043d\u0438\u0445 0.015 \u0441\u0435\u043a. \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0411\u0414 \u043d\u0430 \u0437\u0430\u043f\u043e\u043b\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u043f\u043e\u043b\u044f\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u043f\u043e\u043c\u0435\u043d\u044c\u0448\u0435 \u2014 <b>2.8%<\/b><\/p>\n<p>  \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0446\u0438\u0444\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 ORM. \u041e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0411\u0414 \u2014 1.5 \u2014 3 \u0440\u0430\u0437\u0430 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0435\u043c ORM, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0437\u0433\u0440\u0443\u0437\u0438\u0442 \u0441\u0435\u0440\u0432\u0435\u0440 MySQL. \u041d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0438 \u043a\u0435\u0448\u0438\u0440\u0443\u044e\u0442\u0441\u044f MySQL \u2014 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0439 \u043f\u0440\u0438\u0440\u043e\u0441\u0442 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432 \u0440\u0430\u0439\u043e\u043d\u0435 2-3%. <\/p>\n<p>  \u042f\u0432\u043d\u044b\u0439 \u043c\u0438\u043d\u0443\u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0434\u0438\u043d \u2014 \u043d\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0430 \u043b\u0430\u0439\u0432 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0438 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u2014 \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <i>$_table_columns<\/i> \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0430 \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432.<\/p>\n<p>  P.S. \u0421\u043e\u0430\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438 \u2014 <a href=\"http:\/\/habrahabr.ru\/users\/unix44\/\" class=\"user_link\">unix44<\/a>, \u043a\u0442\u043e \u043d\u0435 \u0436\u0430\u0434\u043d\u044b\u0439 \u2014 \u043c\u043e\u0436\u0435\u0442 \u0434\u0430\u0442\u044c \u0438\u043d\u0432\u0430\u0439\u0442.    \t   \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\/154865\/\"> http:\/\/habrahabr.ru\/post\/154865\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \tORM, \u043d\u0435\u0441\u043e\u043c\u043d\u0435\u043d\u043d\u043e, \u043c\u043e\u0449\u043d\u0430\u044f \u0438 \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0432\u0435\u0449\u044c, \u043d\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0435, \u043d\u043e \u0435\u0449\u0435 \u0438 \u043b\u0438\u0448\u043d\u0438\u0435. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0434\u0435\u043b\u0438 ORM \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0432\u0441\u0435\u0445 \u043f\u043e\u043b\u044f\u0445 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0411\u0414. \u0427\u0442\u043e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u043c \u043a \u0411\u0414.  <\/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-154865","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/154865","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=154865"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/154865\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154865"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}