Ignore:
Timestamp:
2009/03/25 10:27:53 (15 years ago)
Author:
kotani
Message:

MySQLでの商品表示高速化対応(商品詳細ページのみ)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_4/data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php

    r17819 r17925  
    3434 * @package DB 
    3535 * @author LOCKON CO.,LTD. 
    36  * @version $Id:SC_DB_DBFactory_MYSQL.php 15267 2007-08-09 12:31:52Z nanasess $ 
     36 * @version $Id$ 
    3737 */ 
    3838class SC_DB_DBFactory_MYSQL extends SC_DB_DBFactory { 
     
    168168        $arrWhere[$target] = $where_tmp . " " . $option; 
    169169        return $arrWhere[$target]; 
    170     } 
    171  
    172     /** 
    173      * SQL の中の View の存在をチェックする. 
    174      * 
    175      * @access private 
    176      * @param string $sql SQL 文 
    177      * @return bool Viewが存在しない場合 false 
    178      */ 
    179     function sfInArray($sql){ 
    180         $arrView = $this->viewToSubQuery(); 
    181  
    182         foreach($arrView as $key => $val){ 
    183             if (strcasecmp($sql, $val) == 0){ 
    184                 $changesql = eregi_replace("($key)", "$val", $sql); 
    185                 $this->sfInArray($changesql); 
    186             } 
    187         } 
    188         return false; 
    189170    } 
    190171 
     
    438419 
    439420            "vw_products_allclass_detail" => ' 
    440                 (SELECT product_id,price01_min,price01_max,price02_min,price02_max,stock_min,stock_max,stock_unlimited_min,stock_unlimited_max, 
    441                 del_flg,status,name,comment1,comment2,comment3,deliv_fee,main_comment,main_image,main_large_image, 
    442                 sub_title1,sub_comment1,sub_image1,sub_large_image1, 
    443                 sub_title2,sub_comment2,sub_image2,sub_large_image2, 
    444                 sub_title3,sub_comment3,sub_image3,sub_large_image3, 
    445                 sub_title4,sub_comment4,sub_image4,sub_large_image4, 
    446                 sub_title5,sub_comment5,sub_image5,sub_large_image5, 
    447                 product_flag,deliv_date_id,sale_limit,point_rate,sale_unlimited,file1,file2,category_id 
    448                 FROM ( SELECT * FROM (dtb_products AS T1 RIGHT JOIN 
    449                 (SELECT 
    450                 product_id AS product_id_sub, 
    451                 MIN(price01) AS price01_min, 
    452                 MAX(price01) AS price01_max, 
    453                 MIN(price02) AS price02_min, 
    454                 MAX(price02) AS price02_max, 
    455                 MIN(stock) AS stock_min, 
    456                 MAX(stock) AS stock_max, 
    457                 MIN(stock_unlimited) AS stock_unlimited_min, 
    458                 MAX(stock_unlimited) AS stock_unlimited_max 
    459                 FROM dtb_products_class GROUP BY product_id) AS T2 
    460                 ON T1.product_id = T2.product_id_sub ) ) AS T3 LEFT JOIN (SELECT rank AS category_rank, category_id AS sub_category_id FROM dtb_category) AS T4 
    461                 ON T3.category_id = T4.sub_category_id) ', 
     421        (SELECT 
     422            dtb_products.product_id, 
     423            T4.price01_min, 
     424            T4.price01_max, 
     425            T4.price02_min, 
     426            T4.price02_max, 
     427            T4.stock_min, 
     428            T4.stock_max, 
     429            T4.stock_unlimited_min, 
     430            T4.stock_unlimited_max, 
     431            dtb_products.del_flg, 
     432            dtb_products.status, 
     433            dtb_products.name, 
     434            dtb_products.comment1, 
     435            dtb_products.comment2, 
     436            dtb_products.comment3, 
     437            dtb_products.deliv_fee, 
     438            dtb_products.main_comment, 
     439            dtb_products.main_image, 
     440            dtb_products.main_large_image, 
     441            dtb_products.sub_title1, 
     442            dtb_products.sub_comment1, 
     443            dtb_products.sub_image1, 
     444            dtb_products.sub_large_image1, 
     445            dtb_products.sub_title2, 
     446            dtb_products.sub_comment2, 
     447            dtb_products.sub_image2, 
     448            dtb_products.sub_large_image2, 
     449            dtb_products.sub_title3, 
     450            dtb_products.sub_comment3, 
     451            dtb_products.sub_image3, 
     452            dtb_products.sub_large_image3, 
     453            dtb_products.sub_title4, 
     454            dtb_products.sub_comment4, 
     455            dtb_products.sub_image4, 
     456            dtb_products.sub_large_image4, 
     457            dtb_products.sub_title5, 
     458            dtb_products.sub_comment5, 
     459            dtb_products.sub_image5, 
     460            dtb_products.sub_large_image5, 
     461            dtb_products.product_flag, 
     462            dtb_products.deliv_date_id, 
     463            dtb_products.sale_limit, 
     464            dtb_products.point_rate, 
     465            dtb_products.sale_unlimited, 
     466            dtb_products.file1, 
     467            dtb_products.file2 
     468        FROM 
     469            dtb_products 
     470            LEFT JOIN 
     471                ( 
     472                    SELECT 
     473                        product_id, 
     474                        MIN(product_code) AS product_code_min, 
     475                        MAX(product_code) AS product_code_max, 
     476                        MIN(price01) AS price01_min, 
     477                        MAX(price01) AS price01_max, 
     478                        MIN(price02) AS price02_min, 
     479                        MAX(price02) AS price02_max, 
     480                        MIN(stock) AS stock_min, 
     481                        MAX(stock) AS stock_max, 
     482                        MIN(stock_unlimited) AS stock_unlimited_min, 
     483                        MAX(stock_unlimited) AS stock_unlimited_max, 
     484                        COUNT(*) as class_count 
     485                    FROM dtb_products_class 
     486                    GROUP BY product_id 
     487                ) AS T4 
     488                ON dtb_products.product_id = T4.product_id 
     489        ) ', 
    462490 
    463491            "vw_product_class" => ' 
Note: See TracChangeset for help on using the changeset viewer.