1. PHP / Говнокод #8684

    +161

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    public function selectItems( $id, $withStrictment = 'no' /* $withStrictment = no, retail, discount */ ) {
    		
    		if( $withStrictment == 'discount' ) $onlyWithRetailPriceSql = " and items.articul in ( select articul from items_discount ) ";
    		if( $withStrictment == 'retail' ) $onlyWithRetailPriceSql = " and items.articul in ( select articul from retailPrice ) ";
    	
    		$a = database::select("	SELECT items.* FROM items WHERE items.id = '$id' and items.deleted = 'no' ");
    		$a = $a[0];
    
    		$this->data = database::select("SELECT items.*, 
    										IF(DATEDIFF(now(),created) <= 30, 'Новинка! ', '') as fresh,
    										( items.quantity - coalesce(view_pendeditemsquantity.sum,0) ) as quantity,
    										items_comments.comment as dopDescr, items_comments.comment as comment, items_discount.priceAsUSD as discountPrice,
    										items_packing.packing,
    										concat(items.name, ' - ', items.quantity) as name
    										FROM items 
    										LEFT JOIN view_pendeditemsquantity ON items.articul = view_pendeditemsquantity.articul
    										LEFT JOIN items_comments ON items.articul = items_comments.articul
    										left join items_discount on items.articul = items_discount.articul
    										left join items_packing on items.articul = items_packing.articul
    										WHERE items.group_id in ( select articul from items where is_group = '1' and name = '{$a['name']}' and group_id = '' )
    										  and items.deleted = 'no' 
    										  $onlyWithRetailPriceSql 
    										order by items.quantity desc, items.name asc
    										");
    	}

    Запостил: guzik, 30 Ноября 2011

    Комментарии (10) RSS

    Добавить комментарий