Ignore:
Timestamp:
2010/08/20 18:06:32 (12 years ago)
Author:
nanasess
bzr:base-revision:
ohkouchi@loop-az.jp-20100819104758-beubop5hq0pwdqhx
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/class/SC_CustomerList.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_CustomerList.php
data/class/batch/SC_Batch_Daily.php 15600@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fbatch%2FSC_Batch_Daily.php
data/class/db/SC_DB_DBFactory.php 15123@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fdb%2FSC_DB_DBFactory.php
data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php 15123@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fdb%2Fdbfactory%2FSC_DB_DBFactory_MYSQL.php
data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php 15123@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fdb%2Fdbfactory%2FSC_DB_DBFactory_PGSQL.php
data/class/helper/SC_Helper_DB.php 15176@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_DB.php
data/class/pages/admin/LC_Page_Admin_Home.php 15287@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2FLC_Page_Admin_Home.php
data/class/pages/admin/mail/LC_Page_Admin_Mail_Sendmail.php 16321@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fmail%2FLC_Page_Admin_Mail_Sendmail.php
data/class/pages/admin/order/LC_Page_Admin_Order.php 15584@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Forder%2FLC_Page_Admin_Order.php
data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php 17293@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Fdata%2Fclass%2Fpages%2Fadmin%2Forder%2FLC_Page_Admin_Order_ProductSelect.php
data/class/pages/admin/products/LC_Page_Admin_Products.php 15342@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fproducts%2FLC_Page_Admin_Products.php
data/class/pages/admin/products/LC_Page_Admin_Products_ProductSelect.php 15557@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fproducts%2FLC_Page_Admin_Products_ProductSelect.php
data/class/pages/mypage/LC_Page_Mypage_DownLoad.php 18777@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fversion-2_5-dev%2Fdata%2Fclass%2Fpages%2Fmypage%2FLC_Page_Mypage_DownLoad.php
data/class/util/SC_Utils.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Futil%2FSC_Utils.php
test/class/db/SC_DB_DBFactory_Test.php 15242@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Ftest%2Fclass%2Fdb%2FSC_DB_DBFactory_Test.php
bzr:mapping-version:
v4
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20100820090626-dkyj2ngdh7vklaow
bzr:revno:
2272
bzr:revprop:branch-nick:
branches/version-2_5-dev
bzr:root:
branches/version-2_5-dev
bzr:text-parents:

data/class/SC_CustomerList.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
data/class/batch/SC_Batch_Daily.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
data/class/db/SC_DB_DBFactory.php ohkouchi@loop-az.jp-20100804045224-nsulc26bh1ttqfrb
data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php ohkouchi@loop-az.jp-20100812103342-5fc7rp06997dbg6e
data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php ohkouchi@loop-az.jp-20100812103342-5fc7rp06997dbg6e
data/class/helper/SC_Helper_DB.php ohkouchi@loop-az.jp-20100812103342-5fc7rp06997dbg6e
data/class/pages/admin/LC_Page_Admin_Home.php ohkouchi@loop-az.jp-20100803084717-9sbbuk4o59x5sio4
data/class/pages/admin/mail/LC_Page_Admin_Mail_Sendmail.php ohkouchi@loop-az.jp-20100803050621-j3gswdse0qsqamvw
data/class/pages/admin/order/LC_Page_Admin_Order.php ohkouchi@loop-az.jp-20100803084717-9sbbuk4o59x5sio4
data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php ohkouchi@loop-az.jp-20100803084717-9sbbuk4o59x5sio4
data/class/pages/admin/products/LC_Page_Admin_Products.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
data/class/pages/admin/products/LC_Page_Admin_Products_ProductSelect.php ohkouchi@loop-az.jp-20100614082857-g3n9wn9zakpc7a0m
data/class/pages/mypage/LC_Page_Mypage_DownLoad.php svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:18777
data/class/util/SC_Utils.php ohkouchi@loop-az.jp-20100804045224-nsulc26bh1ttqfrb
test/class/db/SC_DB_DBFactory_Test.php ohkouchi@loop-az.jp-20100726081655-tqxqwy02bxqhswcu
bzr:timestamp:
2010-08-20 18:06:26.950999975 +0900
bzr:user-agent:
bzr2.1.2+bzr-svn1.0.2
svn:original-date:
2010-08-20T09:06:26.951000Z
Message:

