Skip to content

Instantly share code, notes, and snippets.

@lorenzo
Forked from fly2279/gist:4edee4cb14e35c133806
Last active September 19, 2015 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzo/210fc430a0afe6469fc2 to your computer and use it in GitHub Desktop.
Save lorenzo/210fc430a0afe6469fc2 to your computer and use it in GitHub Desktop.
Query with belongsToMany and belongsTo association
<?php
$query = $this->Articles->find('all')
->leftJoinWith('ArticlesAuthors')
->leftJoinWith('Authors')
->where(['Authors.id' => 1])
->orWhere(['ArticlesAuthors.author_id' => 1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment