Skip to content

Instantly share code, notes, and snippets.

@fly2279
Last active September 19, 2015 12:48
Show Gist options
  • Save fly2279/4edee4cb14e35c133806 to your computer and use it in GitHub Desktop.
Save fly2279/4edee4cb14e35c133806 to your computer and use it in GitHub Desktop.
Query with belongsToMany and belongsTo association
$query = $this->Articles->find('all')
->matching('ArticlesAuthors', function ($q) {
return $q->where(['ArticlesAuthors.author_id' => 1]);
})
->where('Articles_author_id' => 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment