doctrine

Why is DoctrineExtensions Blameable eagerly fetching all created_by users

浪子不回头ぞ 提交于 2019-12-11 13:28:52
问题 When using the following trait in my user class /** * @var User * * @Gedmo\Blameable(on="create") * @ORM\ManyToOne(targetEntity="User") */ protected $createdBy; /** * @var User * * @Gedmo\Blameable(on="update") * @ORM\ManyToOne(targetEntity="User") */ protected $updatedBy; Whenever i query a user the createdBy user is also fetched and this goes on recursively.. So if user C that was created by B, that was created by A is queried. All three users will be fetched... Is there a way to disable

Symfony 1.4 Doctrine 1 Yaml, cannot define default Timestamp value

安稳与你 提交于 2019-12-11 13:11:04
问题 I have been trying to set TIMESTAMP DEFAULT CURRENT_TIMESTAMP default values for the table columns created_at and updated_at in my schema.yml as explained in this post. System Info: Symfony 1.4.17 , Doctrine 1 MySQL 5.6.10 PHP 5.4 Carefully read the columnDefinition documentation but couldnt get it to work. As stated in the documentation, columnDefinition attribute should be set after the name of the column. After making a migration of the database, the default values set in columnDefinition

How to save additional entity while persisting another in Doctrine?

这一生的挚爱 提交于 2019-12-11 13:10:33
问题 I've got a Place entity and a Distance one, like so: class Place { /** @ORM\Id @ORM\Column(type="integer") @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** @ORM\Column(type="string", length=62, nullable=false) */ private $name; /** @ORM\OneToMany(targetEntity="Distance", mappedBy="origin") */ protected $distancesTo; /** @ORM\OneToMany(targetEntity="Distance", mappedBy="destination") */ protected $distancesFrom; } class Distance { /** @ORM\Id @ORM\Column(type="integer") @ORM

Doctrine 2 Bulk insert with relation

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 13:01:47
问题 I am trying to do some Bulk inserts into my database. I have read the article about it on the doctrine side and wanted to use sporadic flushs and clears in order to prevent high memory consumptions. Unfortunately all entities get detached in the process, not only the ones I am inserting, but also the relations to it. I tried to remerge them or use references instead. In my current case I am using a reference and still I get the following error message: [Doctrine\ORM

How to add a registration form another field Symfony 2.7 in FOSUserBundle

爷,独闯天下 提交于 2019-12-11 12:46:33
问题 How to add a field on the registration form ? I do so: \\src\UserBundle\Form\Type\RegistrationFormType.php <?php namespace UserBundle\Form\Type; //use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use FOS\UserBundle\Form\Type\RegistrationFormType as BaseType; class RegistrationFormType extends BaseType { public function buildForm(FormBuilderInterface $builder, array $options) { parent::buildForm($builder, $options); $builder->add('realname'); } public

foreign-key relationship with Doctrine concrete inheritance

蓝咒 提交于 2019-12-11 12:35:56
问题 In my schema, I have a generic table Animal and an inherited table Dog . Before using doctrine, I used to implement this pattern with an inherited id referencing the generic id as foreign key. I can't reproduce the same with Doctrine, and I feel like something is missing. The schema I used to produce is the following : CREATE TABLE `animal` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `color` VARCHAR(20) NOT NULL, PRIMARY KEY (`id`) ); CREATE TABLE `dog` ( `id` INT UNSIGNED NOT NULL, `breed`

Doctrine2 cannot make '2' one-to-many relations

旧城冷巷雨未停 提交于 2019-12-11 12:25:57
问题 I'm trying to make 3 entities (Item, Agree, Disagree) with following relations. Item one-to-many Agree Item one-to-many Disagree But only one relation (declared later) out of two has made. Here're my .yml files. Entities\Item: type: entity fields: id: type: integer id: true generator: strategy: AUTO oneToMany: agrees: targetEntity: Agree mappedBy: items oneToMany: disagrees: targetEntity: Disagree mappedBy: items Entities\Agree: type: entity fields: id: type: integer id: true generator:

Left join with Pagerfanta Doctrine

南楼画角 提交于 2019-12-11 11:28:18
问题 I'd like show results of two tables but I have this Exception: "Cannot count query which selects two FROM components, cannot make distinction". My query is: $queryBuilder = $em->createQueryBuilder() ->select('e, e.id AS id, e.f14010101 AS f14010101, e.f14010105 AS f14010105') ->from('T140101Bundle\Entity\T140101', 'e') ->leftJoin('T140102Bundle\Entity\T140102', 'c', 'WITH', 'c.f14010201= e.id') ->groupBy('e.id'); Can you help me? 来源: https://stackoverflow.com/questions/14030475/left-join-with

How to set the table collation to utf_general_ci using doctrine2

你。 提交于 2019-12-11 11:15:52
问题 Today I got the following error in an application which uses doctrine2 Message: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_unicode_ci,COERCIBLE) for operation 'like' I checked with phpmyadmin that the collation of the table is latin1_swedish_ci. Within my application I configured doctrine to use utf8 $em->getEventManager()->addEventSubscriber(new \Doctrine\DBAL\Event\Listeners\MysqlSessionInit('utf8', 'utf8_unicode_ci')); My database

Removing table headers from embedRelation()

半世苍凉 提交于 2019-12-11 11:07:22
问题 I have used the embedRelation() to pull another form into the sfGuard user form. It is working correctly, I am just trying to style it to fit into the current form. This pulls the form in: $this->embedRelation('Profile'); but it is adding some extra html elements that I would like to remove: <div class="form_row"> Profile <table> <tbody><tr> <th><label for="sf_guard_user_Profile_department_title">Department</label></th> <td><input type="text" name="sf_guard_user[Profile][department_title]"