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
30
votes
3 answers

Undefined index on doctrine m:n relation

I have a 'department' and 'newsItem', which are related m:n. Whenever I try to enumerate over a department's newsItems, thus triggering retrieval from the db, I get this error: at ErrorHandler ->handle ( '8', 'Undefined index: newsItems', …
Jan
  • 6,532
  • 9
  • 37
  • 48
30
votes
7 answers

Generating Entity Getters and Setters in Symfony / Doctrine ORM

I have the following ORM Symfony entity with only properties :
SmootQ
  • 2,096
  • 7
  • 33
  • 58
30
votes
4 answers

How can I load fixtures from functional test in Symfony 2

My DoctrineFixturesBundle is installed and I can load fixture trough the command-line but , how can I load fixtures from my functional test ?
Ousmane
  • 2,673
  • 3
  • 30
  • 37
29
votes
4 answers

Doctrine 2: Call to a member function format() on a non-object ... in DateTimeType.php

I have a DateTime field: /** * Date time posted * @Column(type="datetime") */ private $dtPosted; which is set to a default value by using a LifeCycleCallback /** * @PrePersist */ function onPrePersist() { // set default date …
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
29
votes
7 answers

Memory leak when executing Doctrine query in loop

I'm having trouble in locating the cause for a memory leak in my script. I have a simple repository method which increments a 'count' column in my entity by X amount: public function incrementCount($id, $amount) { $query = $this …
Jonathan
  • 13,947
  • 17
  • 94
  • 123
29
votes
4 answers

Doctrine: Counting an entity's items with a condition

How can I count an entity's items with a condition in Doctrine? For example, I realize that I can use: $usersCount = $dm->getRepository('User')->count(); But that will only count all users. I would like to count only those that have type employee.…
luqita
  • 4,008
  • 13
  • 60
  • 93
28
votes
2 answers

How can i use php8 attributes instead of annotations in doctrine?

This is what I would like to use: #[ORM\Column(type: "string")] instead of this: /** * @ORM\Column(type="string") */ But I'm getting this error: (error: Class 'Column' is not annotated with 'Attribute' ) Is it because Doctrine does not support…
glm
  • 393
  • 1
  • 3
  • 6
28
votes
11 answers

Symfony 3.4.0 Could not find any fixture services to load

I am using Symfony 3.4.0, I try to load fixtures with: php bin/console doctrine:fixtures:load An error occurred while creating the data, what's wrong?
Alexander
  • 311
  • 1
  • 3
  • 6
28
votes
3 answers

Symfony Cache doctrine/orm/Proxies failed to open stream /Proxy/AbstractProxyFactory.php on line 209

I'm try to move symfony to shared host. I moved symfony structure to / and my web folder is /public_html. Warning: require(/home/user/app/cache/prod/doctrine/orm/Proxies/__CG__UserBundleEntityUser.php): failed to open stream: No such file or…
Luiz Brz Developer
  • 428
  • 1
  • 4
  • 14
27
votes
5 answers

Doctrine 2 PrePersist doesn't fire

Within the same entity I have a PreUpdate and a PrePersist. The PreUpdate fires, but the PrePersist never does. I put a die() after the flush and comments within the lifecycle callbacks. Full entity can be seen at http://pastebin.com/yUk1u4GQ Entity…
Tom
  • 1,971
  • 3
  • 22
  • 32
27
votes
2 answers

How do you access Doctrine DBAL in a Symfony2 service class?

I'm learning Symfony2 (and OOP) and want to create a service that's available throughout my app. This service takes a value foo, checks it against a database table, and returns a value bar. I have a little class namespace…
Acyra
  • 15,864
  • 15
  • 46
  • 53
27
votes
8 answers

Symfony 2 or Symfony 1.4?

I am starting a new Symfony project that will be very important to my company. My experience is only with Symfony 1.4. and I have 3 months to complete the project. The project should be around for years and will grow to have many features. I know…
sqlman
  • 631
  • 1
  • 7
  • 8
27
votes
2 answers

Symfony 2.7 / 3 - Doctrine: You have requested a non-existent service "fos_user.doctrine_registry"

Doing a composer update today suddenly getting the following error: [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException] You have requested a non-existent service "fos_user.doctrine_registry". when composer is executing…
ken
  • 399
  • 1
  • 3
  • 6
27
votes
1 answer

SQL How do I query a many-to-many relationship

How do I select posts that contain a specific tag if there is a many-to-many relationship between posts and tags? The problem I am having is that because of the where tag.name = 'xxx', only that tag is selected. I want to select all posts that have…
Jiew Meng
  • 84,767
  • 185
  • 495
  • 805
27
votes
2 answers

Symfony2 Doctrine querybuilder where IN

I losted trilion hours google this but none of the solutions were good. I have this querybuilder: $qb2=$this->createQueryBuilder('s') ->addSelect('u') ->innerJoin('s.user','u') ->where("u.id IN(:followeeIds)") …
Lukas Lukac
  • 7,766
  • 10
  • 65
  • 75