We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Builder Join does not work as it should

I have the following tables

app
language
app_info

app_info has a foreign key of app and language tables

I want bring a only result of app_info which has the same id_language, not all, but the query returns me all the app_info which are related with id_app.

    $app = $this->modelsManager->createBuilder()
      ->from(['a'   =>  'App'])
      ->join('AppInfo', 'a.id_app = AppInfo.id_app_fk_app_info')
      ->where('a.id_app = :id_app:')
      ->andWhere('AppInfo.id_lang_available_fk_app_info = :id_lang:')
      ->groupBy('a.id_app')
      ->getQuery()
      ->execute(['id_app'   =>  12, 'id_lang'   =>  1])
      ->getFirst();

    $this->view->app = $app;

Directly in MySQL Workbench when i use the following SQL works like i want

select * 
from app a
join app_info ai
on a.id_app = ai.id_app_fk_app_info
where a.id_app = 12
and ai.id_lang_available_fk_app_info = 1
group by a.id_app

Hey,

have you trid using getQuery() to the debug the query generated by Phalcon's query builder and see if there are any differences with the expected query.