Skip to content

Instantly share code, notes, and snippets.

@shadowhand
Created March 16, 2009 14:36
Show Gist options
  • Save shadowhand/79905 to your computer and use it in GitHub Desktop.
Save shadowhand/79905 to your computer and use it in GitHub Desktop.
<?php
public function find_all_by_country($country)
{
return $this
->select('DISTINCT categories.*')
->join('categories_products', 'categories_products.category_id', 'categories.id')
->join('products', 'products.id', 'categories_products.product_id')
->join('product_skus', 'product_skus.product_id', 'products.id')
->join('countries_product_skus', 'countries_product_skus.product_sku_id', 'product_skus.id')
->where('countries_product_skus.country_id', $country->id)
->where('categories.category_parent_id', NULL)
->find_all();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment