Using subqueries with doctrine / Errors with aliases

I'm trying to make a simple query with a subquery in a orWhere clause (with Doctrine).

As always, Doctrine tries to rename every aliases and completely destroys the queries...

Here's an example:

$q = Doctrine_Query::create()
    ->from('Actualite a')
    ->where('a.categorie_id =?', $id)
    ->orWhere('a.categorie_id IN (select id from cat.categorie as cat where cat.categorie_id =?)', $id)

Which in MySQL would make something like:

FROM actualite a 
WHERE a.categorie_id = 1 OR a.categorie_id IN (SELECT FROM categorie cat WHERE cat.categorie_id = 1);

Everything is right about it, but then again Doctrine destroys it: Couldn't find class cat

Every time I try to do something a little complex with Doctrine, I have errors with aliases. Any advice or ideas about how to fix this?



The SQL example you've provided is fine but the corresponding Doctrine syntax has a couple of errors. Here's a clean version:

$q = Doctrine_Query::create()
    ->from('Actualite a')
    ->where('a.categorie_id = ?', $id)
    ->orWhere('a.categorie_id IN (SELECT FROM Categorie cat WHERE cat.categorie_id = ?)', $id)

Need Your Help

How to handle Drag and Drop Properly using PYQT QAbstractItemModel

pyqt qtreeview qtreewidget qabstractitemmodel qtreewidgetitem

Here is a code I ended up after two days of TreeView/Model madness. The subject appeared to be much more broad than I thought. I barely can spend so much time creating a singe widget. Anyway. The

How do I omit the values of variables on Sphinx?

python python-sphinx documentation-generation

I have some module-level variables that have long and uninteresting values which I would like to exclude from auto-generated documentation. Is there a way to do this?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.