doctrine

Doctrine: on persist: soft-delete only if object has changed

别等时光非礼了梦想. 提交于 2019-12-12 01:07:48
问题 In Doctrine/Symfony3, how would I best check whether a record is about to be changed in order to delete/create a new one instead of updating? Context: I'm loading a large price list csv into the database every time the supplier sends one. It is important that updated prices are not reflected in previously placed orders. Of course I could soft-delete all objects every time the list is uploaded, and create new ones, but that would make the database unnecessarily large and require unneccessary

Symfony 4: how to load DataFixtures in a KernelTestCase

℡╲_俬逩灬. 提交于 2019-12-12 00:48:00
问题 I got DataFixtures set up, that I can load via console into my test database. $ php bin/console doctrine:fixtures:load --env=test -n > purging database > loading App\DataFixtures\PropertyFixtures > loading App\DataFixtures\UserFixtures > loading App\DataFixtures\UserPropertyFixtures works like a chram But I am lost how to load these fixtures automatically with my service unit tests, without having to run the command manually before testing. There has to be another way! What I found so far is

Doctrine 2: Not all entities get persisted, why?

老子叫甜甜 提交于 2019-12-12 00:26:48
问题 I'm trying to persist Feedback entities in a loop. The problem is, that exactly 1 entity doesn't get persisted (no matter how many entities I want to persist at all; it's always n-1 instead of n). To understand the following code snippet you have to know that a survey entity can contain several feedback entities (1..n relation). Let's say if $feedbackCount = 10 then just 9 feedback entities get persisted into the database. At the end of this post you can also see the according doctrine unit

when flush() primary key does not get inserted

江枫思渺然 提交于 2019-12-11 23:16:31
问题 I am working on a PHP Project, utilizing Symfony 2, and Doctrine as ORM. When I persist and flush the object the primary key column is not even in the insert SQL DML Statement, and of course an error is thrown. The ID is a generated value, using PHP's uniqid. I will provide the Entity and a code snippet of the controller. /** * Metrics * * @ORM\Table(name="metrics", indexes={@ORM\Index(name="metrics_assignedTo_fk", columns={"assignedTo"}), @ORM\Index(name="metrics_ui_fk", columns={"ui"})}) *

Doctrine Query Builder Delete Statement

亡梦爱人 提交于 2019-12-11 22:12:07
问题 I am using Symfony2, i must use the Doctrine QueryBuilder ( http://docs.doctrine-project.org/en/latest/reference/query-builder.html ) The documentation does not have an example for the delete or update statement. My entity is : object(stdClass)[417] public '__CLASS__' => string 'Les\DataBundle\Entity\News' (length=26) public 'id' => int 1 public 'restoId' => int 1 public 'category' => string 'dessert' (length=7) public 'text' => string 'jlkdjsalkdj sa' (length=14) public 'dateCreated' =>

zend2 doctrine 2 form intgergration OneToOne

二次信任 提交于 2019-12-11 21:19:51
问题 I am trying to integrate Doctrine 2 to my Zend 2 . I wish to join two entities on my form; i.e ONeToOne. I followed the tutorial by gammamatrix. I was able to successfully integrate doctrine and was able to Hydrate one of the entities. The problem occurs when I try to join the second entity fieldset to the first entity. I keep getting the following fatal error message: **Catchable fatal error: Argument 1 passed to Workers\Form\Fieldset\WorkerAddressFieldset::__construct() must implement

Symfony Dependency Injection not triggering load function

一世执手 提交于 2019-12-11 21:18:43
问题 I'm trying out building my own CMS with the Symfony stack and I'm already in some issues with the Dependency Injection. What am I trying to do Load the 'Extension' of each module installed on the CMS, so services and doctrine settings can be merged. What I am doing Running Symfony Flex ( Symfony 4 ) I have in src/Kernel.php: ( in the configureContainer function) foreach ($this->getInstalledModules() as $module) { $class = 'App\\Modules\\' . $module . '\\DependencyInjection\\' . $module .

Check if UNIQUE row already exists using findBy in ManyToMany, any workaround or working solution?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 20:45:40
问题 So I've this relations defined in my entities: class Producto { /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Norma", inversedBy="normasProducto", cascade={"persist"}) * @ORM\JoinTable(name="nomencladores.norma_producto", schema="nomencladores", * joinColumns={@ORM\JoinColumn(name="producto_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="norma_id", referencedColumnName="id")} * ) */ protected $productoNormas; } class Norma { /** * @ORM\ManyToMany

Symfony2 filling all fields of table related to a Entity

懵懂的女人 提交于 2019-12-11 20:37:51
问题 I have a Entity of TeamMembers. And the TeamMember can have a Specification with a value. So I have three Entities: TeamMember, Specifications, SpecificationValues. In the SpecificationValue table I want to store the TeamMember_id, the Specification_id and the value that is just for that TeamMember. The Specifications and TeamMembers Entities are working. But now I want to show all the Specifications, if I go to the edit route (see code example) of a TeamMember, and have to possibility over

Doctrine Query Builder Bug?

泪湿孤枕 提交于 2019-12-11 19:51:23
问题 I have run into an issue in Doctrine. I have built the following query with queryBuilder $qb = $query = $this->repoLibrary->createQueryBuilder('l'); $query = $qb ->innerJoin('l.productVariant', 'v') ->innerJoin('v.product', 'p') ->innerJoin('p.taxons', 't', 'WITH', 't.id IN (:array)') ->where('l.user = :user') ->groupBy('l.id HAVING count(DISTINCT t.id) >= :count') ->setParameter('user', $user) ->setParameter('array', $s) ->setParameter('count', count($taxons)) ->getQuery(); Here is the query