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

Last change on this file since 27743 was 27743, checked in by Miklfe, 10 years ago

Version de lancement

File size: 1.7 KB
Line 
1<?php
2defined('MPS_PATH') or die('Hacking attempt!');
3
4/**
5*product/image
6**/
7function add_product_image($product, $images)
8{
9  if (count($product) == 0 or count($images) == 0)
10  {
11    return;
12  }
13
14  $query = '
15        DELETE
16        FROM '.MPS_PROD_IMG_TABLE.'
17        WHERE image_id IN ('.implode(',', $images).')
18        AND product_id IN ('.implode(',', $product).')
19
20        ;';
21  pwg_query($query);
22
23  $inserts = array();
24  foreach ($images as $image_id)
25  {
26    foreach ( array_unique($product) as $product_id)
27    {
28      $inserts[] = array(
29          'image_id' => $image_id,
30          'product_id' => $product_id,
31        );
32    }
33  }
34    mass_inserts(
35    MPS_PROD_IMG_TABLE,
36    array_keys($inserts[0]),
37    $inserts
38    );
39}
40
41/**
42*product/image
43**/
44function deletAll_product_image($product, $images)
45{
46  $query = '
47        DELETE
48        FROM '.MPS_PROD_IMG_TABLE.'
49        WHERE image_id IN ('.implode(',', $images).')
50        AND product_id IN ('.implode(',', $product).')
51
52        ;';
53  pwg_query($query);
54
55}
56
57function deletThis_image_Allproduct($images)
58{
59  $query = '
60        DELETE
61        FROM '.MPS_PROD_IMG_TABLE.'
62        WHERE image_id IN ('.$images.')
63
64        ;';
65  pwg_query($query);
66
67}
68
69function add_product_Thisimage($product, $images)
70{
71  if (count($product) == 0 or count($images) == 0)
72  {
73    return;
74  }
75
76  $query = '
77        DELETE
78        FROM '.MPS_PROD_IMG_TABLE.'
79        WHERE image_id IN ('.implode(',', $images).')
80
81        ;';
82  pwg_query($query);
83
84  $inserts = array();
85  foreach ($images as $image_id)
86  {
87    foreach ( array_unique($product) as $product_id)
88    {
89      $inserts[] = array(
90          'image_id' => $image_id,
91          'product_id' => $product_id,
92        );
93    }
94  }
95    mass_inserts(
96    MPS_PROD_IMG_TABLE,
97    array_keys($inserts[0]),
98    $inserts
99    );
100}
101
Note: See TracBrowser for help on using the repository browser.