{"id":259572,"date":"2015-06-18T07:00:02","date_gmt":"2015-06-18T03:00:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=259572"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=259572","title":{"rendered":"Active Record \u0434\u043b\u044f Node.js \u0441 API \u043e\u0442 Yii 2"},"content":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b9c\/e1d\/925\/b9ce1d9253aa4d0595a6aedb0157380f.png\" alt=\"Jii\" align=\"right\"\/><\/p>\n<h1>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h1>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0430\u043c, \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044f\u043c Yii \u0438 Node.js.<br \/>  \u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"http:\/\/www.jiiframework.ru\/\">Jii<\/a>, \u0432 <a href=\"http:\/\/habrahabr.ru\/post\/260295\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (Query Builder).<br \/>  \u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Active Record.<\/p>\n<h1>Active Record<\/h1>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a0c\/e49\/a69\/a0ce49a699f74a138d2989ec37d5295e.jpg\" \/><\/div>\n<p><a name=\"habracut\"><\/a><a href=\"http:\/\/en.wikipedia.org\/wiki\/Active_record_pattern\">Active Record<\/a> \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0438 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0445\u0440\u0430\u043d\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u041a\u043b\u0430\u0441\u0441 Active Record \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0435 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0438\u0441\u0430\u0442\u044c SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u0412\u044b \u0438\u043c\u0435\u0435\u0442\u0435 \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c Active Record \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c, \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c Active Record \u043a\u043b\u0430\u0441\u0441 `app.models.Customer`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 `customer` \u0438 `name` \u044d\u0442\u043e \u0438\u043c\u044f \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 `customer`. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 `customer`:<\/p>\n<pre><code class=\"javascript\">var customer = new app.models.Customer(); customer.name = 'Vladimir'; customer.save(); <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0434\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0438 \u0433\u0434\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0438\u0434\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"javascript\">db.createCommand('INSERT INTO `customer` (`name`) VALUES (:name)', {     ':name': 'Vladimir', }).execute(); <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 Active Record<\/h2>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 Active Record, \u0443\u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0432 <i>Jii.sql.ActiveRecord<\/i>. \u041a\u0430\u0436\u0434\u044b\u0439 Active Record \u043a\u043b\u0430\u0441\u0441 \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.tableName()<\/i> \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441 \u043a\u0430\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0441\u0432\u044f\u0437\u0430\u043d \u043a\u043b\u0430\u0441\u0441.<\/p>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c `app.models.Customer` \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u044b `customer`.<\/p>\n<pre><code class=\"javascript\">var Jii = require('jii');  \/** * @class app.models.Customer * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Customer', \/** @lends app.models.Customer.prototype *\/{      __extends: Jii.sql.ActiveRecord,      __static: \/** @lends app.models.Customer *\/{          tableName: function() {             return 'customer';         }      }  }); <\/code><\/pre>\n<p>  \u041a\u043b\u0430\u0441\u0441 Active Record \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0435\u043b\u044c\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u044b\u0447\u043d\u043e \u043c\u044b \u043a\u043b\u0430\u0434\u0435\u043c Active Record \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d `models`.<\/p>\n<p>  \u041a\u043b\u0430\u0441\u0441 <i>Jii.sql.ActiveRecord<\/i> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 <i>Jii.base.Model<\/i>, \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043e\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442 *\u0432\u0441\u0435* \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u0435\u0439, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u044b, \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438, \u0441\u0435\u0440\u0435\u043b\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0442.\u0434.<\/p>\n<h2>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0411\u0414<\/h2>\n<p>  \u041f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, Active Record \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <a href=\"http:\/\/www.jiiframework.ru\/guide\/structure-application-components\">\u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/a> `db`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <i>Jii.sql.BaseConnection<\/i> \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0411\u0414. \u041a\u0430\u043a \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 <a href=\"http:\/\/habrahabr.ru\/post\/260295\/\">\u0441\u0442\u0430\u0442\u044c\u0435<\/a>, \u0432 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u00ab\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445\u00bb, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f `db` \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"javascript\">return {     components: {         db: {             className: 'Jii.sql.mysql.Connection',             host: '127.0.0.1',             database: 'testdb',             username: 'demo',             password: 'demo',             charset: 'utf8',         }     } }; <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.getDb()<\/i>:<\/p>\n<pre><code class=\"javascript\">\/** * @class app.models.Customer * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Customer', \/** @lends app.models.Customer.prototype *\/{      __extends: Jii.sql.ActiveRecord,      __static: \/** @lends app.models.Customer *\/{          STATUS_INACTIVE: 0,         STATUS_ACTIVE: 1,          \/\/ ...          getDb: function() {             \/\/ use the &quot;db2&quot; application component             return Jii.app.db2;         }      }  }); <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u044b\u0431\u043e\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/4bc\/cec\/931\/4bccec931e5049a69f67722b60df98fd.jpg\" \/><\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043a\u043b\u0430\u0441\u0441\u0430 Active Record, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0411\u0414.<br \/>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0442\u0440\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f:<\/p>\n<p>  1. \u0421\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0443\u0442\u0435\u043c \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 <i>Jii.sql.ActiveRecord.find()<\/i>;<br \/>  2. \u0421\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432;<br \/>  3. \u0412\u044b\u0437\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0432\u0438\u0434\u0435 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 Active Record.<\/p>\n<p>  \u042d\u0442\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043e\u0447\u0435\u043d\u044c \u0441\u0445\u043e\u0436\u0438 \u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f\u043c\u0438 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.find()<\/i>, \u0430 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0447\u0435\u0440\u0435\u0437 `new`.<\/p>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432, \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u0435, \u043a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Active Query \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 ID 123 \/\/ SELECT * FROM `customer` WHERE `id` = 123 app.models.Customer.find()     .where({id: 123})     .one()     .then(function(customer) {         \/\/ ...     });  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e ID \/\/ SELECT * FROM `customer` WHERE `status` = 1 ORDER BY `id` app.models.Customer.find()     .where({status: app.models.Customer.STATUS_ACTIVE})     .orderBy('id')     .all()     .then(function(customers) {         \/\/ ...     });  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \/\/ SELECT COUNT(*) FROM `customer` WHERE `status` = 1     app.models.Customer.find()     .where({status': app.models.Customer.STATUS_ACTIVE})     .count()     .then(function(count) {         \/\/ ...     });  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432 \u0432\u0438\u0434\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u0433\u0434\u0435 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f ID \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \/\/ SELECT * FROM `customer`     app.models.Customer.find()     .indexBy('id')     .all()     .then(function(customers) {         \/\/ ...     }); <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043f\u043e ID \u0441\u043e\u0437\u0434\u0430\u043d\u044b \u043c\u0435\u0442\u043e\u0434\u044b:  <\/p>\n<ul>\n<li><i>Jii.sql.ActiveRecord.findOne()<\/i>: \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Active Record, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0430\u043f\u0440\u043e\u0441\u0430.<\/li>\n<li><i>Jii.sql.ActiveRecord.findAll()<\/i>: \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 Active Record, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0430\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/li>\n<\/ul>\n<p>  \u041e\u0431\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0430\u0433\u0440\u0443\u043c\u0435\u043d\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430:  <\/p>\n<ul>\n<li>\u0421\u043a\u0430\u043b\u044f\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0438\u0434\u0435\u0442 \u043f\u043e\u0438\u0441\u043a. \u041f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0439 \u043a\u043b\u044e\u0447 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0438\u0437 \u0441\u0445\u0435\u043c\u044b \u0411\u0414.<\/li>\n<li>\u041c\u0430\u0441\u0441\u0438\u0432 \u0441\u043a\u0430\u043b\u044f\u0440\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439: \u043c\u0430\u0441\u0441\u0438\u0432 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0434\u0435\u0442 \u043f\u043e\u0438\u0441\u043a. \u2014 \u041e\u0431\u044a\u0435\u043a\u0442, \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0434\u0435\u0442 \u043f\u043e\u0438\u0441\u043a.<\/li>\n<\/ul>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043a\u0430\u043a \u044d\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 ID 123 \/\/ SELECT * FROM `customer` WHERE `id` = 123 app.models.Customer     .findOne(123)     .then(function(customer) {         \/\/ ...     });  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432\u0441 ID 100, 101, 123 \u0438\u043b\u0438 124 \/\/ SELECT * FROM `customer` WHERE `id` IN (100, 101, 123, 124) app.models.Customer     .findAll([100, 101, 123, 124])     .then(function(customers) {         \/\/ ...     });  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 ID 123 \/\/ SELECT * FROM `customer` WHERE `id` = 123 AND `status` = 1 app.models.Customer     .findOne({         id: 123,         status: app.models.Customer.STATUS_ACTIVE     })     .then(function(customer) {         \/\/ ...     });  \/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \/\/ SELECT * FROM `customer` WHERE `status` = 0 app.models.Customer     .findAll({         status: app.models.Customer.STATUS_INACTIVE     })     .then(function(customers) {         \/\/ ...     }); <\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u041d\u0438 <i>Jii.sql.ActiveRecord.findOne()<\/i>, \u043d\u0438 <i>Jii.sql.ActiveQuery.one()<\/i> \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u044f\u0442 `LIMIT 1` \u0432 SQL \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435. \u0415\u0441\u043b\u0438 \u0412\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c `limit(1)` \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u043f\u0440\u0435\u0434\u0435\u043b\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 `app.models.Customer.find().limit(1).one()`.<\/p><\/blockquote>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0442\u0430\u043a \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0435 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u0445 \u0438\u0445 \u0432 Active Record. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.findBySql()<\/i>:<\/p>\n<pre><code class=\"javascript\">\/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 var sql = 'SELECT * FROM customer WHERE status=:status'; app.models.Customer     .findBySql(sql, {':status': app.models.Customer.STATUS_INACTIVE})     .all()     .then(function(customers) {         \/\/ ...     }); <\/code><\/pre>\n<p>  \u041d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 <i>Jii.sql.ActiveRecord.findBySql()<\/i>, \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f.<\/p>\n<h2>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0434\u0430\u043d\u043d\u044b\u043c<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/9e6\/9e5\/414\/9e69e5414a394661816c4a84e02e194d.jpg\" \/><\/div>\n<p>  \u041a\u0430\u043a \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043b\u043e\u0441\u044c \u0432\u044b\u0448\u0435, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b Active Record \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u0437 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 Active Record. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b Active Record, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">\/\/ \u0418\u043c\u0435\u043d\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 &quot;id&quot; \u0438 &quot;email&quot; \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b &quot;customer&quot; app.models.Customer .findOne(123) .then(function(customer) { var id = customer.get('id'); var email = customer.get('email'); }); <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445<\/h3>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u043a Active Record \u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u043e \u0438\u043d\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043b\u0435\u043d\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0440\u0430\u0441\u0445\u043e\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 Active Record. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0445 \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveQuery.asArray()<\/i>.  <\/p>\n<blockquote><p>\u041f\u043e \u0444\u0430\u043a\u0442\u0443, \u0432 JavaScript \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043c\u0430\u0441\u0441\u0438\u0432, \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0439 \u0431\u044b\u043b\u043e \u0431\u044b \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>asObject()<\/i>, \u0438 \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 (\u0441\u0438\u043d\u043e\u043d\u0438\u043c) \u0435\u0441\u0442\u044c. \u041d\u043e \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f API Yii 2 \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043c\u0435\u0442\u043e\u0434 <i>asArray()<\/i>.<\/p><\/blockquote>\n<p>  <\/p>\n<pre><code class=\"javascript\">\/\/ \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432\u0441\u0435\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432, \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \/\/ \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u043a \u043e\u0431\u044a\u0435\u043a\u0442 app.models.Customer.find()     .asArray() \/\/ alias is asObject()     .all()     .then(function(customers) {         \/\/ ...     }); <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  \u0418\u0437\u043f\u043e\u043b\u044c\u0437\u0443\u044f Active Record, \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0411\u0414 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438:  <\/p>\n<ol>\n<li>\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0438\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Active Record;<\/li>\n<li>\u0417\u0430\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430\u043c<\/li>\n<li>\u0412\u044b\u0437\u043e\u0432\u0438\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.save()<\/i> \u0434\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<\/ol>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">\/\/ \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 var customer = new app.models.Customer(); customer.set('name', 'James'); customer.set('email', 'james@example.com'); customer.save().then(function(success) {      return app.models.Customer.findOne(123);     }).then(function(customer) {          \/\/ \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445         customer.set('email', 'james@newexample.com');         return customer.save();     }).then(function(success) {         \/\/ ...     }); <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.save()<\/i> \u043c\u043e\u0436\u0435\u0442 \u043b\u0438\u0431\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u043b\u0438\u0431\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f Active Record. \u0415\u0441\u043b\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u0435\u0440 \u0431\u044b\u043b \u0441\u043e\u0437\u0434\u0430\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 `new`, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443. \u0415\u0441\u043b\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043f\u043e\u043b\u0443\u0447\u0435\u043d \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <i>find()<\/i> \u0438 \u0435\u043c\u0443 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0438\u043b\u0438 \u0443\u0436\u0435 \u0431\u044b\u043b \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 <i>save()<\/i> \u0440\u0430\u043d\u0435\u0435, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 <i>save()<\/i><br \/>  \u043e\u0431\u043d\u043e\u0432\u0438\u0442 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<h3>\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445<\/h3>\n<p>  \u041a\u043b\u0430\u0441\u0441 <i>Jii.sql.ActiveRecord<\/i> \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u0435\u0442\u0441\u044f \u043e\u0442 <i>Jii.base.Model<\/i>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043d\u0435\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <i>Jii.sql.ActiveRecord.rules()<\/i> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.validate()<\/i>.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.save()<\/i>, \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.validate()<\/i>. \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0411\u0414; \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0432\u0435\u0440\u043d\u044b, \u0442\u043e \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0440\u043d\u0435\u0442 `false` \u0438 \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0448\u0438\u0431\u043a\u0443 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.getErrors()<\/i> \u0438\u043b\u0438 \u0435\u043c\u0443 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435.<\/p>\n<h3>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432<\/h3>\n<p>  \u041a\u0430\u043a \u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 \u043c\u043e\u0434\u0435\u043b\u0438, \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 Active Record \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u043e \u0441\u043f\u043e\u0441\u043e\u0431, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 Active Record \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430. \u041f\u043e\u043c\u043d\u0438\u0442\u0435, \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043c\u0430\u0441\u0441\u043e\u0432\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u044b.<\/p>\n<pre><code class=\"javascript\">var values = {     name: 'James',     email: 'james@example.com' };  var customer = new app.models.Customer();  customer.setAttributes(values); customer.save(); <\/code><\/pre>\n<p>  <\/p>\n<h3>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b<\/h3>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.save()<\/i>, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 Active Record. \u0410\u0442\u0440\u0438\u0431\u0443\u0442 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u0431\u044b\u043b\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043e \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432.<\/p>\n<p>  Active Record \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0445 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432. \u041e\u043d\u0430 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u043d\u044b\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.getDirtyAttributes()<\/i>.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432, \u0432\u044b\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.getOldAttributes()<\/i> \u0438\u043b\u0438 <i>Jii.sql.ActiveRecord.getOldAttribute()<\/i>.<\/p>\n<h3>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e<\/h3>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u0432\u0430\u0448\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043c\u043e\u0433\u0443\u0442 \u0438\u043c\u0435\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c Active Record \u044d\u0442\u0438\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438, \u0432\u044b\u0437\u0432\u0430\u0432 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.loadDefaultValues()<\/i>. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439, \u0442.\u043a. \u0441\u0445\u0435\u043c\u0430 \u0411\u0414 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"javascript\">var customer = new app.models.Customer(); customer.loadDefaultValues(); \/\/ customer.get('xyz') \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430 `xyz` \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u043e\u0432\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e \u043f\u043e-\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430 `xyz`. <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0442\u0440\u043e\u043a<\/h3>\n<p>  \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u043c Active Record. \u0427\u0442\u043e\u0431\u044b \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u043a \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.updateAll()<\/i>:<\/p>\n<pre><code class=\"javascript\">\/\/ UPDATE `customer` SET `status` = 1 WHERE `email` LIKE `%@example.com%` app.models.Customer.updateAll({status: app.models.Customer.STATUS_ACTIVE}, {'like', 'email', '@example.com'}); <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/h2>\n<p>  \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443 \u044d\u043a\u0441\u0435\u043c\u043f\u043b\u044f\u0440\u0430 Active Record, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435, \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.delete()<\/i>.<\/p>\n<pre><code class=\"javascript\">app.models.Customer     .findOne(123)     .then(function(customer) {         customer.delete();     }); <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.deleteAll()<\/i> \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u0442\u0440\u043e\u043a \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e.<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">app.models.Customer.deleteAll({status: app.models.Customer.STATUS_INACTIVE}); <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/ddb\/2db\/383\/ddb2db383aa74be985d057f79ca9c25b.jpg\" \/><\/div>\n<p>  \u041f\u043e\u043c\u0438\u043c\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, Active Record \u0441\u043f\u043e\u0441\u043e\u0431\u0435\u043d \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u0445 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b \u0441 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438. \u041f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0441\u0432\u044f\u0437\u0438 \u0432 Active Record, \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0437\u0430\u043a\u0430\u0437\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 `customer.load(&#8216;orders&#8217;)`, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 `app.models.Order`.<\/p>\n<h3>\u041e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h3>\n<p>  \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Active Record, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Active Record. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">\/** * @class app.models.Customer * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Customer', \/** @lends app.models.Customer.prototype *\/{      \/\/ ...      getOrders: function() {         return this.hasMany(app.models.Order.className(), {customer_id: 'id'});     }  });  \/** * @class app.models.Order * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Order', \/** @lends app.models.Order.prototype *\/{      \/\/ ...      getCustomer: function() {         return this.hasOne(app.models.Customer.className(), {id: 'customer_id'});     }  }); <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0435, \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 `orders` \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 `app.models.Customer`, \u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 `customer` \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 `app.models.Order`.<\/p>\n<p>  \u041a\u0430\u0436\u0434\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d \u043a\u0430\u043a `getXyz` (get + \u0438\u043c\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0431\u0443\u043a\u0432\u043e\u0439 \u0432 \u043d\u0438\u0436\u043d\u0435\u043c \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0435). \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0438\u043c\u0435\u043d\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f *\u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443*.<\/p>\n<p>  \u0412 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0438, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e:<\/p>\n<ul>\n<li>\u041a\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u044c \u0441\u0432\u044f\u0437\u0438: \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <i>Jii.sql.ActiveRecord.hasMany()<\/i>\u00a0\u0438\u043b\u0438 <i>Jii.sql.ActiveRecord.hasOne()<\/i>. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0443 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u043c\u043d\u043e\u0433\u043e \u0437\u0430\u043a\u0430\u0437\u043e\u0432, \u0430 \u0443 \u0437\u0430\u043a\u0430\u0437\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043a\u043b\u0438\u0435\u043d\u0442.<\/li>\n<li>\u041d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 Active Record: \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0443 \u0432\u044b\u0448\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 `Xyz.className()`, \u0447\u0442\u043e\u0431\u044b, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0435\u0449\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0447\u0442\u043e\u0431\u044b IDE \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0430 \u0412\u0430\u043c \u0438\u043c\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438.<\/li>\n<li>\u0421\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0441\u0445\u0435\u043c\u0430\u043c\u0438 \u0442\u0430\u0431\u043b\u0438\u0446: \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 (\u044b), \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0434\u0432\u0430 \u0442\u0438\u043f\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u2014 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c<\/h3>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0447\u0435\u0440\u0435\u0437 \u0438\u043c\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u044f. \u0415\u0441\u043b\u0438 \u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0443\u0436\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0435\u043d\u044b \u0432 Active Record, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 Active Record \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u0443 \u043a <a href=\"http:\/\/www.jiiframework.ru\/guide\/concept-properties\">\u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c<\/a> \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <i>get()<\/i>. \u0418\u043d\u0430\u0447\u0435, \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.load()<\/i> \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 `Promise`, \u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0430\u0442\u044c \u043b\u0438\u0448\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0411\u0414, \u0435\u0441\u043b\u0438 \u0441\u0432\u044f\u0437\u044c \u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0435\u043d\u0430 \u0440\u0430\u043d\u0435\u0435.<\/p>\n<pre><code class=\"javascript\">\/\/ SELECT * FROM `customer` WHERE `id` = 123 app.models.Customer     .findOne(123)     .then(function(customer) {         \/\/ SELECT * FROM `order` WHERE `customer_id` = 123         return customer.load('orders');     })     .then(function(orders) {         \/\/ orders - \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 `app.models.Order`     }); <\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u043c <i>Jii.sql.ActiveRecord.hasMany()<\/i>, \u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 Active Record (\u0438\u043b\u0438 \u043f\u0443\u0441\u0442\u044b\u043c \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u043c). \u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <i>Jii.sql.ActiveRecord.hasOne()<\/i>, \u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c Active Record \u0438\u043b\u0438 `null`, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442.<\/p>\n<p>  \u041f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437, \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0432 \u0411\u0414, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435. \u041f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438, \u0437\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<h3>\u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 (Junction Table)<\/h3>\n<p>  \u041f\u0440\u0438 \u043c\u043e\u0434\u0435\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0433\u0434\u0430 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c\u0438 Many-Many, \u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u2014 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Junction_table\">Junction Table<\/a>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u0431\u043b\u0438\u0446\u0430 `order` \u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 `item` \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u044b `order_item`.<\/p>\n<p>  \u041f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u0442\u0430\u043a\u0438\u0445 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439, \u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <i>Jii.sql.ActiveQuery.via()<\/i> \u0438\u043b\u0438 <i>Jii.sql.ActiveQuery.viaTable()<\/i> \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b. \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0438\u043c\u0435\u043d\u0438 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">\/** * @class app.models.Order * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Order', \/** @lends app.models.Order.prototype *\/{      \/\/ ...      getItems: function() {         return this.hasMany(app.models.Item.className(), {id: 'item_id'})             .viaTable('order_item', {order_id: 'id'});     }  }); <\/code><\/pre>\n<p>  \u0438\u043b\u0438 \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u043d\u043e,<\/p>\n<pre><code class=\"javascript\">\/** * @class app.models.Order * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Order', \/** @lends app.models.Order.prototype *\/{      \/\/ ...      getOrderItems: function() {         return this.hasMany(app.models.OrderItem.className(), {order_id: 'id'});     },      getItems: function() {         return this.hasMany(app.models.Item.className(), {id: 'item_id'})             .via('orderItems');     }  }); <\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439, \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">\/\/ SELECT * FROM `order` WHERE `id` = 100 app.models.Order     .findOne(100)     .then(function(order) {          \/\/ SELECT * FROM `order_item` WHERE `order_id` = 100         \/\/ SELECT * FROM `item` WHERE `item_id` IN (...)         return order.load('items');     })     .then(function(items) {         \/\/ items - \u043c\u0430\u0441\u0441\u0438\u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 `app.models.Item`     }); <\/code><\/pre>\n<p>  <\/p>\n<h3>\u041b\u0435\u043d\u0438\u0432\u0430\u044f \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0438 \u0436\u0430\u0434\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430<\/h3>\n<p>  \u0412 \u0440\u0430\u0437\u0434\u0435\u043b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c, \u043c\u044b \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u0438\u0437 Active Record \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434\u044b <i>get()<\/i> \u0438\u043b\u0438 <i>load()<\/i>. SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u0411\u0414 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0422\u0430\u043a\u0438\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0437\u0432\u0430\u044e\u0442\u0441\u044f \u043b\u0435\u043d\u0438\u0432\u044b\u043c\u0438 (lazy loading).<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">\/\/ SELECT * FROM `customer` WHERE `id` = 123 app.models.Customer     .findOne(123)     .then(function(customer) {         \/\/ SELECT * FROM `order` WHERE `customer_id` = 123         customer.load('orders').then(function(orders) {              \/\/ SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f             return customer.load('orders');         }).then(function(orders2) {              \/\/ \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u043a\u0438 \u0441\u0432\u044f\u0437\u0435\u0439, \u043e\u043d\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 &lt;i&gt;get()&lt;\/i&gt;.             var orders3 = customer.get('orders');         });     });  <\/code><\/pre>\n<p>  \u041b\u0435\u043d\u0438\u0432\u044b\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u0430 \u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0441 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u043c \u0437\u0430\u043d\u043d\u044b\u043c \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 Active Record. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u0441\u043a\u043e\u043b\u044c\u043a\u043e SQL \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043e?<\/p>\n<pre><code class=\"javascript\">\/\/ SELECT * FROM `customer` LIMIT 100 app.models.Customer.find()     .limit(100)     .all()     .then(function(customers) {         return Promise.all(customers.map(function(customer) {              \/\/ SELECT * FROM `order` WHERE `customer_id` = ...             return customer.load('orders');         }));     }).then(function(result) {         var firstOrder = result[0][0];         \/\/ ...     }); <\/code><\/pre>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f 101 SQL \u0437\u0430\u043f\u0440\u043e\u0441! \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u044b \u0437\u0430\u044f\u0432\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441. \u0427\u0442\u043e\u0431\u044b \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434 *\u0436\u0430\u0434\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438*, \u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0438\u0436\u0435,<\/p>\n<pre><code class=\"javascript\">\/\/ SELECT * FROM `customer` LIMIT 100; \/\/ SELECT * FROM `orders` WHERE `customer_id` IN (...) app.models.Customer.find()     .with('orders')     .limit(100)     .all()     .then(function(customers) {         customers.forEach(function(customer) {              \/\/ \u0431\u0435\u0437 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430             var orders = customer.get('orders');         });     }); <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439. \u0412\u044b \u0434\u0430\u0436\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 `app.models.Customer` \u0441\u0432\u044f\u0437\u0430\u043d \u0441` app.models.Order` \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 `orders`, \u0430 `app.models.Order` \u0441\u0432\u044f\u0437\u0430\u043d \u0441 `Item` \u0447\u0435\u0440\u0435\u0437 `items`. \u041f\u0440\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0435 `app.models.Customer`, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 `items` \u0443\u043a\u0430\u0437\u0430\u0432 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <i>with()<\/i> `orders.items`.<\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <i>Jii.sql.ActiveQuery.with()<\/i>. \u041c\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 `app.models.Customer` \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f: `orders` \u0438 `country`, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 `app.models.Order` \u0438\u043c\u0435\u0435\u0442 \u043e\u0434\u043d\u043e \u0441\u043e\u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u2014 `items`.<\/p>\n<pre><code class=\"javascript\">\/\/ \u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 &quot;orders&quot; \u0438 &quot;country&quot; app.models.Customer.find()     .with('orders', 'country')     .all()     .then(function(customers) {         \/\/ ...     });  \/\/ \u044d\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0430\u0441\u0441\u0438\u0432 app.models.Customer.find()     .with(['orders', 'country'])     .all()     .then(function(customers) {         \/\/ \u0431\u0435\u0437 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430         var orders = customers[0].get('orders');         var country = customers[0].get('country');     });  \/\/ \u041f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f &quot;orders&quot; \u0438 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f &quot;orders.items&quot; app.models.Customer.find()     .with('orders.items')     .all()     .then(function(customers) {          \/\/ \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0437\u0430\u043a\u0430\u0437\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430         \/\/ \u0431\u0435\u0437 SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430         var items = customers[0].get('orders')[0].get('items');     }); <\/code><\/pre>\n<p>  \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0433\u043b\u0443\u0431\u043e\u043a\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f, \u0442\u0430\u043a\u0438\u0435 \u043a\u0430\u043a `a.b.c.d`. \u0412\u0441\u0435 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043d\u0443\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u044b.<\/p>\n<p>  \u041f\u0440\u0438 \u0436\u0430\u0434\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u043f\u0435\u0440\u0435\u0434\u0430\u0432 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">\/\/ \u041f\u043e\u0438\u0441\u043a \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0438\u0445 \u0441\u0442\u0440\u0430\u043d\u0430\u043c\u0438 \u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c\u0438 \u0437\u0430\u043a\u0430\u0437\u0430\u043c\u0438 \/\/ SELECT * FROM `customer` \/\/ SELECT * FROM `country` WHERE `id` IN (...) \/\/ SELECT * FROM `order` WHERE `customer_id` IN (...) AND `status` = 1 app.models.Customer.find()     .with({         country: 'country',         orders: function (query) {             query.andWhere({'status': app.models.Order.STATUS_ACTIVE});         }     })     .all()     .then(function(customers) {         \/\/ ...     }); <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u043e\u0433\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u0438, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043c\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043a\u043b\u044e\u0447\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430. \u041f\u0435\u0440\u0432\u044b\u043c \u0430\u0433\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c \u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 `query`, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 <i>Jii.sql.ActiveQuery<\/i>. \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435, \u043c\u044b \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043e \u0441\u0442\u0430\u0442\u0443\u0441\u0435 \u0437\u0430\u043a\u0430\u0437\u0430.<\/p>\n<h3>\u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f<\/h3>\n<p>  \u041e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 Active Record \u0437\u0430\u0447\u0430\u0441\u0442\u0443\u044e \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043b\u0430\u0441\u0441 `app.models.Customer` \u0441\u0432\u044f\u0437\u0430\u043d \u0441 `app.models.Order` \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 `orders`, \u0430 \u043a\u043b\u0430\u0441\u0441 `app.models.Order` \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d \u0441 \u043a\u043b\u0430\u0441\u0441\u043e\u043c `app.models.Customer` \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 `customer`.<\/p>\n<pre><code class=\"javascript\">\/** * @class app.models.Customer * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Customer', \/** @lends app.models.Customer.prototype *\/{      \/\/ ...      getOrders: function() {         return this.hasMany(app.models.Order.className(), {customer_id: 'id'});     }  });  \/** * @class app.models.Order * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Order', \/** @lends app.models.Order.prototype *\/{      \/\/ ...      getCustomer: function() {         return this.hasOne(app.models.Customer.className(), {id: 'customer_id'});     }  }); <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430:<\/p>\n<pre><code class=\"javascript\">\/\/ SELECT * FROM `customer` WHERE `id` = 123 app.models.Customer     .findOne(123)     .then(function(customer) {         \/\/ SELECT * FROM `order` WHERE `customer_id` = 123         return customer.load('orders');     }).then(function(orders) {         var order = orders[0];          \/\/ SELECT * FROM `customer` WHERE `id` = 123         return order.load('customer');     }).then(function(customer2) {          \/\/ \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 &quot;not the same&quot;         console.log(customer2 === customer ? 'same' : 'not the same');     }); <\/code><\/pre>\n<p>  \u041c\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u043c, \u0447\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b `customer` \u0438 `customer2` \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438, \u043d\u043e \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u041e\u043d\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438. \u041f\u0440\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u043a `order.customer` \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0439 SQL \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 `customer2`.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e SQL \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e `customer` \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f *\u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c\u044e* \u043e\u0442 `orders` \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0435\u0442\u043e\u0434\u0430 <i>Jii.sql.ActiveQuery.inverseOf()<\/i>.<\/p>\n<pre><code class=\"javascript\">\/** * @class app.models.Customer * @extends Jii.sql.ActiveRecord *\/ Jii.defineClass('app.models.Customer', \/** @lends app.models.Customer.prototype *\/{      \/\/ ...      getOrders: function() {         return this.hasMany(app.models.Order.className(), {customer_id: 'id'}).inverseOf('customer');     }  }); <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c:<\/p>\n<pre><code class=\"javascript\">\/\/ SELECT * FROM `customer` WHERE `id` = 123 app.models.Customer     .findOne(123)     .then(function(customer) {         \/\/ SELECT * FROM `order` WHERE `customer_id` = 123         return customer.load('orders');     }).then(function(orders) {         var order = orders[0];          \/\/ SELECT * FROM `customer` WHERE `id` = 123         return order.load('customer');     }).then(function(customer2) {          \/\/ \u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 &quot;same&quot;         console.log(customer2 === customer ? 'same' : 'not the same');     }); <\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>\u0417\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0434\u043b\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0439 Many-Many, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0441 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0446\u0435\u0439 (Junction Table).<\/p><\/blockquote>\n<p>  <\/p>\n<h2>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439<\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/3b0\/6a6\/86d\/3b06a686d9e74310a984a6308b3df021.jpg\" \/><\/div>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0447\u0430\u0441\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f. \u0421 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c Active Record \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"javascript\">app.models.Customer     .findOne(123)     .then(function(customer) {         var order = new app.models.Order();         order.subtotal = 100;          \/\/ ...          \/\/ \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 &quot;customer&quot; \u0434\u043b\u044f `app.models.Order` \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c.         order.customer_id = customer.id;         order.save();     }); <\/code><\/pre>\n<p>  Active Record \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.link()<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u044f\u0449\u043d\u043e:<\/p>\n<pre><code class=\"javascript\">app.models.Customer     .findOne(123)     .then(function(customer) {         var order = new app.models.Order();         order.subtotal = 100;          \/\/ ...          order.link('customer', customer);     }); <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.link()<\/i> \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u0438\u043c\u044f \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u0438 \u044d\u043a\u0437\u0435\u043f\u043c\u043b\u044f\u0440 Active Record, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c. \u041c\u0435\u0442\u043e\u0434 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442 \u0434\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 Active Record \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u0445 \u0432 \u0411\u0414. \u0412 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u043e\u043d \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442 \u0430\u0442\u0440\u0438\u0431\u0443\u0442 `customer_id` \u0432 `app.models.Order`.  <\/p>\n<blockquote><p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0434\u0432\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 Active Record.<\/p><\/blockquote>\n<p>  \u0412\u044b\u0433\u043e\u0434\u0430 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <i>Jii.sql.ActiveRecord.link()<\/i> \u0435\u0449\u0435 \u0431\u043e\u043b\u0435\u0435 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0447\u0442\u043e\u0431\u044b \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 `app.models.Order` \u0441 `app.models.Item`:<\/p>\n<pre><code class=\"javascript\">order.link('items', item); <\/code><\/pre>\n<p>  \u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 `order_item` \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0441\u0432\u044f\u0437\u0438 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u043c\u0438 Active Record, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.unlink()|unlink()<\/i>.<br \/>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,<\/p>\n<pre><code class=\"javascript\">app.models.Customer.find()     .with('orders')     .all()     .then(function(customer) {         customer.unlink('orders', customer.get('orders')[0]);     }); <\/code><\/pre>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043c\u0435\u0442\u043e\u0434 <i>Jii.sql.ActiveRecord.unlink()<\/i> \u043c\u0435\u0442\u043e\u0434 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435, \u0432 `null`. \u041e\u0434\u043d\u0430\u043a\u043e, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 `isDelete` \u043a\u0430\u043a `true`, \u0447\u0442\u043e\u0431\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b.<\/p>\n<h1>\u0412 \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438<\/h1>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/332\/cc1\/b11\/332cc1b116d9437687454015cd74f7c1.jpg\" \/><\/div>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432 Active Record \u043e\u0442 Jii \u043d\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0432\u0435\u0449\u044c \u043d\u0443\u0436\u043d\u0430\u044f \u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043e\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f.<br \/>  \u041a\u0430\u043a \u044f \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u0432 <a href=\"http:\/\/habrahabr.ru\/post\/260295\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>, Jii \u2014 \u043e\u043f\u0435\u043d\u0441\u043e\u0440\u0441\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0431\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u0441\u044f \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 Jii. \u041f\u0438\u0448\u0438\u0442\u0435 \u043d\u0430 affka@affka.ru.   \t\t\t\t<\/p>\n<div class=\"polling\">\n<form action=\"\/json\/polling\/\" class=\"poll\" method=\"post\">\n<div class=\"poll_title\">\u041a\u0430\u043a \u0432\u044b \u043e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u0442\u0435 \u0438\u0434\u0435\u044e Jii?<\/div>\n<p>  \t\t<input type=\"hidden\" name=\"post_id\" value=\"260569\"\/> \t\t<input type=\"hidden\" name=\"polling_question_id\" value=\"13703\"\/>  \t\t<\/p>\n<table class=\"answer\">\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67565\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67565\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67565\">\u0418\u0434\u0435\u044f \u043a\u0440\u0443\u0442\u0430, \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0439\u0442\u0435!<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67567\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67567\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67567\">\u0422\u0430\u043a \u0441\u0435\u0431\u0435<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67569\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67569\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67569\">\u041f\u043b\u043e\u0445\u0430\u044f \u0438\u0434\u0435\u044f, \u0437\u0430\u0439\u043c\u0438\u0442\u0435\u0441\u044c \u0434\u0440\u0443\u0433\u0438\u043c \u0434\u0435\u043b\u043e\u043c<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67571\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67571\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67571\">\u041c\u043d\u0435 \u043f\u043e\u0444\u0438\u0433<\/label> \t\t\t\t<\/td>\n<\/tr>\n<\/table>\n<p class=\"total\">\u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b 1 \u0447\u0435\u043b\u043e\u0432\u0435\u043a. \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.<\/p>\n<\/p><\/form>\n<form action=\"\/json\/polling\/\" class=\"poll\" method=\"post\">\n<div class=\"poll_title\">\u041a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0440\u0430\u0437\u0434\u0435\u043b\u043e\u0432 Jii \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435?<\/div>\n<p>  \t\t<input type=\"hidden\" name=\"post_id\" value=\"260569\"\/> \t\t<input type=\"hidden\" name=\"polling_question_id\" value=\"13705\"\/>  \t\t<\/p>\n<table class=\"answer\">\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67573\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67573\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67573\">\u0412\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043c\u043e\u0434\u0435\u043b\u044f\u0445<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67575\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67575\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67575\">HTTP \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u0440\u043e\u0443\u0442\u0438\u043d\u0433\u043e\u043c \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0435\u0439 URL<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67577\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67577\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67577\">\u041f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 (Assets Manager)<\/label> \t\t\t\t<\/td>\n<\/tr>\n<tr>\n<td class=\"input\"> \t\t\t\t\t<input type=\"radio\" id=\"vv67579\" \t\t\t\t\t\tclass=\"radio js-field-data\" \t\t\t\t\t\tname=\"variant[]\" \t\t\t\t\t\tvalue=\"67579\" \/> \t\t\t\t<\/td>\n<td class=\"label\"> \t\t\t\t\t<label for=\"vv67579\">\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0435 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0435 (\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u041c\u043e\u0434\u0443\u043b\u044c, \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442&#8230;)<\/label> \t\t\t\t<\/td>\n<\/tr>\n<\/table>\n<p class=\"total\">\u041d\u0438\u043a\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b. \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.<\/p>\n<\/p><\/form>\n<p class=\"for_users_only_msg\">\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a href=\"https:\/\/habrahabr.ru\/auth\/login\/\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/p>\n<\/p><\/div>\n<div class=\"clear\"><\/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\/260569\/\"> http:\/\/habrahabr.ru\/post\/260569\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>     \t<img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/b9c\/e1d\/925\/b9ce1d9253aa4d0595a6aedb0157380f.png\" alt=\"Jii\" align=\"right\"\/><\/p>\n<h1>\u0412\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435<\/h1>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0430\u043c, \u043b\u044e\u0431\u0438\u0442\u0435\u043b\u044f\u043c Yii \u0438 Node.js.<br \/>  \u042d\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043f\u0440\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <a href=\"http:\/\/www.jiiframework.ru\/\">Jii<\/a>, \u0432 <a href=\"http:\/\/habrahabr.ru\/post\/260295\/\">\u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u043b\u0438 \u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0434\u0430\u043d\u043d\u044b\u043c \u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 (Query Builder).<br \/>  \u041a\u0430\u043a \u0438 \u043e\u0431\u0435\u0449\u0430\u043b, \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 Active Record.<\/p>\n<h1>Active Record<\/h1>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/a0c\/e49\/a69\/a0ce49a699f74a138d2989ec37d5295e.jpg\" \/><\/div>\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-259572","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/259572","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=259572"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/259572\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=259572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=259572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=259572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}