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
27
votes
6 answers

How to call parent function from instance of child?

I have model BaseUser.class.php User.class.php UserTable.class.php In user Class I have been override the delete function class User extends BaseUser { function delete(){ } } Now, if i want to call parent delete function .... how…
user1435539
27
votes
2 answers

How to set a date in Doctrine 2?

I have a field named "birthday" in doctrine entity. I would like to create an object to add to database using doctrine. Inside the controller : $name = "John Alex"; $birthday = "11-11-90"; $student = new…
AKRAM EL HAMDAOUI
  • 1,818
  • 4
  • 22
  • 27
26
votes
3 answers

Doctrine 2: how to clone all values from one object onto another except ID?

In $entity variable, there is an object of same type as $other_address, but with all field values filled in. I want to set all fields in $other_address object to have exact same values as $entity object. Is this doable in less then N number of…
Tool
  • 12,126
  • 15
  • 70
  • 120
26
votes
1 answer

Different inheritance types in the same schema

I'm using Doctrine 1.2 on a symfony project, and I'm considering mixing concrete and column aggregation inheritance types in my schema: column aggregation lets me query in a parent table and get both parent and child records, while concrete…
26
votes
2 answers

How can I run a doctrine 2 migration commandline without interaction?

How can I run a doctrine 2 migration command without interaction? Currently I have following command which runs on the setup of my Unit Tests. But It always prompt for a Yes/No user input, even when I use the --no-interaction option. $input = new…
tom
  • 8,189
  • 12
  • 51
  • 70
26
votes
3 answers

Generating forms with Symfony 2.8 throws a Twig_Error_Runtime

Since the last LTS version of Symfony was released few days ago (30.11.2015) I started playing with it. Unfortunately I can't generate a CRUD with write actions with the same code that works fine in Symfony 2.7.7. First I create a new Symfony…
cezar
  • 11,616
  • 6
  • 48
  • 84
26
votes
3 answers

Compare dates between datetimes with Doctrine

I have a Symfony2 application with a table that contains a date field, whose type is DateTime. I need to get all the entities where that field value is now. If I uses the following code, I get 0 results because Doctrine is comparing the DateTime…
user3396420
  • 810
  • 2
  • 13
  • 34
26
votes
4 answers

When should use doctrine ORM and when zend-db-table?

In terms of project scale, doctrine vs zend-db-table speed and performance, when should I use doctrine inside Zend project, and when zend-db-table?
Ben
  • 25,389
  • 34
  • 109
  • 165
26
votes
4 answers

Doctrine 2 DQL - Select rows where a many-to-many field is empty?

I have two classes in this example - DeliveryMethod and Country. They have a many-to-many relationship with each other. What I want to do is select all DeliveryMethods that do not have any Countries mapped to them. I can do the opposite, that is…
Gnuffo1
  • 3,478
  • 11
  • 39
  • 53
25
votes
4 answers

Doctrine LIKE case insensitive

is it possible to make a search with Doctrine case insensitive?
chchrist
  • 18,854
  • 11
  • 48
  • 82
25
votes
7 answers

How do I find out which version of Doctrine I am running?

Have been using it for a while with CodeIgniter and I can't remember if I installed v2 or just copied the files from another project. Any ideas?
slugmandrew
  • 1,776
  • 2
  • 25
  • 45
25
votes
1 answer

No result was found for query although at least one row was expected

I have the following code: /** * Search similar category given a string * * @param $searchTerm search similar category */ public function findOneSimilarCategory($searchTerm) { $query =…
adit
  • 32,574
  • 72
  • 229
  • 373
25
votes
2 answers

"Invalid PathExpression. Must be a StateFieldPathExpression" in query builder with non related entities

I have four entities: OfficialDocument, Media, NMediaStatus and NMediaType. I'm trying to translate this SQL: SELECT od.media, od.type, od.status, md.url, nms.name FROM official_document od LEFT JOIN media md ON od.media = md.id LEFT…
ReynierPM
  • 17,594
  • 53
  • 193
  • 363
25
votes
4 answers

Get entityManager inside an Entity

I'd like to use, something like: $em = $this->getEntityManager(); Inside a Entity. I understand I should do this as a service but for some testing purposes, I want to access it from an Entity. Is it possible to achieve that? I've tried to: $em =…
Reinherd
  • 5,476
  • 7
  • 51
  • 88
25
votes
2 answers

Proper way to check if many-to-many relation exists - Symfony2/Doctrine

Let's suppose I have two entities User and Product related by a Many-to-Many relationship with Doctrine. I would like to know the best way to handle a $user->hasProduct($product) method for my User entity that returns true is relation exists or…
Thomas Piard
  • 1,209
  • 2
  • 15
  • 25