Chris
Chris

Reputation: 1505

Concatenation within Doctrine 1 query, unknown relation alias

I've run into an issue with (I believe) concatenation within a Doctrine 1 query. The query has been tested in Phpmyadmin and confirmed to return the desired results, however when run as Doctrine_Query::create() I'm getting an Unknown relation alias error in my php log.

The query:

$q = Doctrine_Query::create()
      ->select('id')
      ->from('TableName')
      ->innerJoin('OtherTable')
      ->where('TableName.table_column LIKE CONCAT("%[",OtherTable.id,"]%")')
      ->andWhere('OtherTable.id='.$EXTERNAL_VAR)
      ->andWhere('TableName.other_table_column=value');

The error (written to an external log file):

[Tue Dec 09 11:28:25 2014] [error] [client 127.0.0.1] Unknown relation alias , referer: http://local.environment/

I've isolated the problem to be the above query, but aren't sure how to reformat the CONCAT line to work as expected.

Upvotes: 1

Views: 766

Answers (1)

rtome
rtome

Reputation: 1993

The problem is with your innerjoin. Doctrine doesn't understand how to join the tables. (thus the message "Unknown relation alias")

Is the relation specified in your schema file ? If you just defined this relation or done other changes to the schema file have you done a rebuild of the model ? (with symfony doctrine:build-model)

Upvotes: 2

Related Questions