Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT `sizes`.*
- FROM `sizes`
- LEFT JOIN `items` ON `sizes`.`id` = `items`.`size_id_ref`
- LEFT JOIN `products` ON `items`.`product_id_ref` = `products`.`id`
- LEFT JOIN `brands` ON `products`.`brand_id` = `brands`.`id`
- WHERE `brands`.`name`='oneBrand'
- public function getItems(){
- return $this->hasMany(Item::className(),['size_id_ref' => 'id']);
- }
- public function getProducts(){
- return $this->hasMany(Product::className(),['id' => 'product_id_ref'])
- ->via('items');
- }
- public function getBrands(){
- return $this->hasMany(Brand::className(),['id' => 'brand_id'])
- ->via('products');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement