<i id='l6RWj'><tr id='l6RWj'><dt id='l6RWj'><q id='l6RWj'><span id='l6RWj'><b id='l6RWj'><form id='l6RWj'><ins id='l6RWj'></ins><ul id='l6RWj'></ul><sub id='l6RWj'></sub></form><legend id='l6RWj'></legend><bdo id='l6RWj'><pre id='l6RWj'><center id='l6RWj'></center></pre></bdo></b><th id='l6RWj'></th></span></q></dt></tr></i><div id='l6RWj'><tfoot id='l6RWj'></tfoot><dl id='l6RWj'><fieldset id='l6RWj'></fieldset></dl></div>
      <tfoot id='l6RWj'></tfoot>

        <bdo id='l6RWj'></bdo><ul id='l6RWj'></ul>
    1. <small id='l6RWj'></small><noframes id='l6RWj'>

        <legend id='l6RWj'><style id='l6RWj'><dir id='l6RWj'><q id='l6RWj'></q></dir></style></legend>
      1. Symfony2 YAML 实体字段未绑定

        时间:2024-08-09

        • <bdo id='Q8tzX'></bdo><ul id='Q8tzX'></ul>

            <small id='Q8tzX'></small><noframes id='Q8tzX'>

              <legend id='Q8tzX'><style id='Q8tzX'><dir id='Q8tzX'><q id='Q8tzX'></q></dir></style></legend>
            • <i id='Q8tzX'><tr id='Q8tzX'><dt id='Q8tzX'><q id='Q8tzX'><span id='Q8tzX'><b id='Q8tzX'><form id='Q8tzX'><ins id='Q8tzX'></ins><ul id='Q8tzX'></ul><sub id='Q8tzX'></sub></form><legend id='Q8tzX'></legend><bdo id='Q8tzX'><pre id='Q8tzX'><center id='Q8tzX'></center></pre></bdo></b><th id='Q8tzX'></th></span></q></dt></tr></i><div id='Q8tzX'><tfoot id='Q8tzX'></tfoot><dl id='Q8tzX'><fieldset id='Q8tzX'></fieldset></dl></div>
                <tbody id='Q8tzX'></tbody>

                • <tfoot id='Q8tzX'></tfoot>

                  本文介绍了Symfony2 YAML 实体字段未绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个关于 Symfony2 的项目.我应该说我不认为自己是 Symfony2 的大师.你可以说我是新手.

                  I have a project on Symfony2. I should say that I don't consider myself a master of Symfony2 in any way. You could say I'm a newbie.

                  我的实体通过 YAML 绑定到数据库,并且在 php 中创建了一个不受注释绑定的实体类.

                  My entities are bound via YAML to database and an Entity class is created in php not bound by annotations.

                  我有一个这样的实体:

                  Project/CoreBundle/Resources/config/doctrine/Card.orm.yml
                  
                  Project/CoreBundle/Entity/Card.php
                  

                  卡片 - 是一个仪表板元素,可以拖动以方便用户.

                  Card - is a dashboard element, that can be dragged around for user's convenience.

                  对应的 Card.orm.yml 和 Card.php 具有对应于 db 中的表的结构.我创建了这段代码并且运行良好.

                  The corresponding Card.orm.yml and Card.php have structure that correspond to table in db. I created this piece of code and worked fine.

                  问题:现在我尝试向表、orm 和实体添加更多字段,但 Symfony2/Doctrine2 查询没有选择它们(我在调试器中查找过它,甚至在查询中都没有找到新字段是已选中).

                  The Problem: now that I try to add more fields to table, to orm and Entity, they are not being selected by Symfony2/Doctrine2 query (I've looked it up in debugger and not even in query the new field is SELECTed).

                  更重要的是,我尝试添加任何字段并且它不会被绑定.在检索到的对象中,它始终为 NULL.我查看了这个实体的映射,这个字段正在映射.但是在选择查询中,它又不存在.我使用了清晰的缓存机制等 - 没有用.我已经从 orm 和实体中删除了其他字段 - Doctrine2 会引发异常,但是当我删除此字段(它仍然存在于表中)并且工作相同时,只返回 null.

                  More so, I try to add any field and it doesn't become bound. In retrieved object it is always NULL. I've looked up MAPPING of this entity and this field is BEING MAPPED. But in select query, again, it is not present. I've used clear caching mechanisms and such - didn’t work. I've deleted OTHER fields from orm and entity - Doctrine2 throws exceptions, though when I remove this field (it still being present in table) and works the same, just returns null.

                  这是有效的:

                  $queryBuilder
                          ->select(array('card','card.isSpecialCard'))
                  

                  isSpecialCard"字段是未绑定选择的字段,因此我必须从表中自定义选择它,然后通过选择加载它.此外,它被加载到另一个级别的数组中,在卡片对象旁边而不是在对象中,尽管该对象仍然具有该字段并且它具有就像它被选中一样的值.

                  The "isSpecialCard" field is the one that's not being bound to select, so I have to custom-select it out of table and THEN it's loaded via select. Also, it's being loaded in another level of array, NEXT TO THE OBJECT OF CARD not IN THE OBJECT, though the object still has that field AND IT HAS VALUE AS IF IT WAS SELECTED.

                  我正在使用 Symfony 2.1.

                  I am using Symfony 2.1.

                  推荐答案

                  您不应该手动进行更改,而是让 ORM 驱动程序为您完成.使用这两个命令相应地更新实体和您的数据库:

                  You should not make the changes manually, but let the ORM driver do them for you. Use these two commands to update the Entity and your database accordingly:

                  php app/console doctrine:generate:entities Namespace:Card
                  php app/console doctrine:schema:update --force
                  

                  这篇关于Symfony2 YAML 实体字段未绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Doctrine 中的额外 changeColumns generate-migrations-diff 下一篇:学说:扩展实体类

                  相关文章

                • <legend id='8ygzh'><style id='8ygzh'><dir id='8ygzh'><q id='8ygzh'></q></dir></style></legend>
                    <bdo id='8ygzh'></bdo><ul id='8ygzh'></ul>

                  <i id='8ygzh'><tr id='8ygzh'><dt id='8ygzh'><q id='8ygzh'><span id='8ygzh'><b id='8ygzh'><form id='8ygzh'><ins id='8ygzh'></ins><ul id='8ygzh'></ul><sub id='8ygzh'></sub></form><legend id='8ygzh'></legend><bdo id='8ygzh'><pre id='8ygzh'><center id='8ygzh'></center></pre></bdo></b><th id='8ygzh'></th></span></q></dt></tr></i><div id='8ygzh'><tfoot id='8ygzh'></tfoot><dl id='8ygzh'><fieldset id='8ygzh'></fieldset></dl></div>
                • <tfoot id='8ygzh'></tfoot>

                      <small id='8ygzh'></small><noframes id='8ygzh'>