doctrine2

doctrine2 dql, use setParameter with % wildcard when doing a like comparison

I want to use the parameter place holder - e.g. ?1 - with the % wild cards. that is, something like: "u.name LIKE %?1%" (though this throws an error). The docs have the following two examples: 1. // Example - $qb->expr()->like('u.firstname', $qb->expr()->literal('Gui%')) public function like($x, $y); // Returns Expr\Comparison instance ...

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

The title says it all really. 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? ...

Refactoring of model for testing purpose

Hi All, I want to refactor my model so I can properly write a unit test for it. But I have some dependencies. Can anybody point me in the right direction how I can remove these dependencies? class Customer { public function save(array $data, $id = NULL) { // create or update if (empty($id)) { $custom...

Querying an entity on a recursive relationship...

Is it possible to query a recursive relationship in D2 for all fields that don't have a related element specified? ...

Can a Discriminator Column be part of the Primary Key in Doctrine2?

I'm using Single Table Inheritance in Doctrine2 to store OAuth credentials for multiple services. I'd like to use the service's id as the primary key; however, that's not unique across all services. I've setup the database to use the discriminator column and the service's id as the primary key, but I can't find a way to make Doctrine u...

doctrine2 dql query by property of serialized object within entity

I have an entity with an 'object' type column. I want to be able to retreive the entity by a property (say id) of that object. For example, the query would look something like this: $em->createQuery('SELECT e FROM Entity_Class e SOME_MAGIC e.object o WHERE o.id = ?1'); The question is, is there *SOME_MAGIC* in dql? ...

Why don't any functions run from the Doctrine 2.0 Command Line Interface (CLI) ?

I've recently managed to get the betas of Codeigniter 2.0 and Doctrine 2.0 working together, thanks to the help from this guide: http://eryr.wordpress.com/2010/09/26/integrating-doctrine-2-with-codeigniter-2/ I have set up the CLI as set out in that guide, but I can't run any commands - I type doctrine and get the menu and list of comma...

Doctrine 2 get real class name of proxy class

The following: I have approximantely 20 models. These classes extend a base class. This base class contains a method which should be able to determine the classname of the child element. Normally you could this with: get_called_class(); But in many cases doctrine 2 uses ProxyClasses and in that case the get_called_class() function re...

How to get an id without join in doctrine2?

I have entity like this: /** * * @Table(name="table") * @Entity */ class Table { /** * @Column(type="integer") * @Id * @GeneratedValue(strategy="IDENTITY") */ private $id; /** * @ManyToOne(targetEntity="Entities\Users") * @joinColumn(name="userId", referencedColumnName="id") */ ...

Can't delete entity from Doctrine "Not unique table/alias" error

I am using Doctrine 2 and am unable to delete an entity. When I try to access a property/method of the entity, it returns the value as expected. Doctrine\Common\Util\Debug::dump($entity->getId()); //int(17) When I try to access the whole entity I get an error (the same error when I get when try to delete) Doctrine\Common\Util\Debug...

Multiple discrimination levels while using Doctrine2

I'm using Doctrine2 to manage my model below: There's an abstract concept Content with a Composite pattern in Gallery, also an abstract concept Media from which Video and Image inherits. My choice was to add discriminators to Content and Media tables in order to differentiate between Gallery, Video and Image. Content uses JOIN inherit...

Doctrine Class Inheritance in XML

I'm trying to setup class inheritance using the Doctrine 2 ORM, but am getting errors (even when following their examples). I'm using the console from a Symfony 2 sandbox. The simple example uses the classes Person and Employee; An Employee extends Person. The error I'm getting when trying to generate the entities is: [Doctrine\ORM\M...

Hibernate Envers for Doctrine?

Doctrine 1.x and 2 both offer some kind of Versionable support in the form of a separate auditing table that tracks changes over time. However, the versions appear to be intended for per-row use (ie, they all maintain their own version number) instead of database-wide, such as in Hibernate Envers, which gives every row a unique revision ...

Checking for duplacte keys with doctrine 2

Hi all, Is there an easy way to check for duplicate keys with Doctrine 2 before doing a flush? ...

How to make custom sql log in symfony 2 and doctrine 2?

I need to add sql logging to work in native WebProfileBundle. When I do one default connection in application config, I see the sql queries in my log. But my application uses many connections to many db servers, so I can't add all the possible connections to config file. I create runtime connections, i.e.: $config = array( 'us...

Doctrine 2: group by field alias (Error: '...' does not point to a Class. )

I got this Doctrine query: select upper(substring(e.name, 1, 1)) first_letter from Application\Models\Exercise e group by first_letter order by first_letter asc But it throws an exception with the message: Error: 'first_letter' does not point to a Class. If I leave out the group by and the order by,...

findBy relation field

class Profile { /** @OneToMany(targetEntity="Link", mappedBy="owner") */ private $links; } class Link { /** * @ManyToOne(targetEntity="Profile", inversedBy="links") * @JoinColumn(name="owner_id", referencedColumnName="id") */ public $owner; /** * @ManyToOne(targetEntity="Profile") * @JoinC...

generate annotated doctrine2 entites from db schema

Is it possible to generate Doctrine 2 entities, with the relevant docblock annotations, from an existing database schema? ...