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
39
votes
4 answers

When inserting an entity with associations, is there a way to just use the FK instead of retrieving the entity?

I need to insert an entity which has associations. If I already have the FK's of the associated entities, is there a way to insert the primary entity into the db with just the FK's populated? Or do I always have to retrieve the associated entities…
blacktie24
  • 4,985
  • 6
  • 41
  • 52
38
votes
2 answers

Symfony 2 + Doctrine 2 + PHPUnit 3.5: Serialization of closure exception

I tried to find something about this on Google but nothing came out. I have a TestCase class that inherits from WebTestCase, with some methods that I want to use in all my unit/functional tests:
Adrian
  • 547
  • 1
  • 5
  • 10
38
votes
3 answers

Using EntityRepository::findBy() with Many-To-Many relations will lead to a E_NOTICE in Doctrine

For a Symfony2 project I had to create a relationship between a blog post and so called platforms. A platform defines a specific filter based on the domain you use to view the site. For example: If you join the site by url first-example.com, the…
devsheeep
  • 2,076
  • 1
  • 22
  • 31
37
votes
5 answers

Generate unique id - doctrine - symfony2

I want to generate a unique ticket ID for my tickets. But how to let doctrine generate a unique id? /** * @ORM\Column(name="id", type="integer") * @ORM\Id() * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; little more explain: id must…
Mitchel Verschoof
  • 1,543
  • 4
  • 20
  • 38
35
votes
3 answers

How to query NOT NULL with Doctrine?

I have table Test: Test: id | name 1 | aaa 2 | 3 | ccc 4 | aaa 5 | 6 | ddd I want result where name is NOT NULL: aaa ccc aaa ddd How can i get with: Doctrine_Core::getTable('Test')->findBy('name', NOTNULL??) <-doesnt working and in model…
Michael Fidy
  • 389
  • 1
  • 4
  • 9
35
votes
3 answers

'where not in' query with doctrine query builder

Im trying to reproduce this query: SELECT * FROM `request_lines` where request_id not in( select requestLine_id from `asset_request_lines` where asset_id = 1 ) in doctrine query builder, I am stuck on the where request_id not in(select I currently…
Andrew Atkinson
  • 4,103
  • 5
  • 44
  • 48
34
votes
1 answer

Object-Relational Mapping vs Database Abstraction Layer

I'm using Doctrine which provides both ORM and DBAL. What is difference between them? How should one decide when to use which?
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
34
votes
4 answers

how to sort an entity's arrayCollection in symfony2

I have an entity "container" with this property /** * @ORM\OneToMany(targetEntity="BizTV\ContentManagementBundle\Entity\Content", mappedBy="container") */ private $content; the property is an array collection... public function __construct() { …
Matt Welander
  • 8,234
  • 24
  • 88
  • 138
34
votes
9 answers

How to check if entity changed in Doctrine 2?

I need to check if a persisted entity has changed and needs to be updated on the database. What I made (and did not work) was the following: $product = $entityManager->getRepository('Product')->find(3); $product->setName('A different…
eagleoneraptor
  • 1,217
  • 2
  • 12
  • 20
33
votes
4 answers

Limiting a doctrine query with a fetch-joined collection?

I have a doctrine query that returns blog posts and their comments: SELECT b, c FROM BlogPost b LEFT JOIN b.comments c I would like to limit the results to 10 blog posts. According to the DQL documentation, setMaxResults() doesn't work correctly on…
Stephen Watkins
  • 25,047
  • 15
  • 66
  • 100
32
votes
8 answers

Can I access discriminator field from php in doctrine2?

I have an entity which defines inheritance like this: * @DiscriminatorColumn(name="type", type="string") * @DiscriminatorMap({"text" = "TextAttribute", "boolean" = "BooleanAttribute", "numeric" = "NumericAttribute", "date" = "DateAttribute"}) I am…
Greg
  • 2,413
  • 5
  • 22
  • 23
31
votes
12 answers

What's your experience with Doctrine ORM?

What's your experience with doctrine? I've never been much of an ORM kind of guy, I mostlymanaged with just some basic db abstraction layer like adodb. But I understood all the concepts and benifits of it. So when a project came along that needed…
paan
  • 7,054
  • 8
  • 38
  • 44
31
votes
6 answers

Doctrine Batch Processing Iterate High Memory Usage

I've been looking into using iterators for batch processing in Doctrine (http://docs.doctrine-project.org/en/2.0.x/reference/batch-processing.html). I've got a database with 20,000 images which I would like to iterate over. I understand that using…
user2406944
31
votes
3 answers

Symfony error The class XXX was not found in the chain configured namespaces XXX

There are some other questions on this subject already, but none of them were really helpful. I am new to Symfony, so it's pretty hard to get my head around it. I am in the file Client\IntranetBundle\LDAP\LDAPAuthenticationProvider.php and this…
user1834464
31
votes
2 answers

Expression mysql NOW() in Doctrine QueryBuilder

How to use the expression mysql NOW() in doctrine querybuilder?
Ricardo Viana
  • 341
  • 1
  • 3
  • 6