[27568] | 1 | <?php |
---|
| 2 | defined('MPS_PATH') or die('Hacking attempt!'); |
---|
| 3 | |
---|
[27781] | 4 | //add a product to all selected image |
---|
[27568] | 5 | function add_product_image($product, $images) |
---|
| 6 | { |
---|
| 7 | if (count($product) == 0 or count($images) == 0) |
---|
| 8 | { |
---|
| 9 | return; |
---|
| 10 | } |
---|
| 11 | |
---|
[27781] | 12 | pwg_query(' |
---|
| 13 | DELETE |
---|
| 14 | FROM '.MPS_PROD_IMG_TABLE.' |
---|
| 15 | WHERE image_id IN ('.implode(',', $images).') |
---|
| 16 | AND product_id IN ('.implode(',', $product).') |
---|
| 17 | ;'); |
---|
[27568] | 18 | |
---|
[27781] | 19 | foreach ($images as $image_id) { |
---|
| 20 | |
---|
| 21 | foreach ( array_unique($product) as $product_id) { |
---|
| 22 | $inserts[] = array( |
---|
| 23 | 'image_id' => $image_id, |
---|
| 24 | 'product_id' => $product_id, |
---|
| 25 | ); |
---|
| 26 | } |
---|
[27568] | 27 | } |
---|
[27781] | 28 | |
---|
| 29 | mass_inserts( |
---|
| 30 | MPS_PROD_IMG_TABLE, |
---|
| 31 | array_keys($inserts[0]), |
---|
| 32 | $inserts |
---|
| 33 | ); |
---|
[27568] | 34 | } |
---|
| 35 | |
---|
[27781] | 36 | //delet all product for all selected image |
---|
[27568] | 37 | function deletAll_product_image($product, $images) |
---|
| 38 | { |
---|
[27781] | 39 | pwg_query(' |
---|
| 40 | DELETE |
---|
| 41 | FROM '.MPS_PROD_IMG_TABLE.' |
---|
| 42 | WHERE image_id IN ('.implode(',', $images).') |
---|
| 43 | AND product_id IN ('.implode(',', $product).') |
---|
| 44 | ;'); |
---|
[27568] | 45 | } |
---|
| 46 | |
---|
[27781] | 47 | //delet all product to specific image |
---|
| 48 | function delet_Allproduct_Thisimage($images) |
---|
[27568] | 49 | { |
---|
| 50 | $query = ' |
---|
| 51 | DELETE |
---|
| 52 | FROM '.MPS_PROD_IMG_TABLE.' |
---|
| 53 | WHERE image_id IN ('.$images.') |
---|
| 54 | |
---|
| 55 | ;'; |
---|
| 56 | pwg_query($query); |
---|
| 57 | |
---|
| 58 | } |
---|
| 59 | |
---|
[27781] | 60 | //add a product to specific image |
---|
[27568] | 61 | function add_product_Thisimage($product, $images) |
---|
| 62 | { |
---|
| 63 | if (count($product) == 0 or count($images) == 0) |
---|
| 64 | { |
---|
| 65 | return; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | $query = ' |
---|
| 69 | DELETE |
---|
| 70 | FROM '.MPS_PROD_IMG_TABLE.' |
---|
| 71 | WHERE image_id IN ('.implode(',', $images).') |
---|
| 72 | |
---|
| 73 | ;'; |
---|
| 74 | pwg_query($query); |
---|
| 75 | |
---|
| 76 | $inserts = array(); |
---|
| 77 | foreach ($images as $image_id) |
---|
| 78 | { |
---|
| 79 | foreach ( array_unique($product) as $product_id) |
---|
| 80 | { |
---|
| 81 | $inserts[] = array( |
---|
| 82 | 'image_id' => $image_id, |
---|
| 83 | 'product_id' => $product_id, |
---|
| 84 | ); |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | mass_inserts( |
---|
| 88 | MPS_PROD_IMG_TABLE, |
---|
| 89 | array_keys($inserts[0]), |
---|
| 90 | $inserts |
---|
| 91 | ); |
---|
| 92 | } |
---|
| 93 | |
---|