1

I have a entity called Venues and other called Users. Each Venue has one field called User which is the owner of the venue and is one of the users. On the other side each User has a Venue field, including the original venue where he signed up. So I'm trying to sort out what's the proper yml config.

On the venue.orm.yml file I have

manyToOne:
    user:
        targetEntity: Users
        joinColumns:
                  User:
                    referencedColumnName: ID
        inverseJoinColumns:
                  ID:
                    referencedColumnName: User
        orphanRemoval: false

And on the users.orm.yml I got:

manyToOne:
    venue:
        targetEntity: Venues
        joinColumns:
                  Venue:
                    referencedColumnName: ID
        inverseJoinColumns:
                  ID:
                    referencedColumnName: Venue
        orphanRemoval: false

The app fails silently, stopping the rendering of the view, just when form_start(form). I'm not able to see the web profiler (as usual) although I'm on dev mode. If I remove the field User from venue, then the render will be ok. Please let me know what I'm missing since I can't find a proper example under doctrine or symfony docs, and I think that I'm misunderstanding this link http://mnapoli.fr/doctrine-2-yaml-reference/ Thanks in advance ;)

EDIT The cause of the failure was a Memory Exhaust type error so this issue was at first provisionally solved by increasing the php.ini memory limit to 220MB,but as I need to set it back to 64MB limit, I found that by explicitly declaring all the types and entity options of my formType, the memory overhead was dramatically reduced. In addition I have limited the total options available at some selects, using query builder in the formType. Anyway I'll look forward for any additional action oriented to the memory saving. I'm going to google for any select options lazyloader Symfony component...

Arco Voltaico
  • 860
  • 13
  • 29

2 Answers2

1
manyToOne:
    user: <-- CLASS MEMBER NAME
    targetEntity: Users
        joinColumns:
            user: <-- DATABASE COLUMN NAME
                referencedColumnName: id <-- DATABASE COLUMN NAME

Be sure that you haven't misplaced class member name for database column name.

Also, your original YAML seems to be a bit more complicated that it should be. As far as I know, joinColumns and inverseJoinColumns should be used together only in case of joined tabled (@ManyToMany) which is clearly not your case.

The fact that it fails so silently points to some severe error, although I cannot be even guess why it does not log it.

EDIT (long shot really):

Do you, by any chance, have xdebug enabled? I've just remembered having some problems with recursion level limit within xdebug and php terminating silently.

If you do, see this question on how to increase it: Increasing nesting function calls limit

Community
  • 1
  • 1
Jovan Perovic
  • 19,846
  • 5
  • 44
  • 85
  • Tried this before, using user: targetEntity: Users joinColumns: User: referencedColumnName: ID But still the result is a half-rendered view Btw thanks for the helping – Arco Voltaico May 26 '14 at 15:30
  • Of course, after any change at orm I'm running the db update command succesfully – Arco Voltaico May 26 '14 at 15:32
  • Nice, I'm trying. I have news too.. from dev log [2014-05-26 17:51:56] emergency.EMERGENCY: Allowed memory size of 33554432 bytes exhausted (tried to allocate 107 bytes) Same kind of msg I'm getting when trying to exec clear cache command. So I'm forced to clear manually the cache folder... – Arco Voltaico May 26 '14 at 15:54
  • Yes, I have XDebug enabled ... I think so. I have also checked the datetime issue I got on a twig version, https://github.com/fabpot/Twig/issues/1241 but this not the case... – Arco Voltaico May 26 '14 at 15:56
  • I have just change my php.ini memory_limit from 32M to 64M... I'm afraid is not a right solution... and I'd need to optimize doctrine settings... What do you think? – Arco Voltaico May 26 '14 at 16:03
  • What it's still strange is getting a similar memory overload while trying to clear cache... – Arco Voltaico May 26 '14 at 16:05
  • Should I try to change my doctrine/symfony settings or should I go to increase my php memory limit? The last approach could work on dev but I think that it's not suitable for prod. – Arco Voltaico May 26 '14 at 16:25
  • Hm... are you making changes to the right `php.ini`? Some distros have one for command line and one for browser. I've just checked one of my production boxes and it while its memory is set to 128M it performs flawlessly – Jovan Perovic May 26 '14 at 17:03
  • I'm on OSX MAMP-File-Edit template-PHP-php.ini. Restart and ok, no problem if I raise the limit. As a better solution I explicit declare every type and entity options on the form "adds" reducing dramatically the use of memory. Anyway, I'm forced to rely on a 64MB limit, and I don´t know if it's optimized enough. – Arco Voltaico May 27 '14 at 08:24
  • Any decent hosting provider supplies you with at least `256M` (don't know about free hostings, though), sooo, you should be fine :) – Jovan Perovic May 27 '14 at 08:27
  • I'm at servergrove (developer plan), I'm really glad with them, and the phpinfo() shows 64MB limit. – Arco Voltaico May 27 '14 at 09:17
0

use mappedBy on the inverse side and inversedBy on the owning side.

venue.orm.yml

manyToOne:
    user:
        targetEntity: Users
        joinColumns:
                  User:
                      referencedColumnName: ID
        inversedBy:venue
        orphanRemoval: false

users.orm.yml

oneToMany:
    venue:
        targetEntity: Venues
        joinColumns:
                  Venue:
                      referencedColumnName: ID
        mappedBy: user
        orphanRemoval: false

Be careful:

joinColumns:
    X:
       referencedColumnName: Y

X and Y are sql table fields, X field of Entity field, Y referenced entity field.

Regards

Jean-Luc Barat
  • 1,147
  • 10
  • 18