dql

Join Table On Self using Doctrine (DQL)

I'm attempting to join a table on itself using doctrine's DQL. The scenario is: I have a table of product attribute values at is linked to a products table via a reference table. The product attribute values are to serve as filters on the products, therefore, the products attribute values table needs to be joined back onto itself to ...

DQL return files in a Cabinet

Using DQL I want to return all the documents under the Cabinet test. How would I go about writing a query to do this? ...

Doctrine Named Queries: Specifing limit on query call

Hey guys! Let's imagine something like this: class MyTable extends Doctrine_Table { public function construct() { $q = Doctrine_Query::create()->from('MyTable t') ->orderBy('t.creationDate DESC') ->limit(5); $this->addNamedQuery('top5', $q...

Complex WHERE clauses using the PHP Doctrine ORM

I'm using the PHP Doctrine ORM to build my queries. However, I can't quite seem to figure how to write the following WHERE clause using DQL (Doctrine Query Language): WHERE name='ABC' AND (category1 = 'X' OR category2 = 'X' OR category3 = 'X') AND price > 10 How can I specify where the parentheses go? What I currently have in my PH...

Does "LINQ to DQL" exist?

If LINQ-to-SQL overcomes the object-relational impedance mismatch of a .NET application talking to a SQL Server database... If I want to build a .NET MVC UI, where my model queries a Documentum CMS database... Is there a LINQ to DQL (Documentum Query Language) library ? ... ... that will help me overcome the object-relational impedan...

How to use Doctrine_RawSql for a fulltext search and sorting by relevance

I'm trying to get fulltext searches to be sorted by relevance in a Doctrine_RawSql query. This code will perform the search: $q = new Doctrine_RawSql(); $q->select('{p.*}') ->from('cms_page p') ->where('match(p.content) against (?)', $user_query) ->addComponent('p', 'CmsPage p'); This will execute. I would like the results to ...

Doctrine - own postgres function

Hi, how can i call my own function stored in postgres DB, while i am selecting data throught Doctrine_Query::create() ->select('schema.my_function(id)') ...

Cumulative DQL with Doctrine

Hello Im having a hard time working out a proper DQL to generate cumulative sum. I can do it in plain SQL but when it comes to DQL i cant get hold of it. Here is how it looks in SQL: SELECT s.name, p.date_short, p.nettobuy, (select sum(pp.nettobuy) as sum from price pp where pp.stock_id = p.stock_id and p.broker_id = pp.brok...

Doctrine - filter by foreign agregate value

Hi there, how can i use result of Agregate function in where in Doctrine? For example i want to know user with silly much numbers. SELECT u.name, COUNT(p.id) AS users_phonenumber_count FROM users u INNER JOIN phonenumbers p ON p.user_id = u.id WHERE users_phonenumber_count > 10 GROUP BY u.id How can i access the *use...

Can anybody explain me this error..

I am firing a update query. Its working for one page and not working on other one. Can anybody take a look. thanks <br /> <b>Fatal error</b>: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens' in C:\xa...

Access field in a many-to-many intermediate table with DQL in Doctrine

i have a model called ContentGroup and another called Content with a many-to-many relation between them. The intermediate table has a field called Position, When i try to write a DQL query to obtain all the contents associated with a ContentGroup i cannot reference the position field usign the aliases of the models or relations involved...

Doctrine ORM - Self join without any real relation

I'm trying to find related objects to one object by matching the objects tags. I've constructed a mysql query which will return the objects that match the most by counting the matching tags. I'm new to doctrine (1.2) so I'm wondering if someone could help me to get on the right track modifying my schema and creating a DQL query? The bi...

How can get unique values from data table using dql?

I am having a table in which there is a column in which various values are stored.i want to retrieve unique values from that table using dql. Doctrine_Query::create() ->select('rec.school') ->from('Records rec') ->where("rec.city='$city' ") ...

Having a relation 1 to many on Doctrine but having 2 fields being the primary key on the other end

Hi ! Does anyone knows how can I have a relation 1 to many in doctrine but in this special way: in my principal table I have some fields, almnost none of them are fields which could have translations Table1: table_id <- primary key numeric_field1 numeric_field1 numeric_field3 now in my Table1_translations I have all the fields which ...

Self join without relations in Doctrine ORM

I have a class MenuItem act as NestedSet with many roots: MenuItem: actAs: NestedSet: hasManyRoots: true rootColumnName: root_id I want to retrieve a path from root to selected node. SQL-query for this is: SELECT m2.* FROM menu_item m INNER JOIN menu_item m2 ON m2.lft <= m.lft AND m2.rgt >= m.rgt WHERE m...

What'd be a good pattern on Doctrine to have multiple languages

Hi! I have this challenge which consist in having a system that offers it's content in multiple languages, however a part of the data contained in the system is not translatable such as dates, ints and such. I mean if I have a content on the following YAML Corporativos: columns: nombre: type: string(254) notnull: tr...

How can i get in between rows in mysql query.

I want to fetch intermediate rows from by database. Like for last 10 rows i will use limit : return Doctrine_Query::create() ->select('v.*') ->from('Video v') ->where("v.community_id='$community_id' AND v.user_id='$user_id' AND v.published='$published'") ...

Is this possible to join tables in doctrine ORM without using relations?

Suppose there are two tables. Table X-- Columns: id x_value Table Y-- Columns: id x_id y_value Now I dont want to define relationship in doctrine classes and i want to retrieve some records using these two tables using a query like this: Select x_value from x, y where y.id="variable_z" and x.id=y.x_id; ...

Exclude rows with Doctrine ORM DQL (NOT IN)

I'm building a chat application with codeigniter and doctrine. Tables: - User - User_roles - User_available Relations: ONE user have MANY roles. ONE user_available have ONE user. Users available for chatting will be in the user_available table. Problem: I need to get all users in in user_available that hasn't got role_id 7. So I ...

nesting conditions with DQL

Hey there :) Now that I've read all the DQL docs I still have some doubts, I'm trying to do some nested condictions in my DQL however playing around with DQL I can't seem to be able to archive them To make myself more clear: I have this DQL query $q = Doctrine_Query::create() ->select('c.nombre,c.webpage') ->addSe...