doctrine

Submiting data in a ManyToMany relation

陌路散爱 提交于 2019-12-25 00:40:49
问题 I have 2 entities, Parking and Agent, each parking can have many Agents and each Agent can administer many parkings. After I created the relationship, Doctrine automatically added a join table called parking-Agent. Now I'm trying to populate that table through a form, like when creating a new Agent I can give him one or many parkings, or Vice-Versa. I tried adding a choicetype with multiple choices to the form but it didn't work. Can you guys help me ? Entity Agent: <?php /** * @ORM\Entity *

Symfony 1.4 makes 15 DB requests for 1 query [duplicate]

青春壹個敷衍的年華 提交于 2019-12-24 23:51:55
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: got a select that does 10 query in doctrine (Symfony) I currently have a big problem with my symfony app, I have a complexe sql query that makes too much connections the the database. The query order, search for keyword using doctrine searchable, and check the geo position. Here the complete model pasted and the sql log, anyone got an idea what I am doing wrong ? :/ public function getListItems($orderby, $budget

Doctrine cascade on OneToMany does not set the parent object?

…衆ロ難τιáo~ 提交于 2019-12-24 23:45:04
问题 I have a User objects which has many Journal entries. The user class contains a $userJournals property and the required add/remove functions, as below: class User{ .... /** * @var \Doctrine\Common\Collections\ArrayCollection * * @ORM\OneToMany(targetEntity="models\UserJournal", mappedBy="user", cascade={"persist"}) */ protected $userJournals; .... public function addUserJournal(\models\UserJournal $userJournal) { $this->userJournals->add($userJournal); return $this; } } The UserJournal class

Symfony Doctrine skeleton files

*爱你&永不变心* 提交于 2019-12-24 21:57:46
问题 I'm using Symfony 1.4 with the Doctrine 1.2 plugin. I would like to add some function to the Doctrine auto-generated models files (*Base.class.php). Thoses file are normally generated using "./symfony doctrine:build-model" command from the CLI. I know Symfony have a system of skeleton for every file generated from the CLI but I habe absolutely no idea how to modify specific Doctrine skeletons files. I've looked a the documentation but didn't find any hints. Is this even possible ? 回答1:

Symfony: how would you reverse the “notnull:true” in a schema of a plugin?

℡╲_俬逩灬. 提交于 2019-12-24 21:26:11
问题 sfGuardUser model of sfDoctrineGuardPlugin is defined this way: sfGuardUser: actAs: [Timestampable] columns: id: type: integer(4) primary: true autoincrement: true username: type: string(128) notnull: true unique: true As you can see 'username' has the feature "notnull:true". Now i want to create a register form that is not using 'username' but the email address of the user. When a user wants to register, it is showed this: Validation failed in class sfGuardUser 1 field had validation error:

Doctrine and symfony filter, debug the filter

旧时模样 提交于 2019-12-24 21:26:04
问题 So i have the following filter: class ClientFilter extends SQLFilter { public function addFilterConstraint(ClassMetadata $targetEntity, $targetTableAlias) { return $targetTableAlias.'client_id = '. $this->getParameter('client_id'); } } and in my controller: $em = $this->get('doctrine.orm.default_entity_manager'); $filter = $em->getFilters()->enable('client_filter'); var_dump($em->getFilters()->isEnabled('client_filter')); it prints out bool(true) which means it is enabled, but when i look

Symfony2 and Doctrine: how to use findOneBy method taking capitals into account

早过忘川 提交于 2019-12-24 19:59:17
问题 Using Symfony2, Doctrine and MySQL, I am using findOneBy method. I need it to take capitals into account when talking about string criteria fields. Example: imagine I have this path field in some table in my database. id path --------- 1 path1 2 path2 3 path3 4 path4 If I do findOneByPath("PATH2") it will find the second row. The question: how can I make it to distinguish capitals, so that it wouldn't find any row in the described case? 回答1: The issue is not a doctrine/symfony issue - the

Symfony 5.0: make:migration or doctrine:schema:update --force only creates id columns but not other fields defined in entity

不羁的心 提交于 2019-12-24 19:34:03
问题 Something very strange happened to my right now... I use the newest symfony CLI tool and created a project and an entity which has a field "name". When i update or migrate the schema, only the column "id" is generated. Symfony CLI version v4.11.2 (c) 2017-2019 Symfony SAS $ symfony new --full test $ cd test $ php bin/console doctrine:database:create $ php bin/console make:entity Test $ php bin/console make:migration $ php bin/console doctrine:migrations:migrate The created entity: <?php

Doctrine 2 - Outer join query

一笑奈何 提交于 2019-12-24 18:10:54
问题 In the context of the SonataAdminBundle / SonataUserBundle, I'm using the query builder to add static filters to the "list" query : With this query, I get only users in the group "Juge", the query works well : $query ->leftJoin( $query->getRootAlias().'.groups', 'g') ->andWhere( 'g.name = :group_name' ) ->setParameter('group_name', 'Juge'); In an other Admin class, i want to do the oposite of this query : get the users who ARE NOT in the "Juge" group . How can I perform this? There is not

How do you override a Constant in Doctrine's Models?

£可爱£侵袭症+ 提交于 2019-12-24 17:29:28
问题 In Doctrine you are provided with a Constant Variable that allows you to set a global Identifier column in all of the models that are generated by Doctrine's code. I am trying to figure out how I can override/shut off this value so that it does not create this column in a specific table. The Constant is: ATTR_DEFAULT_IDENTIFIER_OPTIONS It gets set in a bootstrapped PHP file and it automatically creates the appropriate table in your Database. Example Code: // set the default primary key to be