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

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

  1. <tfoot id='jGVyw'></tfoot>

  2. <legend id='jGVyw'><style id='jGVyw'><dir id='jGVyw'><q id='jGVyw'></q></dir></style></legend>
        <bdo id='jGVyw'></bdo><ul id='jGVyw'></ul>
    1. 教义映射字段不起作用

      时间:2024-08-15
      • <bdo id='Zzuba'></bdo><ul id='Zzuba'></ul>
        • <tfoot id='Zzuba'></tfoot>
            <tbody id='Zzuba'></tbody>
          <legend id='Zzuba'><style id='Zzuba'><dir id='Zzuba'><q id='Zzuba'></q></dir></style></legend>

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

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

                本文介绍了教义映射字段不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有两个实体 UserUserMiscNotification 并且我希望有可能通过执行 在 User 实体中获取用户的通知$user->getNotifications().通常我对这种类型的关系没有问题.

                I have two entities UserUser and MiscNotification and I want to have the possibility to fetch the user's notifications inside the User entity, by doing $user->getNotifications(). Usually I have no problem with this type of relations.

                请参阅下面的代码(我只是添加了 TicketApp 关系作为示例,因为该关系有效并且完全相同):

                See my code below (I just added the TicketApp relation as an example, since this relation works and is exactly the same):

                /**
                 * This is working
                 * @ORMOneToMany(targetEntity="[...]EntityTicketTicketApp", mappedBy="author")
                 */
                private $tickets;
                
                /**
                 * This is not
                 * @ORMOneToMany(targetEntity="[...]EntityMiscNotification", mappedBy="receiver", fetch="EXTRA_LAZY")
                 */
                private $notifications;
                

                用户用户:__construct()

                $this->tickets       = new DoctrineCommonCollectionsArrayCollection();
                $this->notifications = new DoctrineCommonCollectionsArrayCollection();
                

                杂项通知:属性

                /**
                 * @ORMManyToOne(targetEntity="[...]EntityUserUser", inversedBy="notifications")
                 * @ORMJoinColumn(nullable=false)
                 */
                private $receiver;
                

                <小时>

                这似乎没问题(或者今晚我完全失明了......).问题是: $user->getNotifications() 返回 null 而不是 Doctrine Collection 对象.我的表中有数据.这种类型的代码有效并返回两个通知:


                This seems to be Ok (or maybe this evening I'm completely blind...). The problem is : $user->getNotifications() returns null instead of a Doctrine Collection object. I have datas in my table. This type of code works and returns two notifications:

                $em->getRepository('[...]:MiscNotification')->findByReceiver($user);
                

                另外,我注意到在 Symfony 调试工具栏中,使用 $user->getNotifications()不会触发任何查询.

                Also, I noticed in the Symfony debug toolbar that no query is fired when using $user->getNotifications().

                推荐答案

                当我想起 Doctrine 有独立于 Symfony 的适当缓存(我尝试了数十个 cache:clear没有任何变化).我认为我的问题可能是 Doctrine 缓存问题,所以我尝试清除缓存:

                I was despairing of finding a solution when I remembered that Doctrine have its proper cache, independent from Symfony (I tried tens of cache:clear without any change). I thought that my problem could be a Doctrine cache issue, so I tried to clear the cache:

                app/console doctrine:cache:clear-metadata
                

                (如果你使用 Doctrine 独立,这个命令在纯 Doctrine 中是等效的,Symfony 只是重命名和改进 Doctrine 命令).

                (If you are using Doctrine standalone, this command has its equivalent in pure Doctrine, Symfony just renames and improves Doctrine commands).

                如果您有正常安装,这应该可以工作,否则请继续阅读.

                If you have a normal installation, this should work, otherwise continue to read.

                在正常情况下,至少在开发模式下,Doctrine 会在每次请求时重新生成元数据缓存.但是Doctrine还有一个APC接口来存储它的缓存……我两三个星期前激活了它,我已经完全忘记了.当我运行上面的命令时,Doctrine 说:

                In a normal time, in dev mode at least, Doctrine regenerates the metadata cache at each request. But Doctrine also have an APC interface to store its cache... I activated it two or three weeks ago, and I have completely forgotten it. When I ran the command above, Doctrine said:

                Cannot clear APC Cache from Console, its shared in the Webserver memory and not accessible from the CLI.
                

                问题现在很清楚了.Doctrine 填充了缓存,然后无法正确删除数据.getNotifications 方法返回 null 因为它是纯 PHP,但 Doctrine 不知道 notifications 属性是 SQL 映射的.所以该字段从未被初始化.如果您使用其他缓存器,这可能是类似的问题.

                The problem is clear now. Doctrine fills the cache and then can't remove data correctly. The getNotifications method was returning null because it was pure PHP, but Doctrine had no knowledge that the notifications property was SQL-mapped. So the field were never initialized. If you use another cacher, that's probably a similar issue.

                上面给出的错误是不言自明的.您需要清除 APC 数据存储.由于它是由网络服务器进程托管的,只需重启这个人:

                The error given above is self-explaining. You'll need to clear the APC datastore. Since it is hosted by the webserver process, just reboot this guy:

                sudo service apache2 restart
                

                阿门.

                这篇关于教义映射字段不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                    <tbody id='iRs74'></tbody>

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

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

                        <tfoot id='iRs74'></tfoot>