I am trying to convert a SQL query into a Doctrine QueryBuilder query. The SQL query works as I want it to within my SQL console (Workbench). But When I converted ,my SQl query into Doctrine 'Query' i get an error i cannot get my head around.....
Pure SQL query:
select
CONCAT('news/', feeds.slug, '/', articles.slug) as 'URL'
from article_feeds
left join articles on article_feeds.article_id=articles.id
left join feeds on article_feeds.feed_id=feeds.id
DOCTRINE Query:
$stmt = $this->db->createQueryBuilder()
->select('faf.article_id', 'faf.feeds_id')
->addSelect('f.slug AS feedSlug')
->addSelect('a.slug AS articleSlug')
->addSelect("Group_CONCAT(DISTINCT CONCAT(feedSlug, '/' , articleSlug) SEPARATOR ',' ) AS url")
->from('article_feeds', 'faf')
->leftJoin('a', 'article_feeds', 'faf', 'af.article_id = a.id')
->leftJoin('f', 'article_feeds', 'faf', 'af.article_id = f.id');
$this->urls = $stmt->execute()->fetch(\PDO::FETCH_OBJ);
Error:
{
code: 0,
message: "The given alias 'articles' is not part of any FROM or JOIN clause table. The currently registered aliases are: faf."
}
From What I understand there is a problem with my leftJoin's but why and what is it, how do I fix it.....?