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

Last change on this file since 27568 was 27568, checked in by Miklfe, 10 years ago
File size: 2.2 KB
Line 
1<?php
2defined('MPS_PATH') or die('Hacking attempt!');
3
4/**
5*prefilte calcul
6**/
7function filter_sets_image_format($ratios)
8{
9  $res = array();
10 
11   $query = '
12   SELECT id, width, height
13   FROM '.IMAGES_TABLE.'
14   ;';
15       
16   $result = pwg_query($query);
17   if (pwg_db_num_rows($result))
18   {
19    while ($row = pwg_db_fetch_assoc($result))
20    {
21    if ($row['width']>0 && $row['height']>0)
22     {
23     $ratio = floor($row['width'] / $row['height'] * 100) / 100;
24               
25    if(($ratio > $ratios[0] && $ratio < $ratios[1]) || ($ratio > $ratios[2] && $ratio < $ratios[3]))
26     {
27      $res[] = $row['id']; 
28     }
29        }
30   }
31 }
32        return $res;
33}
34
35/**
36*product/image
37**/
38function add_product_image($product, $images)
39{
40  if (count($product) == 0 or count($images) == 0)
41  {
42    return;
43  }
44
45  $query = '
46        DELETE
47        FROM '.MPS_PROD_IMG_TABLE.'
48        WHERE image_id IN ('.implode(',', $images).')
49        AND product_id IN ('.implode(',', $product).')
50
51        ;';
52  pwg_query($query);
53
54  $inserts = array();
55  foreach ($images as $image_id)
56  {
57    foreach ( array_unique($product) as $product_id)
58    {
59      $inserts[] = array(
60          'image_id' => $image_id,
61          'product_id' => $product_id,
62        );
63    }
64  }
65    mass_inserts(
66    MPS_PROD_IMG_TABLE,
67    array_keys($inserts[0]),
68    $inserts
69    );
70}
71
72/**
73*product/image
74**/
75function deletAll_product_image($product, $images)
76{
77  $query = '
78        DELETE
79        FROM '.MPS_PROD_IMG_TABLE.'
80        WHERE image_id IN ('.implode(',', $images).')
81        AND product_id IN ('.implode(',', $product).')
82
83        ;';
84  pwg_query($query);
85
86}
87
88function deletThis_image_Allproduct($images)
89{
90  $query = '
91        DELETE
92        FROM '.MPS_PROD_IMG_TABLE.'
93        WHERE image_id IN ('.$images.')
94
95        ;';
96  pwg_query($query);
97
98}
99
100function add_product_Thisimage($product, $images)
101{
102  if (count($product) == 0 or count($images) == 0)
103  {
104    return;
105  }
106
107  $query = '
108        DELETE
109        FROM '.MPS_PROD_IMG_TABLE.'
110        WHERE image_id IN ('.implode(',', $images).')
111
112        ;';
113  pwg_query($query);
114
115  $inserts = array();
116  foreach ($images as $image_id)
117  {
118    foreach ( array_unique($product) as $product_id)
119    {
120      $inserts[] = array(
121          'image_id' => $image_id,
122          'product_id' => $product_id,
123        );
124    }
125  }
126    mass_inserts(
127    MPS_PROD_IMG_TABLE,
128    array_keys($inserts[0]),
129    $inserts
130    );
131}
132
Note: See TracBrowser for help on using the repository browser.