1

I have this Query in Sql giving me required course_path but I am not able to implement this in Cakephp 3 although I have created relations between these tables in Cakephp Model.

  SELECT c.course_path
  FROM courses c
  JOIN modules m ON c.id = m.course_id
  JOIN topics t ON m.id = t.module_id
  WHERE t.topic_name = 'test_topic'.
ParminderBrar
  • 145
  • 1
  • 3
  • 13
  • 1
    **https://stackoverflow.com/questions/26799094/how-to-filter-by-conditions-for-associated-models** – ndm Jul 20 '17 at 11:04
  • Thanks a lot @ndm. This link solved my problem :) – ParminderBrar Jul 20 '17 at 12:01
  • Still one question- How can I pass a variable instead of fixed value in the Query- $this->Contacts ->find() ->contain('Users') ->matching('Users', function(\Cake\ORM\Query $q) { return $q->where(['Users.id' => 1]); }); – ParminderBrar Jul 20 '17 at 13:05
  • **https://stackoverflow.com/questions/11420520/php-variables-in-anonymous-functions** – ndm Jul 20 '17 at 13:19

0 Answers0