DB_TYPE で条件分岐している箇所の抽象化(#801)

  • DB_TYPE で条件分岐している箇所の修正
  • SC_DB_DBFactory に関数を追加
    • getOrderYesterdaySql()
    • getOrderMonthSql()
    • getReviewYesterdaySql()
    • getSendHistoryWhereStartdateSql()
    • concatColumn()
  • SC_Utils::sfManualEscape() の実装を SC_Query::quote() に変更
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/test/class/db/SC_DB_DBFactory_Test.php

    r18763 r18789  
    5757    function testFindTableNames() { 
    5858        $dbFactory = SC_DB_DBFactory::getInstance(); 
    59         $objQuery = new SC_Query(DEFAULT_DSN, true, true); 
     59        $objQuery = new SC_Query(DEFAULT_DSN); 
    6060        $actual = $dbFactory->findTableNames("mtb_pre"); 
    6161        $this->assertEquals("mtb_pref", $actual[0]); 
    6262    } 
     63 
     64    function testConcatColumn() { 
     65 
     66        $params = array("column1", "column2"); 
     67 
     68        switch (DB_TYPE) { 
     69        case "pgsql": 
     70            $expected = "column1 || column2"; 
     71            break; 
     72 
     73        case "mysql": 
     74            $expected = "concat(column1, column2)"; 
     75            break; 
     76 
     77        default: 
     78        } 
     79 
     80        $dbFactory = SC_DB_DBFactory::getInstance(); 
     81        $actual = $dbFactory->concatColumn($params); 
     82 
     83        $this->assertEquals($expected, $actual); 
     84    } 
     85 
     86    /** 
     87     * 昨日の売上高・売上件数を算出する SQL のテスト. 
     88     */ 
     89    function testGetOrderYesterdaySql() { 
     90 
     91        switch (DB_TYPE) { 
     92        case "pgsql": 
     93            $expected = "SELECT COUNT(total) FROM dtb_order " 
     94                       . "WHERE del_flg = 0 " 
     95                         . "AND to_char(create_date,'YYYY/MM/DD') = to_char(now() - interval '1 days','YYYY/MM/DD') " 
     96                         . "AND status <> " . ORDER_CANCEL; 
     97            break; 
     98 
     99        case "mysql": 
     100            $expected = "SELECT COUNT(total) FROM dtb_order " 
     101                       . "WHERE del_flg = 0 " 
     102                         . "AND cast(create_date as date) = DATE_ADD(current_date, interval -1 day) " 
     103                         . "AND status <> " . ORDER_CANCEL; 
     104            break; 
     105 
     106        default: 
     107        } 
     108 
     109        $dbFactory = SC_DB_DBFactory::getInstance(); 
     110        $actual = $dbFactory->getOrderYesterdaySql("COUNT"); 
     111 
     112        $this->assertEquals($expected, $actual); 
     113    } 
     114 
     115    /** 
     116     * 当月の売上高・売上件数を算出する SQL のテスト. 
     117     */ 
     118    function testGetOrderMonthSql() { 
     119        switch (DB_TYPE) { 
     120        case "pgsql": 
     121            $expected =  "SELECT COUNT(total) FROM dtb_order " 
     122                        . "WHERE del_flg = 0 " 
     123                          . "AND to_char(create_date,'YYYY/MM') = ? " 
     124                          . "AND to_char(create_date,'YYYY/MM/DD') <> to_char(now(),'YYYY/MM/DD') " 
     125                          . "AND status <> " . ORDER_CANCEL; 
     126            break; 
     127 
     128        case "mysql": 
     129            $expected = "SELECT COUNT(total) FROM dtb_order " 
     130                       . "WHERE del_flg = 0 " 
     131                         . "AND date_format(create_date, '%Y/%m') = ? " 
     132                         . "AND date_format(create_date, '%Y/%m/%d') <> date_format(now(), '%Y/%m/%d') " 
     133                         . "AND status <> " . ORDER_CANCEL; 
     134            break; 
     135 
     136        default: 
     137        } 
     138 
     139        $dbFactory = SC_DB_DBFactory::getInstance(); 
     140        $actual = $dbFactory->getOrderMonthSql("COUNT"); 
     141 
     142        $this->assertEquals($expected, $actual); 
     143    } 
     144 
     145    /** 
     146     * 昨日のレビュー書き込み件数を算出する SQL のテスト. 
     147     */ 
     148    function testGetReviewYesterdaySql() { 
     149        switch (DB_TYPE) { 
     150        case "pgsql": 
     151            $expected = "SELECT COUNT(*) FROM dtb_review AS A " 
     152                   . "LEFT JOIN dtb_products AS B " 
     153                          . "ON A.product_id = B.product_id " 
     154                       . "WHERE A.del_flg=0 " 
     155                         . "AND B.del_flg = 0 " 
     156                         . "AND to_char(A.create_date, 'YYYY/MM/DD') = to_char(now() - interval '1 days','YYYY/MM/DD') " 
     157                         . "AND to_char(A.create_date,'YYYY/MM/DD') != to_char(now(),'YYYY/MM/DD')"; 
     158            break; 
     159 
     160        case "mysql": 
     161            $expected = "SELECT COUNT(*) FROM dtb_review AS A " 
     162                   . "LEFT JOIN dtb_products AS B " 
     163                          . "ON A.product_id = B.product_id " 
     164                       . "WHERE A.del_flg = 0 " 
     165                         . "AND B.del_flg = 0 " 
     166                         . "AND cast(A.create_date as date) = DATE_ADD(current_date, interval -1 day) " 
     167                         . "AND cast(A.create_date as date) != current_date"; 
     168 
     169            break; 
     170 
     171        default: 
     172        } 
     173 
     174        $dbFactory = SC_DB_DBFactory::getInstance(); 
     175        $actual = $dbFactory->getReviewYesterdaySql(); 
     176 
     177        $this->assertEquals($expected, $actual); 
     178    } 
     179 
    63180} 
    64181 
Note: See TracChangeset for help on using the changeset viewer.