{"id":244,"date":"2017-03-04T08:33:53","date_gmt":"2017-03-04T05:33:53","guid":{"rendered":"https:\/\/zakirov.net\/blog\/?p=244"},"modified":"2017-03-30T19:07:39","modified_gmt":"2017-03-30T16:07:39","slug":"doctrine-tinyint","status":"publish","type":"post","link":"https:\/\/zakirov.net\/blog\/2017\/03\/04\/doctrine-tinyint\/","title":{"rendered":"Doctrine: \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0438\u043f tinyint"},"content":{"rendered":"<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a <a href=\"\/blog\/2017\/03\/04\/doctrine-json_array-unescaped\/\">\u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 json_array \u0432 Doctrine<\/a>. \u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043e\u0434\u043d\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 <strong>tinyint<\/strong>.<br \/>\n<!--more--><br \/>\n\u041d\u043e\u0432\u0438\u0447\u043a\u0438 \u0432 Doctrine, \u043f\u0440\u0438\u0432\u044b\u043a\u0448\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u0439 \u0442\u0438\u043f TINYINT \u0432 MySQL, \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u043c: \u043f\u043e\u0447\u0435\u043c\u0443 \u0435\u0433\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442? \u041e\u0442\u0432\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e\u0439: <strong>\u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439<\/strong>, \u0441\u0442\u0440\u0430\u0434\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u0438\u043f <strong>smallint<\/strong>, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0446\u043e\u0432, \u043e\u043d \u0432\u0441\u0435\u0433\u043e-\u0442\u043e \u043d\u0430 \u0431\u0430\u0439\u0442 \u0434\u043b\u0438\u043d\u043d\u0435\u0435.<\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0436\u0435 \u0432\u044b \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e MySQL \u0432 \u0432\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438 \u0432\u0430\u043c \u043f\u043e\u0437\u0430\u0440\u0435\u0437 \u043d\u0443\u0436\u0435\u043d \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0438\u043f tinyint, \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e <strong>\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u043a\u043e\u0440\u0443\u044e \u0440\u0443\u043a\u0443<\/strong>, \u044d\u0442\u0430\u043a\u0438\u0439 &#171;\u0433\u0440\u044f\u0437\u043d\u044b\u0439 \u0445\u0430\u043a&#187;: \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043d\u0430\u0434\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043d\u0430\u0434 \u0442\u0438\u043f\u043e\u043c smallint \u0438 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f SQL-\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u043b\u044f \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u043e\u0434\u043c\u0435\u043d\u0443 \u0442\u0438\u043f\u0430 SMALLINT \u043d\u0430 TINYINT. \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437, \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0432 Symfony.<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b <strong>src\/AppBundle\/Doctrine\/Types\/TinyIntType.php<\/strong> \u0441 \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre class=\"lang:php\">\r\nnamespace AppBundle\\Doctrine\\Types;\r\n\r\nuse Doctrine\\DBAL\\Types\\SmallIntType;\r\nuse Doctrine\\DBAL\\Platforms\\AbstractPlatform;\r\n\r\nclass TinyIntType extends SmallIntType\r\n{\r\n    const TINYINT = 'tinyint';\r\n\r\n    public function getName()\r\n    {\r\n        return self::TINYINT;\r\n    }\r\n\r\n    public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)\r\n    {\r\n        return str_replace(\r\n            'SMALLINT', \r\n            'TINYINT', \r\n            parent::getSQLDeclaration($fieldDeclaration, $platform)\r\n        );\r\n    }\r\n}\r\n<\/pre>\n<p>\u0418 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0448 \u043d\u043e\u0432\u044b\u0439 \u0442\u0438\u043f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e (<strong>app\/config\/config.yml<\/strong>):<\/p>\n<pre class=\"lang:yaml\">\r\ndoctrine:\r\n    dbal:\r\n        types:\r\n            tinyint: AppBundle\\Doctrine\\Types\\TinyIntType\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u043b, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0442\u0438\u043f\u0430 json_array \u0432 Doctrine. \u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 \u043e\u0434\u043d\u043e\u0431\u0430\u0439\u0442\u043e\u0432\u043e\u0433\u043e \u0442\u0438\u043f\u0430 tinyint.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19,22,3,20,12,9],"tags":[],"_links":{"self":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts\/244"}],"collection":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/comments?post=244"}],"version-history":[{"count":6,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":253,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/posts\/244\/revisions\/253"}],"wp:attachment":[{"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/media?parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/categories?post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zakirov.net\/blog\/wp-json\/wp\/v2\/tags?post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}