Quick Search:

View

Revision:

Diff

Diff from 1574 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/osCommerce/trunk/oscommerce/admin/includes/classes/products.php

Annotated File View

hpdl
1217
1 <?php
2 /*
3   $Id: $
4
5   osCommerce, Open Source E-Commerce Solutions
6   http://www.oscommerce.com
7
8   Copyright (c) 2006 osCommerce
9
hpdl
1498
10   This program is free software; you can redistribute it and/or modify
11   it under the terms of the GNU General Public License v2 (1991)
12   as published by the Free Software Foundation.
hpdl
1217
13 */
14
15   include('../includes/classes/products.php');
16
17   class osC_Products_Admin extends osC_Products {
18     function getData($id) {
19       global $osC_Database, $osC_Language;
20
21       $Qproducts = $osC_Database->query('select p.*, pd.* from :table_products p, :table_products_description pd where p.products_id = :products_id and p.products_id = pd.products_id and pd.language_id = :language_id');
22       $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
23       $Qproducts->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
24       $Qproducts->bindInt(':products_id', $id);
25       $Qproducts->bindInt(':language_id', $osC_Language->getID());
26       $Qproducts->execute();
27
28       $data = $Qproducts->toArray();
29
30       $Qproducts->freeResult();
31
32       return $data;
33     }
34
35     function save($id = null, $data) {
36       global $osC_Database, $osC_Language, $osC_Image;
37
38       $error = false;
39
40       $osC_Database->startTransaction();
41
42       if ( is_numeric($id) ) {
43         $Qproduct = $osC_Database->query('update :table_products set products_quantity = :products_quantity, products_price = :products_price, products_date_available = :products_date_available, products_weight = :products_weight, products_weight_class = :products_weight_class, products_status = :products_status, products_tax_class_id = :products_tax_class_id, manufacturers_id = :manufacturers_id, products_last_modified = now() where products_id = :products_id');
44         $Qproduct->bindInt(':products_id', $id);
45       } else {
46         $Qproduct = $osC_Database->query('insert into :table_products (products_quantity, products_price, products_date_available, products_weight, products_weight_class, products_status, products_tax_class_id, manufacturers_id, products_date_added) values (:products_quantity, :products_price, :products_date_available, :products_weight, :products_weight_class, :products_status, :products_tax_class_id, :manufacturers_id, :products_date_added)');
47         $Qproduct->bindRaw(':products_date_added', 'now()');
48       }
49
50       $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
51       $Qproduct->bindInt(':products_quantity', $data['quantity']);
52       $Qproduct->bindValue(':products_price', $data['price']);
53
54       if ( date('Y-m-d') < $data['date_available'] ) {
55         $Qproduct->bindValue(':products_date_available', $data['date_available']);
56       } else {
57         $Qproduct->bindRaw(':products_date_available', 'null');
58       }
59
60       $Qproduct->bindValue(':products_weight', $data['weight']);
61       $Qproduct->bindInt(':products_weight_class', $data['weight_class']);
62       $Qproduct->bindInt(':products_status', $data['status']);
63       $Qproduct->bindInt(':products_tax_class_id', $data['tax_class_id']);
64       $Qproduct->bindInt(':manufacturers_id', $data['manufacturers_id']);
hpdl
1374
65       $Qproduct->setLogging($_SESSION['module'], $id);
hpdl
1217
66       $Qproduct->execute();
67
68       if ( $osC_Database->isError() ) {
69         $error = true;
70       } else {
71         if ( is_numeric($id) ) {
72           $products_id = $id;
73         } else {
74           $products_id = $osC_Database->nextID();
75         }
76
77         $Qcategories = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
78         $Qcategories->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
79         $Qcategories->bindInt(':products_id', $products_id);
hpdl
1374
80         $Qcategories->setLogging($_SESSION['module'], $products_id);
hpdl
1217
81         $Qcategories->execute();
82
83         if ( $osC_Database->isError() ) {
84           $error = true;
85         } else {
86           if ( isset($data['categories']) && !empty($data['categories']) ) {
87             foreach ($_POST['categories'] as $category_id) {
88               $Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
89               $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
90               $Qp2c->bindInt(':products_id', $products_id);
91               $Qp2c->bindInt(':categories_id', $category_id);
hpdl
1374
92               $Qp2c->setLogging($_SESSION['module'], $products_id);
hpdl
1217
93               $Qp2c->execute();
94
95               if ( $osC_Database->isError() ) {
96                 $error = true;
97                 break;
98               }
99             }
100           }
101         }
102       }
103
104       if ( $error === false ) {
105         $images = array();
106
107         $products_image = new upload('products_image');
108
109         if ( $products_image->exists() ) {
110           $products_image->set_destination(realpath('../images/products/originals'));
111
112           if ( $products_image->parse() && $products_image->save() ) {
113             $images[] = $products_image->filename;
114           }
115         }
116
117         if ( isset($data['localimages']) ) {
118           foreach ($data['localimages'] as $image) {
119             $image = basename($image);
120
121             if (file_exists('../images/products/_upload/' . $image)) {
122               copy('../images/products/_upload/' . $image, '../images/products/originals/' . $image);
123               @unlink('../images/products/_upload/' . $image);
124
125               $images[] = $image;
126             }
127           }
128         }
129
130         $default_flag = 1;
131
132         foreach ($images as $image) {
133           $Qimage = $osC_Database->query('insert into :table_products_images (products_id, image, default_flag, sort_order, date_added) values (:products_id, :image, :default_flag, :sort_order, :date_added)');
134           $Qimage->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
135           $Qimage->bindInt(':products_id', $products_id);
136           $Qimage->bindValue(':image', $image);
137           $Qimage->bindInt(':default_flag', $default_flag);
138           $Qimage->bindInt(':sort_order', 0);
139           $Qimage->bindRaw(':date_added', 'now()');
hpdl
1374
140           $Qimage->setLogging($_SESSION['module'], $products_id);
hpdl
1217
141           $Qimage->execute();
142
143           if ( $osC_Database->isError() ) {
144             $error = true;
145           } else {
146             foreach ($osC_Image->getGroups() as $group) {
147               if ($group['id'] != '1') {
148                 $osC_Image->resize($image, $group['id']);
149               }
150             }
151           }
152
153           $default_flag = 0;
154         }
155       }
156
157       if ( $error === false ) {
158         foreach ($osC_Language->getAll() as $l) {
159           if ( is_numeric($id) ) {
160             $Qpd = $osC_Database->query('update :table_products_description set products_name = :products_name, products_description = :products_description, products_model = :products_model, products_keyword = :products_keyword, products_tags = :products_tags, products_url = :products_url where products_id = :products_id and language_id = :language_id');
161           } else {
162             $Qpd = $osC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_model, products_keyword, products_tags, products_url) values (:products_id, :language_id, :products_name, :products_description, :products_model, :products_keyword, :products_tags, :products_url)');
163           }
164
165           $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
166           $Qpd->bindInt(':products_id', $products_id);
167           $Qpd->bindInt(':language_id', $l['id']);
168           $Qpd->bindValue(':products_name', $data['products_name'][$l['id']]);
169           $Qpd->bindValue(':products_description', $data['products_description'][$l['id']]);
170           $Qpd->bindValue(':products_model', $data['products_model'][$l['id']]);
171           $Qpd->bindValue(':products_keyword', $data['products_keyword'][$l['id']]);
172           $Qpd->bindValue(':products_tags', $data['products_tags'][$l['id']]);
173           $Qpd->bindValue(':products_url', $data['products_url'][$l['id']]);
hpdl
1374
174           $Qpd->setLogging($_SESSION['module'], $products_id);
hpdl
1217
175           $Qpd->execute();
176
177           if ( $osC_Database->isError() ) {
178             $error = true;
179             break;
180           }
181         }
182       }
183
184       if ( $error === false ) {
185         $attributes_array = array();
186
187         if (isset($data['attribute_prefix']) && !empty($data['attribute_prefix']) && isset($data['attribute_price']) && !empty($data['attribute_price'])) {
188           foreach ($data['attribute_prefix'] as $groups => $attributes) {
189             foreach ($data['attribute_prefix'][$groups] as $key => $value) {
hpdl
1574
190               if ( isset($data['attribute_price'][$groups][$key]) ) {
hpdl
1217
191                 $attributes_array[] = $groups . '-' . $key;
192
193                 $Qcheck = $osC_Database->query('select products_attributes_id from :table_products_attributes where products_id = :products_id and options_id = :options_id and options_values_id = :options_values_id');
194                 $Qcheck->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
195                 $Qcheck->bindInt(':products_id', $products_id);
196                 $Qcheck->bindInt(':options_id', $groups);
197                 $Qcheck->bindInt(':options_values_id', $key);
198                 $Qcheck->execute();
199
200                 if ( $Qcheck->numberOfRows() ) {
201                   $Qattribute = $osC_Database->query('update :table_products_attributes set options_values_price = :options_values_price, price_prefix = :price_prefix where products_id = :products_id and options_id = :options_id and options_values_id = :options_values_id');
202                 } else {
203                   $Qattribute = $osC_Database->query('insert into :table_products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) values (:products_id, :options_id, :options_values_id, :options_values_price, :price_prefix)');
204                 }
205
206                 $Qattribute->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
207                 $Qattribute->bindInt(':products_id', $products_id);
208                 $Qattribute->bindInt(':options_id', $groups);
209                 $Qattribute->bindInt(':options_values_id', $key);
210                 $Qattribute->bindValue(':options_values_price', $data['attribute_price'][$groups][$key]);
211                 $Qattribute->bindValue(':price_prefix', $value);
hpdl
1374
212                 $Qattribute->setLogging($_SESSION['module'], $products_id);
hpdl
1217
213                 $Qattribute->execute();
214
215                 if ( $osC_Database->isError() ) {
216                   $error = true;
217                   break;
218                 }
219               }
220             }
221           }
222         }
223
224         $Qcheck = $osC_Database->query('select products_attributes_id from :table_products_attributes where products_id = :products_id and concat(options_id, "-", options_values_id) not in (":attributes")');
225         $Qcheck->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
226         $Qcheck->bindInt(':products_id', $products_id);
227         $Qcheck->bindRaw(':attributes', implode('", "', $attributes_array));
228         $Qcheck->execute();
229
230         if ( $Qcheck->numberOfRows() ) {
231           while ($Qcheck->next()) {
232             $Qdelete = $osC_Database->query('delete from :table_products_attributes where products_attributes_id = :products_attributes_id');
233             $Qdelete->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
234             $Qdelete->bindInt(':products_attributes_id', $Qcheck->valueInt('products_attributes_id'));
hpdl
1374
235             $Qdelete->setLogging($_SESSION['module'], $products_id);
hpdl
1217
236             $Qdelete->execute();
237
238             if ( !$osC_Database->isError() ) {
239               $Qdelete = $osC_Database->query('delete from :table_products_attributes_download where products_attributes_id = :products_attributes_id');
240               $Qdelete->bindTable(':table_products_attributes_download', TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD);
241               $Qdelete->bindInt(':products_attributes_id', $Qcheck->valueInt('products_attributes_id'));
hpdl
1374
242               $Qdelete->setLogging($_SESSION['module'], $products_id);
hpdl
1217
243               $Qdelete->execute();
244
245               if ( $osC_Database->isError() ) {
246                 $error = true;
247                 break;
248               }
249             } else {
250               $error = true;
251               break;
252             }
253           }
254         }
255       }
256
257       if ( $error === false ) {
258         $osC_Database->commitTransaction();
259
260         osC_Cache::clear('categories');
261         osC_Cache::clear('category_tree');
262         osC_Cache::clear('also_purchased');
263
264         return true;
265       }
266
267       $osC_Database->rollbackTransaction();
268
269       return false;
270     }
271
272     function copy($id, $category_id, $type) {
273       global $osC_Database;
274
275       $category_array = explode('_', $category_id);
276
277       if ( $type == 'link' ) {
278         $Qcheck = $osC_Database->query('select count(*) as total from :table_products_to_categories where products_id = :products_id and categories_id = :categories_id');
279         $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
280         $Qcheck->bindInt(':products_id', $id);
281         $Qcheck->bindInt(':categories_id', end($category_array));
282         $Qcheck->execute();
283
284         if ( $Qcheck->valueInt('total') < 1 ) {
285           $Qcat = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
286           $Qcat->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
287           $Qcat->bindInt(':products_id', $id);
288           $Qcat->bindInt(':categories_id', end($category_array));
hpdl
1374
289           $Qcat->setLogging($_SESSION['module'], $id);
hpdl
1217
290           $Qcat->execute();
291
292           if ( $Qcat->affectedRows() ) {
293             return true;
294           }
295         }
296       } elseif ( $type == 'duplicate' ) {
297         $Qproduct = $osC_Database->query('select products_quantity, products_price, products_date_available, products_weight, products_weight_class, products_tax_class_id, manufacturers_id from :table_products where products_id = :products_id');
298         $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
299         $Qproduct->bindInt(':products_id', $id);
300         $Qproduct->execute();
301
302         if ( $Qproduct->numberOfRows() === 1 ) {
303           $error = false;
304
305           $osC_Database->startTransaction();
306
307           $Qnew = $osC_Database->query('insert into :table_products (products_quantity, products_price, products_date_added, products_date_available, products_weight, products_weight_class, products_status, products_tax_class_id, manufacturers_id) values (:products_quantity, :products_price, now(), :products_date_available, :products_weight, :products_weight_class, 0, :products_tax_class_id, :manufacturers_id)');
308           $Qnew->bindTable(':table_products', TABLE_PRODUCTS);
309           $Qnew->bindInt(':products_quantity', $Qproduct->valueInt('products_quantity'));
310           $Qnew->bindValue(':products_price', $Qproduct->value('products_price'));
311
312           if ( !osc_empty($Qproduct->value('products_date_available')) ) {
313             $Qnew->bindValue(':products_date_available', $Qproduct->value('products_date_available'));
314           } else {
315             $Qnew->bindRaw(':products_date_available', 'null');
316           }
317
318           $Qnew->bindValue(':products_weight', $Qproduct->value('products_weight'));
319           $Qnew->bindInt(':products_weight_class', $Qproduct->valueInt('products_weight_class'));
320           $Qnew->bindInt(':products_tax_class_id', $Qproduct->valueInt('products_tax_class_id'));
321           $Qnew->bindInt(':manufacturers_id', $Qproduct->valueInt('manufacturers_id'));
hpdl
1374
322           $Qnew->setLogging($_SESSION['module']);
hpdl
1217
323           $Qnew->execute();
324
325           if ( $Qnew->affectedRows() ) {
326             $new_product_id = $osC_Database->nextID();
327
328             $Qdesc = $osC_Database->query('select language_id, products_name, products_description, products_model, products_tags, products_url from :table_products_description where products_id = :products_id');
329             $Qdesc->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
330             $Qdesc->bindInt(':products_id', $id);
331             $Qdesc->execute();
332
333             while ($Qdesc->next()) {
334               $Qnewdesc = $osC_Database->query('insert into :table_products_description (products_id, language_id, products_name, products_description, products_model, products_tags, products_url, products_viewed) values (:products_id, :language_id, :products_name, :products_description, :products_model, :products_tags, :products_url, 0)');
335               $Qnewdesc->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
336               $Qnewdesc->bindInt(':products_id', $new_product_id);
337               $Qnewdesc->bindInt(':language_id', $Qdesc->valueInt('language_id'));
338               $Qnewdesc->bindValue(':products_name', $Qdesc->value('products_name'));
339               $Qnewdesc->bindValue(':products_model', $Qdesc->value('products_model'));
340               $Qnewdesc->bindValue(':products_tags', $Qdesc->value('products_tags'));
341               $Qnewdesc->bindValue(':products_description', $Qdesc->value('products_description'));
342               $Qnewdesc->bindValue(':products_url', $Qdesc->value('products_url'));
hpdl
1374
343               $Qnewdesc->setLogging($_SESSION['module'], $new_product_id);
hpdl
1217
344               $Qnewdesc->execute();
345
346               if ($osC_Database->isError()) {
347                 $error = true;
348                 break;
349               }
350             }
351
352             if ( $error === false ) {
353               $Qp2c = $osC_Database->query('insert into :table_products_to_categories (products_id, categories_id) values (:products_id, :categories_id)');
354               $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
355               $Qp2c->bindInt(':products_id', $new_product_id);
356               $Qp2c->bindInt(':categories_id', end($category_array));
hpdl
1374
357               $Qp2c->setLogging($_SESSION['module'], $new_product_id);
hpdl
1217
358               $Qp2c->execute();
359
360               if ( $osC_Database->isError() ) {
361                 $error = true;
362               }
363             }
364           } else {
365             $error = true;
366           }
367
368           if ( $error === false ) {
369             $osC_Database->commitTransaction();
370
371             osC_Cache::clear('categories');
372             osC_Cache::clear('category_tree');
373             osC_Cache::clear('also_purchased');
374
375             return true;
376           } else {
377             $osC_Database->rollbackTransaction();
378           }
379         }
380       }
381
382       return false;
383     }
384
385     function delete($id, $categories = null) {
386       global $osC_Database, $osC_Image;
387
388       $delete_product = true;
389       $error = false;
390
391       $osC_Database->startTransaction();
392
393       if ( is_array($categories) && !empty($categories) ) {
394         $Qpc = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id and categories_id in :categories_id');
395         $Qpc->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
396         $Qpc->bindInt(':products_id', $id);
397         $Qpc->bindRaw(':categories_id', '("' . implode('", "', $categories) . '")');
hpdl
1374
398         $Qpc->setLogging($_SESSION['module'], $id);
hpdl
1217
399         $Qpc->execute();
400
401         if ( !$osC_Database->isError() ) {
402           $Qcheck = $osC_Database->query('select products_id from :table_products_to_categories where products_id = :products_id limit 1');
403           $Qcheck->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
404           $Qcheck->bindInt(':products_id', $id);
405           $Qcheck->execute();
406
407           if ( $Qcheck->numberOfRows() > 0 ) {
408             $delete_product = false;
409           }
410         } else {
411           $error = true;
412         }
413       }
414
415       if ( ($error === false) && ($delete_product === true) ) {
416         $Qr = $osC_Database->query('delete from :table_reviews where products_id = :products_id');
417         $Qr->bindTable(':table_reviews', TABLE_REVIEWS);
418         $Qr->bindInt(':products_id', $id);
hpdl
1374
419         $Qr->setLogging($_SESSION['module'], $id);
hpdl
1217
420         $Qr->execute();
421
422         if ( $osC_Database->isError() ) {
423           $error = true;
424         }
425
426         if ( $error === false ) {
427           $Qcb = $osC_Database->query('delete from :table_customers_basket where products_id = :products_id or products_id like :products_id');
428           $Qcb->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
429           $Qcb->bindInt(':products_id', $id);
430           $Qcb->bindValue(':products_id', (int)$id . '#%');
431           $Qcb->execute();
432
433           if ( $osC_Database->isError() ) {
434             $error = true;
435           }
436         }
437
438         if ( $error === false ) {
439           $Qp2c = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
440           $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
441           $Qp2c->bindInt(':products_id', $id);
hpdl
1374
442           $Qp2c->setLogging($_SESSION['module'], $id);
hpdl
1217
443           $Qp2c->execute();
444
445           if ( $osC_Database->isError() ) {
446             $error = true;
447           }
448         }
449
450         if ( $error === false ) {
451           $Qs = $osC_Database->query('delete from :table_specials where products_id = :products_id');
452           $Qs->bindTable(':table_specials', TABLE_SPECIALS);
453           $Qs->bindInt(':products_id', $id);
hpdl
1374
454           $Qs->setLogging($_SESSION['module'], $id);
hpdl
1217
455           $Qs->execute();
456
457           if ( $osC_Database->isError() ) {
458             $error = true;
459           }
460         }
461
462         if ( $error === false ) {
463           $Qpa = $osC_Database->query('delete from :table_products_attributes where products_id = :products_id');
464           $Qpa->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
465           $Qpa->bindInt(':products_id', $id);
hpdl
1374
466           $Qpa->setLogging($_SESSION['module'], $id);
hpdl
1217
467           $Qpa->execute();
468
469           if ( $osC_Database->isError() ) {
470             $error = true;
471           }
472         }
473
474         if ( $error === false ) {
475           $Qpd = $osC_Database->query('delete from :table_products_description where products_id = :products_id');
476           $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
477           $Qpd->bindInt(':products_id', $id);
hpdl
1374
478           $Qpd->setLogging($_SESSION['module'], $id);
hpdl
1217
479           $Qpd->execute();
480
481           if ( $osC_Database->isError() ) {
482             $error = true;
483           }
484         }
485
486         if ( $error === false ) {
487           $Qp = $osC_Database->query('delete from :table_products where products_id = :products_id');
488           $Qp->bindTable(':table_products', TABLE_PRODUCTS);
489           $Qp->bindInt(':products_id', $id);
hpdl
1374
490           $Qp->setLogging($_SESSION['module'], $id);
hpdl
1217
491           $Qp->execute();
492
493           if ( $osC_Database->isError() ) {
494             $error = true;
495           }
496         }
497
498         if ( $error === false ) {
499           $Qim = $osC_Database->query('select id from :table_products_images where products_id = :products_id');
500           $Qim->bindTable(':table_products_images', TABLE_PRODUCTS_IMAGES);
501           $Qim->bindInt(':products_id', $id);
502           $Qim->execute();
503
504           while ($Qim->next()) {
505             $osC_Image->delete($Qim->valueInt('id'));
506           }
507         }
508       }
509
510       if ( $error === false ) {
511         $osC_Database->commitTransaction();
512
513         osC_Cache::clear('categories');
514         osC_Cache::clear('category_tree');
515         osC_Cache::clear('also_purchased');
516
517         return true;
518       }
519
520       $osC_Database->rollbackTransaction();
521
522       return false;
523     }
hpdl
1345
524
525     function setDateAvailable($id, $data) {
526       global $osC_Database;
527
528       $Qproduct = $osC_Database->query('update :table_products set products_date_available = :products_date_available, products_last_modified = now() where products_id = :products_id');
529       $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
530
531       if ( date('Y-m-d') < $data['date_available'] ) {
532         $Qproduct->bindValue(':products_date_available', $data['date_available']);
533       } else {
534         $Qproduct->bindRaw(':products_date_available', 'null');
535       }
536
537       $Qproduct->bindInt(':products_id', $id);
hpdl
1374
538       $Qproduct->setLogging($_SESSION['module'], $id);
hpdl
1345
539       $Qproduct->execute();
540
541       if ( !$osC_Database->isError() ) {
542         return true;
543       }
544
545       return false;
546     }
hpdl
1397
547
548     function getKeywordCount($keyword, $id = null) {
549       global $osC_Database;
550
551       $Qkeywords = $osC_Database->query('select count(*) as total from :table_products_description where products_keyword = :products_keyword');
552
553       if ( is_numeric($id) ) {
554         $Qkeywords->appendQuery('and products_id != :products_id');
555         $Qkeywords->bindInt(':products_id', $id);
556       }
557
558       $Qkeywords->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
559       $Qkeywords->bindValue(':products_keyword', $keyword);
560       $Qkeywords->execute();
561
562       return $Qkeywords->valueInt('total');
563     }
hpdl
1217
564   }
565 ?>