Witam
Mam problem, muszę zmodyfikować to zapytanie:

  1. <?php
  2. $select = $db->select()->from(array('t' => DB_PREFIX . 'prod_translations'),
  3.        array('options', 'product_name', 'description'))->join(array('p' => DB_PREFIX .
  4.        'products'), 'p.product_id = t.pid', array('product_id', 'category_id', 'gfx',
  5.        'vat', 'promo', 'weight', 'in_stock', 'price', 'actual_price' =>
  6.        'IF(s.special_price, s.special_price, p.price)'))->joinLeft(array('g' =>
  7.        DB_PREFIX . 'gfx'), 't.pid = g.prod_id AND g.main_gfx = 1', array('unic_name'))->
  8.        joinLeft(array('s' => DB_PREFIX . 'special_offers'),
  9.        't.pid = s.pid AND s.date_from <= ' . strtotime(date("Y-m-d")) .
  10.        ' AND s.date_to >= ' . strtotime(date("Y-m-d")), array('special_price'))->where('t.lang = ?',
  11.        $session->lang)->where('t.active = 1')->limit($krok, $page * $krok);
  12. ?>


tak żeby dodać do tego jest wyciąganie nazwy producenta z tabeli manufactures, która wygląda tak:

  1. CREATE TABLE `manufacturers` (
  2. `producent_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `name` varchar(255) NOT NULL DEFAULT '',
  4. `info` varchar(99) NOT NULL DEFAULT '',
  5. `web` varchar(255) NOT NULL DEFAULT '',
  6. `gfx` varchar(30) NOT NULL DEFAULT '',
  7. `isdefault` tinyint(1) NOT NULL,
  8. PRIMARY KEY (`producent_id`),
  9. KEY `name` (`name`),
  10. KEY `isdefault` (`isdefault`)
  11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1087 ;


i dodatkowo pogrupować wyniki po nazwie producenta (kolumna name w tabeli manufactures).

Oto pozostałe tabele:

  1. CREATE TABLE `prod_translations` (
  2. `id_transl` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `pid` int(11) NOT NULL DEFAULT '0',
  4. `product_name` varchar(255) character SET utf8 collate utf8_polish_ci NOT NULL,
  5. `description` mediumtext character SET utf8 collate utf8_polish_ci NOT NULL,
  6. `params` mediumtext NOT NULL,
  7. `jm` varchar(32) NOT NULL DEFAULT '',
  8. `options` mediumtext NOT NULL,
  9. `active` tinyint(1) NOT NULL,
  10. `lang` char(3) NOT NULL DEFAULT '',
  11. `isdefault` tinyint(1) NOT NULL,
  12. PRIMARY KEY (`id_transl`),
  13. UNIQUE KEY `pid` (`pid`,`lang`),
  14. KEY `lang_active` (`active`,`lang`),
  15. KEY `product_name_2` (`product_name`),
  16. KEY `pid_2` (`pid`),
  17. KEY `product_name_3` (`product_name`,`lang`),
  18. KEY `lang` (`lang`),
  19. KEY `isdefault` (`isdefault`),
  20. FULLTEXT KEY `product_name` (`product_name`),
  21. FULLTEXT KEY `search` (`product_name`,`description`)
  22. ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6271 ;


  1. CREATE TABLE `products` (
  2. `product_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `category_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
  4. `producer_id` int(11) UNSIGNED DEFAULT NULL,
  5. `rate` float DEFAULT NULL,
  6. `votes` int(6) DEFAULT NULL,
  7. `vat` varchar(8) NOT NULL DEFAULT '0',
  8. `in_stock` int(11) NOT NULL DEFAULT '1',
  9. `gfx` varchar(99) DEFAULT NULL,
  10. `gfx_small` varchar(30) DEFAULT NULL,
  11. `gfx_enlarge` varchar(30) DEFAULT NULL,
  12. `file` varchar(255) DEFAULT NULL,
  13. `add_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  14. `edit_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  15. `price` decimal(10,2) NOT NULL DEFAULT '0.00',
  16. `promo` char(1) NOT NULL DEFAULT '',
  17. `warranty` int(11) NOT NULL DEFAULT '0',
  18. `weight` varchar(12) NOT NULL DEFAULT '',
  19. `views` int(7) NOT NULL DEFAULT '0',
  20. `category2` int(11) UNSIGNED NOT NULL DEFAULT '0',
  21. `category3` int(11) UNSIGNED NOT NULL DEFAULT '0',
  22. `sort` int(11) NOT NULL DEFAULT '0',
  23. `main_page` tinyint(1) NOT NULL,
  24. `main_page_sort` int(11) NOT NULL DEFAULT '0',
  25. `products_related` mediumtext NOT NULL,
  26. `other_price` float NOT NULL DEFAULT '0',
  27. `product_code` varchar(255) NOT NULL DEFAULT '',
  28. `pkwiu` varchar(255) DEFAULT NULL,
  29. PRIMARY KEY (`product_id`),
  30. UNIQUE KEY `product_code_2` (`product_code`),
  31. KEY `producer_id` (`producer_id`),
  32. KEY `add_date` (`add_date`),
  33. KEY `sort` (`sort`),
  34. KEY `categories` (`category_id`,`category2`,`category3`),
  35. KEY `main_page` (`main_page`),
  36. KEY `main_page_sort` (`main_page_sort`),
  37. KEY `price` (`price`),
  38. KEY `in_stock` (`in_stock`),
  39. KEY `promo` (`promo`),
  40. KEY `category2` (`category2`),
  41. KEY `category3` (`category3`)
  42. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=0 AUTO_INCREMENT=6271 ;


  1. CREATE TABLE `gfx` (
  2. `gfx_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `prod_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
  4. `main_gfx` int(1) NOT NULL DEFAULT '0',
  5. `name` varchar(60) NOT NULL DEFAULT '',
  6. `unic_name` varchar(60) NOT NULL DEFAULT '',
  7. `gfx_sort` int(4) NOT NULL DEFAULT '0',
  8. PRIMARY KEY (`gfx_id`),
  9. UNIQUE KEY `unic_name` (`unic_name`),
  10. KEY `prod_id` (`prod_id`),
  11. KEY `main_gfx` (`main_gfx`),
  12. KEY `gfx_sort` (`gfx_sort`)
  13. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


  1. CREATE TABLE `special_offers` (
  2. `promo_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  3. `pid` int(11) UNSIGNED NOT NULL DEFAULT '0',
  4. `special_price` decimal(10,2) NOT NULL DEFAULT '0.00',
  5. `date_from` int(11) DEFAULT NULL,
  6. `date_to` int(11) DEFAULT NULL,
  7. `start_page` tinyint(1) NOT NULL,
  8. PRIMARY KEY (`promo_id`),
  9. KEY `pid` (`pid`),
  10. KEY `date_from` (`date_from`,`date_to`),
  11. KEY `start_page` (`start_page`)
  12. ) ENGINE=InnoDB DEFAULT CHARSET=utf8 PACK_KEYS=0 AUTO_INCREMENT=1 ;



ktoś jest w stanie to zrobić, bo sam sobie jakoś nie mogę z tym poradzić a jest mi to potrzebne koniecznie.

Pozdrawiam