Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. SELECT `sizes`.*
  2. FROM `sizes`
  3. LEFT JOIN `items` ON `sizes`.`id` = `items`.`size_id_ref`
  4. LEFT JOIN `products` ON `items`.`product_id_ref` = `products`.`id`
  5. LEFT JOIN `brands` ON `products`.`brand_id` = `brands`.`id`
  6. WHERE `brands`.`name`='oneBrand'
  7.  
  8. public function getItems(){
  9. return $this->hasMany(Item::className(),['size_id_ref' => 'id']);
  10. }
  11.  
  12. public function getProducts(){
  13. return $this->hasMany(Product::className(),['id' => 'product_id_ref'])
  14. ->via('items');
  15. }
  16.  
  17. public function getBrands(){
  18. return $this->hasMany(Brand::className(),['id' => 'brand_id'])
  19. ->via('products');
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement