source: extensions/MyPiwiShop/include/functions.inc.php

Last change on this file was 27781, checked in by Miklfe, 10 years ago
File size: 1.7 KB
Line 
1<?php
2defined('MPS_PATH') or die('Hacking attempt!');
3
4//add a product to all selected image
5function add_product_image($product, $images)
6{
7  if (count($product) == 0 or count($images) == 0)
8  {
9    return;
10  }
11
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  ;');
18
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   }
27  }
28 
29  mass_inserts(
30   MPS_PROD_IMG_TABLE,
31   array_keys($inserts[0]),
32   $inserts
33  );
34}
35
36//delet all product for all selected image
37function deletAll_product_image($product, $images)
38{
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  ;');
45}
46
47//delet all product to specific image
48function delet_Allproduct_Thisimage($images)
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
60//add a product to specific image
61function 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
Note: See TracBrowser for help on using the repository browser.