doctrine-query

Doctrine - How to print out the real sql, not just the prepared statment?

We're using Doctrine, a PHP ORM. I am creating a query like this: $q = Doctrine_Query::create()->select('id')->from('MyTable'); and then in the function I'm adding in various where clauses and things as appropriate, like this $q->where('normalisedname = ? OR name = ?', array($string, $originalString)); Later on, before execute()-in...

Doctrine - Can I use real SQL (not DQL) in a ->andWhere() ?

I'm using Doctrine, a PHP ORM. I have created a Doctrine Query, and I need more control. So I've started to use the ->andWhere(...) methods to add new where clauses. However I need to do a subquery based on another table, like so: $query->andWhere("id in (SELECT id from other_table where value = ?)", $myvar); The above doesn't work. H...

Doctrine DQL execute passing params

I used this DQL in Doctrine $q->update('product') ->set('quantity','?') ->where('id=?'); $q->execute(array(20,5)); I check the server for the query and this the generated sql UPDATE product SET quantity = '20', updated_at = '5' WHERE (id = '2010-04-26 14:34); So I need to know why the arguments aren't in the correct places? ...

What is the most efficient approach to fetch category tree, products, brands, counts by subcategory in Symfony + Doctrine

Symfony 1.4 + Doctrine 1.2. What is the best way to minimize the number of queries to retrieve products, subcategories of current category, product counts by subcategory and brand for the result set of the query below? Categories are a nested set. Here is my query: $q = Doctrine_Query::create() ->select('c.*, p.product,p.pri...

Get Doctrine Relationships in DQL

I have three tables: Project: ... relations: User: local: authorId foreign: id Users: class: User local: projectId foreign: userId refClass: UserProjects User: ... relations: Projects: class: Project local: userId foreign: projectId refClass: UserProjects ...

Retrieve related objects with Doctrine and Symfony

I searched for a long time, but I don't manage to retrieve two related object in one query. I am using Doctrine and Symfony (uses Doctrine by default). Here is a part of my schema.yml: Member: columns: ...some fields... Report: columns: member: { type: integer, notnull: true } ...some fields... relations: M...

how to get rid of primary column in doctrine queries

Doctrine always includes an ID column in a query, for example: $new_fees = Doctrine::getTable('Stats')->createQuery('s') ->select('s.sid')->where('s.uid = ?', $this->uid) ->andWhere('s.operation = ?', PPOperationType::FEE_PAID_BY_REFERRED_OWNER) ->andWhere('s.created_at > ?', $lastwd) ->groupBy('s.sid')->execute(); won't work...

Doctrine 2 PlainValue expected

I'm having trouble executing a Doctrine DQL Query. This is the error it gives me. Doctrine\Common\Annotations\AnnotationException: [Syntax Error] Expected PlainValue, got 'integer' at position 13 in property Base\Session::$lifetime. My code looks like this: $query = $em->createQuery("SELECT s FROM Base\Session s WHERE s.session = \"...

Why will Doctrine ORM will not create SQL query for my 1-to-many model??

I know this has to have an easy answer, but I cannot figure it out. After tears, I am hoping someone here can help. Here is my YML model: Identity: columns: id: type: integer(10) primary: true autoincrement: true username: type: string(255) Profile: columns: id: ...

Problem with two requests on a table in one action

Hello, I have an action with two requests on an unique table. The results of the requests must be different. But, the result is the same for my two requests and it comes from my second request. // Récupération du (ou des) locataire(s) actuel(s) du logement $this->locataires = Doctrine_Query::create() ->from('logement l')...

Ordering by a generated field in Doctrine 1.2

I'm using a preDqlSelect() callback to add a "virtual field". But the validation of my query must be happening before the callback get fired because I can't order by that new field when I query that model. Here's my callback: class Artist extends BaseArtist { public function preDqlSelect(Doctrine_Event $event) { // Ad...

Doctrine: Using DQL, how do I only grab one related record in a hasMany relationship?

Product has many product images. I want to grab a bunch of products, while only getting one product image each. What's the DQL syntax for that? I'm using Doctrine 1.2. ...