doctrine

Joining-Table with Metadata Impairs Getters/Setters - Doctrine 2

我的梦境 提交于 2019-12-25 09:00:24
问题 I'm writing a feature which calls for the records of my joining table to carry extra metadata ( Joining-Table with Metadata ). I've attempted to implement this in accordance with this section of the Doctrine documentation. See below for example Entity definitions. The challenge now is that getGroups and setGroups do not yield/set Group entities (& the same is true from the Group instance perspective), but they yield GroupUser entities. This adds a substantial delay to process of managing this

FOSUserBundle Unique Entity constraints

匆匆过客 提交于 2019-12-25 08:34:53
问题 I want to set up a unique constraint on the fields "username" and "email" but it doesn't work : use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use FOS\UserBundle\Model\User as BaseUser; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * @ORM\Table(name="acteurs") * @ORM\Entity(repositoryClass="UserBundle\Repository\ActeurRepository") * @ORM\InheritanceType("JOINED") * @UniqueEntity(fields="email", message="Cet email existe déjà.") *

Doctrine: Value of mappedBy ignored in OneToMany Association

被刻印的时光 ゝ 提交于 2019-12-25 08:26:04
问题 I set up a simple User->Comment association in Doctrine, simple OneToMany (One User can write many Comments). All works find, but i found a strange behavior of Doctrine. First some Code: User Entity /** * @ORM\Entity * @ORM\Table(name="users") */ class User extends EntityAbstract { /** * @var int * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue */ protected $_id; /** * @var \Doctrine\Common\Collections\Collection * @ORM\OneToMany(targetEntity="Comment", mappedBy=

Doctrine: can't removeElement from inverse side of the relation

亡梦爱人 提交于 2019-12-25 08:05:00
问题 I have a ManyToMany relation (an offer can have many banners, and a banner can belong to many offers). I don't understand why this works: $banner->getOffers()->removeElement($this->offer); But this doesn't: $this->offer->getBanners()->removeElement($banner); These are my entities: Class Banner { /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Offer", inversedBy="banners") */ private $offers; public function __construct() { $this->offers = new ArrayCollection(); } public function

How to handle huge select query with symfony and doctrine?

廉价感情. 提交于 2019-12-25 07:49:46
问题 For example, i have playlist of 5000-10000 videos, what is the best way to select and show those videos in list. Pager is not an option, I need to have all of them becouse sorting and other functionalities? I thinking about solution to load list while scrolling the playlist, but this make me another problem, if i dont have all videos loaded, i can not properly save playlist. All suggestions/proposals are welcome... 回答1: use a dynamic pagination i.e, dont bring every thing to the frontend,

Symfony config component and Doctrine dbal

喜欢而已 提交于 2019-12-25 07:46:54
问题 Via composer i installed doctrine dbal and symfony2 config component "require":{ "symfony/dependency-injection": "2.4.*", "symfony/filesystem": "2.4.*", "symfony/config": "2.4.*", "doctrine/dbal": "2.3.4" } I autoload them via require_once __DIR__ . '/vendor/autoload.php' Then code goes like this use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/app/config/')); $loader->load(

Symfony/Doctrine: “Soft update” if a certain field has changed

流过昼夜 提交于 2019-12-25 07:38:30
问题 I know you can soft delete in Doctrine (i.e. do not delete a record but rather add a "deleted" value). There's an extension for that. Now I wonder if there's a way to "soft update" a record. I mean not actually update the record but rather create a new record and make the old one invalid. In the same extension as soft-delete, there's a function loggable , but this one logs to a different table. I could create a controller that, instead of updating, soft-deletes (and thus invalidates) the old

Single id is not allowed on composite primary key in entity using knp paginator

若如初见. 提交于 2019-12-25 07:25:09
问题 I have a question about knp paginator. I use Symfony 2.8. I made a table that has composite primary key, and corresponding list page using knp paginator. I'm receiving the exception when I try to show. "Single id is not allowed on composite primary key in entity" I tried to inspect source files of knp paginator and doctrine. So I found a workaround. 1)Set knp option "distinct" to false; 2)Set following hints to query. set "knp_paginator.count" to rows count of query result. set "knp_paginator

How to determine order of colums in table?

一笑奈何 提交于 2019-12-25 06:57:56
问题 I defined an Symfony2 entity class and I want to create the corresponding table in my database. This works fine thanks to the command 'php app/console doctrine:schema:update --force'. But the order of the columns isn't equal to the order in my class. Any way to get them in the same order? 来源: https://stackoverflow.com/questions/27283284/how-to-determine-order-of-colums-in-table

Symfony2 Doctrine Schema Update from Directory and Subdirectories

拜拜、爱过 提交于 2019-12-25 05:31:58
问题 I have one product for many customers but I want to have one code base. Every customer needs some specific changes in database(entities repos) and in his own themes. Every customer has his own database. I need to find a solution to define in configuration for every customer witch entities must be read to create or update his own database schema. In my bundles i have this structure in Entities Acme\JobBundle\Entities\Customer.php Acme\JobBundle\Entities\Customer1\Customer.php Acme\JobBundle