function getRanking()
 {
     $objQuery = new SC_Query();
     $col = "T1.product_id, T1.product_name as name,COUNT(*) AS order_count ";
     $from = "dtb_order_detail AS T1\r\n             INNER JOIN dtb_order AS T2 ON T1.order_id = T2.order_id\r\n             INNER JOIN dtb_products AS T3 ON T1.product_id = T3.product_id";
     $objQuery->setgroupby("T1.product_id,T1.product_name");
     $objQuery->setorder("order_count DESC");
     $objQuery->setlimit(10);
     //var_dump($objQuery->setorder("order_count DESC"));
     return $objQuery->select($col, $from, 'T2.status = ?', array('5'));
 }
 function lfGetRelateProducts($tmp_id)
 {
     $objQuery = new SC_Query();
     //自動抽出
     $objQuery->setorder("random()");
     //表示件数の制限
     $objQuery->setlimit(RELATED_PRODUCTS_MAX);
     //検索条件
     $col = "name, main_list_image, price01_min, price02_min, price01_max, price02_max, point_rate";
     $from = "vw_products_allclass AS allcls ";
     $where = "del_flg = 0 AND status = 1 AND (stock_max <> 0 OR stock_max IS NULL) AND product_id = ? ";
     $arrval[] = $tmp_id;
     //結果の取得
     $arrProducts = $objQuery->select($col, $from, $where, $arrval);
     return $arrProducts;
 }
    /**
     * デストラクタ.
     *
     * @return void
     */
    function lfGetRecommendProducts($product_id)
    {
        $objQuery = new SC_Query();
        $cols = '*, (SELECT COUNT(*) FROM dtb_order_detail WHERE product_id = alldtl.product_id) AS cnt';
        $from = 'vw_products_allclass_detail AS alldtl';
        $where = <<<__EOS__
            del_flg = 0
            AND status = 1
            AND product_id IN (
                SELECT product_id
                FROM
                    dtb_order_detail
                    INNER JOIN dtb_order
                        ON dtb_order_detail.order_id = dtb_order.order_id
                WHERE 0=0
                    AND dtb_order.del_flg = 0
                    AND dtb_order.order_id IN (
                        SELECT order_id
                        FROM dtb_order_detail
                        WHERE 0=0
                            AND product_id = ?
                    )
                    AND dtb_order_detail.product_id <> ?
            )
__EOS__;
        $objQuery->setorder('cnt DESC, RANDOM()');
        $objQuery->setlimit($this->max);
        $recommendProducts = $objQuery->select($cols, $from, $where, array($product_id, $product_id));
        return $recommendProducts;
    }