doctrine-orm

Embed a collection of forms - doctrine, symfony

与世无争的帅哥 提交于 2020-01-11 13:53:06
问题 I have two tables "RFQ" and "RFQitem". I can make form which can create RFQ with their title description and amount. And I can create RFQitem form which can create RFQitem with their title, description and amount. Problems starts when I need to upgrade my RFQ form, so that I can make in it RFQitems which will saves in their table, but it need to be assigned to RFQ. In symfony documentation is great example which actually works for me, but this is example is with task and their tags. So task

ZF2 + Doctrine2: Server has gone away - how to jog an old connection?

假如想象 提交于 2020-01-11 07:10:07
问题 Thanks in advance for your help. I'm wondering if anyone quickly knows what functions to call on the Entity Repository to jog its reconnection if it is dead. I am running some jobs that can take a length of time that exceeds wait_timeout through a ZF2 CLI route, and unfortunately, the ER's connection dies by the time it needs to get used (when the job is done). Need: // do the long job $sl = $this->getServiceLocator(); $mapper = $sl->get( 'doctrine_object_mapper' ); if( !$mapper-

How can I order by NULL in DQL?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-10 20:04:29
问题 I'm building an app using Symfony2 framework and using Doctrine ORM. I have a table with airlines for which some IATA codes are missing. I'm outputting a list, ordered by this IATA code, but I'm getting the undesirable result that the records with null IATA codes are sorted at the top. In MySQL this is simple enough to do, with ORDER BY ISNULL(code_iata), code_iata but I'm clueless as to what the equivalent would be for DQL. I tried $er->createQueryBuilder('airline')->orderBy('ISNULL(airline

Symfony2 Doctrine2 Many To Many Form not Saving Entities

大城市里の小女人 提交于 2020-01-10 11:58:15
问题 I am having some trouble with a many to many relationship. I have Users and Assets . I would like to be able to assign users to an asset on the asset page. The code below displays a list of users when creating/editing an asset, however changes made to the user checkboxes do not save, while the rest of the data is persisted. If I add an entry to users_assets through the mysql client, these changes are shown in the asset list. User class User extends BaseUser { /** * @ORM\ManyToMany

Symfony2 Doctrine2 Many To Many Form not Saving Entities

只愿长相守 提交于 2020-01-10 11:57:12
问题 I am having some trouble with a many to many relationship. I have Users and Assets . I would like to be able to assign users to an asset on the asset page. The code below displays a list of users when creating/editing an asset, however changes made to the user checkboxes do not save, while the rest of the data is persisted. If I add an entry to users_assets through the mysql client, these changes are shown in the asset list. User class User extends BaseUser { /** * @ORM\ManyToMany

How to get an id without join in doctrine2?

霸气de小男生 提交于 2020-01-10 09:45:27
问题 I have entity like this: /** * * @Table(name="table") * @Entity */ class Table { /** * @Column(type="integer") * @Id * @GeneratedValue(strategy="IDENTITY") */ private $id; /** * @ManyToOne(targetEntity="Entities\Users") * @joinColumn(name="userId", referencedColumnName="id") */ private $User; /** * @Column(type="string") */ private $text; } If i do $q->getQuery()->getSingleResult()->getUser()->getUserId() doctrine generate query like: SELECT * FROM table t INNER JOIN users u ON u.id = t

How to get an id without join in doctrine2?

江枫思渺然 提交于 2020-01-10 09:44:02
问题 I have entity like this: /** * * @Table(name="table") * @Entity */ class Table { /** * @Column(type="integer") * @Id * @GeneratedValue(strategy="IDENTITY") */ private $id; /** * @ManyToOne(targetEntity="Entities\Users") * @joinColumn(name="userId", referencedColumnName="id") */ private $User; /** * @Column(type="string") */ private $text; } If i do $q->getQuery()->getSingleResult()->getUser()->getUserId() doctrine generate query like: SELECT * FROM table t INNER JOIN users u ON u.id = t

symfony2: setting the value of a form field outside the form, inside a controller action

蹲街弑〆低调 提交于 2020-01-10 08:59:13
问题 I need to set the value of a symfony2 form element. I use a doctrine2 entity, a Symfony\Component\Form\AbstractType and the createForm() method inside my Controllers Action. $saleDataForm = $this->createForm(new SaleType(), $sale); Now, how do i get an element from that form, and how can i set it's value? I want to do something like this, but it doesn't work: $saleDataForm->get('image')->setValue('someimapge.jpg'); FYI: I need to do this to render the field correctly (using this approach, my

Unknown Entity namespace alias in symfony2

好久不见. 提交于 2020-01-10 08:53:48
问题 Hey I have two bundles in my symfony2 project. one is Bundle and the other one is PatentBundle. My app/config/route.yml file is MunichInnovationGroupPatentBundle: resource: "@MunichInnovationGroupPatentBundle/Controller/" type: annotation prefix: / defaults: { _controller: "MunichInnovationGroupPatentBundle:Default:index" } MunichInnovationGroupBundle: resource: "@MunichInnovationGroupBundle/Controller/" type: annotation prefix: /v1 defaults: { _controller: "MunichInnovationGroupBundle:Patent

Symfony 2 authentication with (doctrine) Entity

三世轮回 提交于 2020-01-09 21:34:26
问题 I think I've tried all code in all posts about authentication with (doctrine) Entity in Symfony 2. And I can`t make it work. When I use in_memory provider all works fine. I'm using the PR8. My security.yml security: encoders: Partners\FrontendBundle\Entity\User: plaintext Symfony\Component\Security\Core\User\User: plaintext providers: main: entity: { class: FrontendBundle:User, property: username } # in_memory: # users: # sergi: { password: boo123, roles: [ 'ROLE_USER' ] } firewalls: main: