Questions tagged [doctrine]

The Doctrine Project is a collection of open source libraries and tools for dealing with database abstraction and Object-Relational Mapping written in PHP.

The Doctrine Project is a collection of open source libraries and tools for dealing with database abstraction and Object-Relational Mapping written in PHP.


Doctrine 2

When we say Doctrine 2 it usually refers to Doctrine ORM Project. The ORM sits on top of the database abstraction layer (called DBAL). It also uses Doctrine Common (which provides extensions to core PHP functionality).

Side projects

Then you have side projects dedicated to some DBMS which provide transparent persistence for PHP objects:

Documentation

Useful links


Doctrine 1

The first version doesn't have a separate project for the relational mapper and the database abstraction layer. It requires PHP 5.2.3+ and the latest version is 1.2.5.

11930 questions
3
votes
4 answers

Symfony Profiler Query Stack Trace

I have a portal made with Symfony 3.4 and Sonata Admin. In a specific admin page there are a lot of generated queries. I used the profiler to track them down but I cannot see where they generated from: There is the same query repeated a lot of…
StockBreak
  • 2,857
  • 1
  • 35
  • 61
3
votes
2 answers

Symfony Many to Many does not update on both sides

I am creating an Asset Management Web App with Symfony 3.3. I have two entities, Asset and User. User: namespace AppBundle\Entity; use Doctrine\ORM\Mapping as ORM; use FOS\UserBundle\Model\User as BaseUser; /** * User * *…
Akira Hora
  • 458
  • 1
  • 6
  • 18
3
votes
2 answers

Symfony: Handling EntityNotFoundException on Doctrine relation

When I tried to display a related object in Twig, and that relation is not present because the ID is in the parent entity, but the related entity was not in the current database, Symfony throws a 500 error // EntityNotFoundException …
Geoff Maddock
  • 1,700
  • 3
  • 26
  • 47
3
votes
1 answer

how to overwrite existing entities in doctrine?

I am trying to run the command doctrine command for entities: ./vendor/bin/doctrine orm:convert-mapping --from-database annotation ./Models First time I run this command for generating entity mapping files then I modify the database table and…
flik
  • 3,433
  • 2
  • 20
  • 30
3
votes
1 answer

Doctrine event listener and softdeleted filter

I have entity answers and I use softdeleted filter for them, and when I remove entity in some action everything fine, I have deletedAt datetime, but when I try remove this entity in OnFlushEvent my entity is gone from DB, why ? public function…
shuba.ivan
  • 3,824
  • 8
  • 49
  • 121
3
votes
2 answers

Symfony 4 Doctrine relations , collections dont get datas

First of all, excuse my bad english. I'm using Symfony 4.0 with Doctrine-bridge 4.0. When using a OneToMany relation, the property remains empty. Context I'm trying to create a user entity and a bank account entity so that only account that…
Elie Lam
  • 33
  • 4
3
votes
1 answer

Symfony - SQLSTATE-23000 : Integrity constraint violation: 1022 Can't write duplicate key

I would like to use relations in my Doctrine Product, ProductType and Manufacturer entities, but when i do php bin/console doctrine:migrations:migrate I get this error : -> ALTER TABLE product ADD CONSTRAINT FK_D34A04ADA23B42D FOREIGN KEY…
blakyris
  • 161
  • 1
  • 8
3
votes
2 answers

How to get the discriminator type from repository

I am currently using a single table inheritence for one of my entities in doctrine. The header look like this: /** * Flux * * @ORM\InheritanceType("SINGLE_TABLE") * @ORM\DiscriminatorColumn(name="type", type="string") *…
Liora Haydont
  • 1,252
  • 1
  • 12
  • 25
3
votes
3 answers

Doctrine OneToOne always loaded on querybuilder

I have Partner entity with two relation: /** * @var PartnerSettings * @ORM\OneToOne(targetEntity="PartnerSettings", mappedBy="partner", cascade={"persist", "remove"}, fetch="LAZY") */ private $settings; /** * @var PartnerRating *…
Uni
  • 71
  • 1
  • 6
3
votes
1 answer

Symfony4 sqlite3 connection

I'm trying to play with Symfony4 and SQlite3. After: composer create-project symfony/website-skeleton my-project and something like LuckyNumber, I try to define DB-connection. in: config/packages/doctrine.yaml is: doctrine: dbal: #…
user8380069
3
votes
0 answers

Symfony4 - Working with db-test

I'm unfortunately stuck for few days on one thing.. In my symfony App, I have a 'symfony-db' for my dev and a 'symfony-db-test' which is intended for my tests. However, I don't know the best practice to do. I'm wondering about two ways to do it. I…
Piface
  • 43
  • 4
3
votes
1 answer

Inserting a json in doctrine doesn't work

I call a JSON API that sends me data back and I want to insert this JSON into my MariaDB database using Doctrine in Symfony. The JSON I retrieve is an array of objects, I followed several examples on the internet (Example: Doctrine array vs…
Valentin Harrang
  • 1,081
  • 2
  • 17
  • 34
3
votes
3 answers

Symfony 4 : Namespace issue when generating entities with doctrine

I'm currently using Symfony 4. I have written an entity with ORM and annotions #src/Entity/User.php
Salve Safari
  • 250
  • 1
  • 3
  • 10
3
votes
2 answers

Doctrine ORM: NULL to DateTime conversion error

I use PHP7, Symfony 2.8 andDoctrine ORM 2.5. I have an entity with a datetime field: /** @ORM\Column(name="data_ordine", type="datetime", nullable=true) */ private $dataOrdine; /** * @param mixed $dataOrdine */ public function…
marchiosim
  • 119
  • 1
  • 10
3
votes
2 answers

Doctrine findBy where and order

I have a snippet on symfony doctrine that picks data in descending order. Attempting to Apply a where clause some fields it equal to true is a problem. Below is my snippet $results = $this->getDoctrine()->getRepository('RealBundle:Foo')->findBy([],…
Sleek
  • 135
  • 2
  • 2
  • 9