Changeset 19662 for branches/version-2_5-dev/data/class
- Timestamp:
- 2010/11/09 18:00:25 (16 years ago)
- bzr:base-revision:
- [email protected]
- bzr:committer:
- Kentaro Ohkouchi <[email protected]>
- bzr:file-ids:
data/Smarty/templates/admin/system/editdb.tpl 19117@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcamp%2Fcamp-2_5-D%2Fdata%2FSmarty%2Ftemplates%2Fadmin%2Fsystem%2Feditdb.tpl
data/Smarty/templates/admin/system/subnavi.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fsystem%2Fsubnavi.tpl
data/class/SC_Initial.php 16506@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_Initial.php
data/class/SC_Product.php 18277@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Fdata%2Fclass%2FSC_Product.php
data/class/SC_Query.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2FSC_Query.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/helper/SC_Helper_Session.php 15277@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_Session.php
data/class/pages/LC_Page.php 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2FLC_Page.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/system/LC_Page_Admin_System_Editdb.php 19117@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcamp%2Fcamp-2_5-D%2Fdata%2Fclass%2Fpages%2Fadmin%2Fsystem%2FLC_Page_Admin_System_Editdb.php
data/class/pages/products/LC_Page_Products_List.php 15154@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fproducts%2FLC_Page_Products_List.php
data/class_extends/page_extends/admin/system/LC_Page_Admin_System_Editdb_Ex.php 19117@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcamp%2Fcamp-2_5-D%2Fdata%2Fclass_extends%2Fpage_extends%2Fadmin%2Fsystem%2FLC_Page_Admin_System_Editdb_Ex.php
html/admin/system/editdb.php 19180@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcamp%2Fcamp-2_5-D%2Fhtml%2Fadmin%2Fsystem%2Feditdb.php
html/install/sql/column_comment.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Fcolumn_comment.sql
html/install/sql/create_table_mysql.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Fcreate_table_mysql.sql
html/install/sql/create_table_pgsql.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Fcreate_table_pgsql.sql
html/install/sql/drop_table.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Fdrop_table.sql
html/install/sql/insert_data.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Finsert_data.sql- bzr:mapping-version:
- v4
- bzr:repository-uuid:
- 1e3b908f-19a9-db11-a64c-001125224ba8
- bzr:revision-id:
- [email protected]
- bzr:revno:
- 2392
- bzr:revprop:branch-nick:
- branches/version-2_5-dev
- bzr:root:
- branches/version-2_5-dev
- bzr:timestamp:
- 2010-11-09 18:00:16.530999899 +0900
- bzr:user-agent:
- bzr2.2.0+bzr-svn1.0.3
- svn:original-date:
- 2010-11-09T09:00:16.531000Z
- Location:
- branches/version-2_5-dev/data/class
- Files:
-
- 1 added
- 8 edited
-
SC_Initial.php (modified) (1 diff)
-
SC_Product.php (modified) (4 diffs)
-
SC_Query.php (modified) (3 diffs)
-
helper/SC_Helper_DB.php (modified) (2 diffs)
-
helper/SC_Helper_Session.php (modified) (1 diff)
-
pages/LC_Page.php (modified) (2 diffs)
-
pages/admin/order/LC_Page_Admin_Order_ProductSelect.php (modified) (6 diffs)
-
pages/admin/system/LC_Page_Admin_System_Editdb.php (added)
-
pages/products/LC_Page_Products_List.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/SC_Initial.php
r18815 r19662 86 86 DB_TYPE . "://" . DB_USER . ":" . DB_PASSWORD . "@" 87 87 . DB_SERVER . ":" .DB_PORT . "/" . DB_NAME); 88 } else {89 define("DEFAULT_DSN", "pgsql://nobody:password@localhost:5432/eccubedb");90 88 } 91 89 } -
branches/version-2_5-dev/data/class/SC_Product.php
r18882 r19662 46 46 var $classCat2_find; 47 47 var $classCats1; 48 49 /** 50 * SC_Queryインスタンスに設定された検索条件をもとに商品IDの配列を取得する. 48 /** 検索用並び替え条件配列 */ 49 var $arrOrderData; 50 51 /** 52 * 商品検索結果の並び順を指定する。 53 * 54 * ただし指定できるテーブルはproduct_idを持っているテーブルであることが必要. 55 * 56 * @param string $col 並び替えの基準とするフィールド 57 * @param string $table 並び替えの基準とするフィールドがあるテーブル 58 * @param string $order 並び替えの順序 ASC / DESC 59 * @return void 60 */ 61 function setProductsOrder($col, $table = 'dtb_products', $order = 'ASC') { 62 $this->arrOrderData = array('col' => $col, 'table' => $table, 'order' => $order); 63 } 64 65 /** 66 * SC_Queryインスタンスに設定された検索条件を元に並び替え済みの検索結果商品IDの配列を取得する。 51 67 * 52 68 * 検索条件は, SC_Query::getWhere() 関数で設定しておく必要があります. … … 56 72 * @return array 商品IDの配列 57 73 */ 58 function findProductIds(&$objQuery, $arrVal = array()) { 74 function findProductIdsOrder(&$objQuery, $arrVal = array(), $where) { 75 $table = <<< __EOS__ 76 dtb_products AS alldtl 77 JOIN dtb_products_class AS T1 78 ON alldtl.product_id = T1.product_id 79 JOIN dtb_product_categories AS T2 80 ON alldtl.product_id = T2.product_id 81 JOIN dtb_category 82 ON T2.category_id = dtb_category.category_id 83 __EOS__; 84 $objQuery->setGroupBy('alldtl.product_id'); 85 if(is_array($this->arrOrderData) and $objQuery->order == ""){ 86 $o_col = $this->arrOrderData['col']; 87 $o_table = $this->arrOrderData['table']; 88 $o_order = $this->arrOrderData['order']; 89 $order = <<< __EOS__ 90 ( 91 SELECT $o_col 92 FROM 93 $o_table as T2 94 WHERE T2.product_id = alldtl.product_id 95 ORDER BY T2.$o_col $o_order 96 LIMIT 1 97 ) $o_order, product_id 98 __EOS__; 99 $objQuery->setOrder($order); 100 } 101 $results = $objQuery->select('alldtl.product_id', $table, "", $arrVal, 102 MDB2_FETCHMODE_ORDERED); 103 foreach ($results as $val) { 104 $resultValues[] = $val[0]; 105 } 106 return $resultValues; 107 } 108 109 /** 110 * SC_Queryインスタンスに設定された検索条件をもとに対象商品数を取得する. 111 * 112 * 検索条件は, SC_Query::getWhere() 関数で設定しておく必要があります. 113 * 114 * @param SC_Query $objQuery SC_Query インスタンス 115 * @param array $arrVal 検索パラメータの配列 116 * @return array 対象商品ID数 117 */ 118 function findProductCount(&$objQuery, $arrVal = array()) { 59 119 $table = <<< __EOS__ 60 120 dtb_products AS alldtl … … 64 124 ON T2.category_id = dtb_category.category_id 65 125 __EOS__; 66 // SC_Query::getCol() ではパフォーマンスが出ない 67 $results = $objQuery->select('alldtl.product_id', $table, "", $arrVal, 68 MDB2_FETCHMODE_ORDERED); 69 foreach ($results as $val) { 70 $resultValues[] = $val[0]; 71 } 72 return array_unique($resultValues); 126 $objQuery->setGroupBy('alldtl.product_id'); 127 $sql_base = $objQuery->getSql('alldtl.product_id',$table); 128 return $objQuery->getOne( "SELECT count(*) FROM ( $sql_base ) as t" , $arrVal); 73 129 } 74 130 … … 109 165 ,update_date 110 166 __EOS__; 111 return$objQuery->select($col, $this->alldtlSQL($objQuery->where),167 $res = $objQuery->select($col, $this->alldtlSQL($objQuery->where), 112 168 "", $arrVal); 169 return $res; 113 170 } 114 171 -
branches/version-2_5-dev/data/class/SC_Query.php
r18820 r19662 65 65 $this->conn = MDB2::singleton($dsn, $options); 66 66 } 67 68 67 if (!PEAR::isError($this->conn)) { 69 68 $this->conn->setCharset(CHAR_CODE); 70 69 $this->conn->setFetchMode(MDB2_FETCHMODE_ASSOC); 71 70 } 72 73 71 $this->dbFactory = SC_DB_DBFactory_Ex::getInstance(); 74 72 $this->force_run = $force_run; … … 733 731 return $this->conn->listTableIndexes($table); 734 732 } 735 733 734 /** 735 * テーブルにインデックスを付与する 736 * 737 * @param string $table テーブル名 738 * @param string $name インデックス名 739 * @param array $definition フィールド名など 通常のフィールド指定時は、$definition=array('fields' => array('フィールド名' => array())); 740 */ 741 function createIndex($table, $name, $definition) { 742 $this->conn->loadModule('Manager'); 743 return $this->conn->createIndex($table, $name, $definition); 744 } 745 746 /** 747 * テーブルにインデックスを破棄する 748 * 749 * @param string $table テーブル名 750 * @param string $name インデックス名 751 */ 752 function dropIndex($table, $name) { 753 $this->conn->loadModule('Manager'); 754 return $this->conn->dropIndex($table, $name); 755 } 756 736 757 /** 737 758 * 値を適切にクォートする. … … 777 798 */ 778 799 function execute(&$sth, $arrVal = array()) { 800 $timeStart = SC_Utils_Ex::sfMicrotimeFloat(); 779 801 $affected =& $sth->execute($arrVal); 802 803 // 一定以上時間かかったSQLの場合、ログ出力する。 804 if(defined('SQL_QUERY_LOG_MODE') && SQL_QUERY_LOG_MODE == true) { 805 $timeEnd = SC_Utils_Ex::sfMicrotimeFloat();; 806 $timeExecTime = $timeEnd - $timeStart; 807 if(defined('SQL_QUERY_LOG_MIN_EXEC_TIME') && $timeExecTime >= (float)SQL_QUERY_LOG_MIN_EXEC_TIME) { 808 //$logMsg = sprintf("SQL_LOG [%.2fsec]\n%s", $timeExecTime, $this->getLastQuery(false)); 809 $logMsg = sprintf("SQL_LOG [%.2fsec]\n%s", $timeExecTime, $sth->query); 810 GC_Utils_Ex::gfPrintLog($logMsg); 811 } 812 } 813 780 814 if (PEAR::isError($affected)) { 781 815 $sql = isset($sth->query) ? $sth->query : ''; -
branches/version-2_5-dev/data/class/helper/SC_Helper_DB.php
r19456 r19662 897 897 /** 898 898 * カテゴリ数の登録を行う. 899 * 899 900 * 900 901 * @param SC_Query $objQuery SC_Query インスタンス 901 902 * @return void 902 903 */ 903 function sfCategory_Count($objQuery){ 904 function sfCategory_Count($objQuery = NULL){ 905 $objProduct = new SC_Product(); 906 907 if($objQuery == NULL) { 908 $objQuery =& SC_Query::getSingletonInstance(); 909 } 910 $is_out_tarns = false; 911 //トランザクションの開始確認。開始していない場合は 912 if(!$objQuery->inTransaction()){ 913 //TODO: トランザクション制御を足す? (重い!) 914 //$objQuery->begin(); 915 $is_out_trans = false; 916 } 917 918 //共通のfrom/where文の構築 919 $sql_where = 'alldtl.del_flg = 0 AND alldtl.status = 1'; 920 // 在庫無し商品の非表示 921 if (NOSTOCK_HIDDEN === true) { 922 $sql_where_dtl = 'stock_max >= 1 OR stock_unlimited_max = 1'; 923 $from = $objProduct->alldtlSQL($sql_where_dtl); 924 }else{ 925 $from = " dtb_products as alldtl "; 926 } 927 928 //dtb_category_countの構成 929 // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを含まない。 930 // 2.5で消える予定だったが復活させます。 931 932 //まずテーブル内容の元を取得 933 $arrCategoryCountOld = $objQuery->select('category_id,product_count','dtb_category_count'); 904 934 905 935 //テーブル内容の削除 906 936 $objQuery->query("DELETE FROM dtb_category_count"); 907 $objQuery->query("DELETE FROM dtb_category_total_count"); 908 909 $sql_where .= 'alldtl.del_flg = 0 AND alldtl.status = 1'; 910 // 在庫無し商品の非表示 911 if (NOSTOCK_HIDDEN === true) { 912 $sql_where .= ' AND (alldtl.stock_max >= 1 OR alldtl.stock_unlimited_max = 1)'; 913 } 914 915 //子カテゴリ内の商品数を集計する 916 917 // カテゴリ情報を取得 918 $arrCat = $objQuery->select('category_id', 'dtb_category'); 919 920 $objProduct = new SC_Product(); 921 922 foreach ($arrCat as $row) { 923 $category_id = $row['category_id']; 937 938 //各カテゴリ内の商品数を数えて格納 939 // これは単純集計なので比較的軽い 940 $sql = <<< __EOS__ 941 INSERT INTO dtb_category_count(category_id, product_count, create_date) 942 SELECT T1.category_id, count(T2.category_id), now() 943 FROM dtb_category AS T1 944 LEFT JOIN dtb_product_categories AS T2 945 ON T1.category_id = T2.category_id 946 LEFT JOIN $from 947 ON T2.product_id = alldtl.product_id 948 WHERE $sql_where 949 GROUP BY T1.category_id, T2.category_id 950 __EOS__; 951 $objQuery->query($sql); 952 953 //dtb_category_total_countの構成 954 // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを「含む」。 955 //差分を取得して、更新対象カテゴリだけを確認する。 956 957 //各カテゴリ毎のデータ値において以前との差を見る 958 $arrCategoryCountNew = $objQuery->select('category_id, product_count','dtb_category_count'); 959 960 //古いデータの構造入れ替え 961 $arrOld = array(); 962 foreach($arrCategoryCountOld as $item){ 963 $arrOld[$item['category_id']] = $item; 964 } 965 //新しいデータの構造入れ替え 966 $arrNew = array(); 967 foreach($arrCategoryCountNew as $item){ 968 $arrNew[$item['category_id']] = $item; 969 } 970 $arrDiffCategory_id = array(); 971 //新しいカテゴリ一覧から見て商品数が異なるデータが無いか確認 972 foreach($arrCategoryCountNew as $item){ 973 $category_id = $item['category_id']; 974 if($arrOld[$category_id]['product_count'] != $item['product_count']){ 975 $arrDiffCategory_id[] = $category_id; 976 } 977 } 978 //削除カテゴリを想定して、古いカテゴリ一覧から見て商品数が異なるデータが無いか確認。 979 foreach($arrCategoryCountOld as $item){ 980 $category_id = $item['category_id']; 981 if($arrNew[$category_id]['product_count'] != $item['product_count']){ 982 $arrDiffCategory_id[] = $category_id; 983 } 984 } 985 986 //対象IDが無ければ終了 987 if(count($arrDiffCategory_id) == 0){ 988 if($is_out_tarns){ 989 $objQuery->commit(); 990 } 991 return; 992 } 993 994 //差分対象カテゴリIDの重複を除去 995 $arrDiffCategory_id = array_unique($arrDiffCategory_id); 996 //差分があったIDとその親カテゴリIDのリストを取得する 997 $arrTgtCategory_id = array(); 998 foreach ($arrDiffCategory_id as $parent_category_id) { 999 $arrTgtCategory_id[] = $parent_category_id; 1000 $arrParentID = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); 1001 foreach($arrParentID as $pid) { 1002 $arrTgtCategory_id[] = $pid; 1003 } 1004 } 1005 1006 //重複を取り除く 1007 $arrTgtCategory_id = array_unique($arrTgtCategory_id); 1008 1009 //dtb_cateogry_total_count 集計処理開始 1010 //旧データの削除 1011 $objQuery->query("DELETE FROM dtb_category_total_count WHERE category_id in (" . implode(',',$arrTgtCategory_id) . ")"); 1012 1013 //カテゴリ毎に処理 1014 foreach ($arrTgtCategory_id as $category_id) { 924 1015 $arrval = array(); 925 926 1016 $arrval[] = $category_id; 927 928 1017 list($tmp_where, $tmp_arrval) = $this->sfGetCatWhere($category_id); 929 1018 if ($tmp_where != "") { … … 945 1034 WHERE $where 946 1035 __EOS__; 947 948 1036 $objQuery->query($sql, $arrval); 1037 } 1038 //トランザクションの終了処理。 1039 if($is_out_tarns){ 1040 $objQuery->commit(); 949 1041 } 950 1042 } -
branches/version-2_5-dev/data/class/helper/SC_Helper_Session.php
r19661 r19662 153 153 function getToken() { 154 154 if (empty($_SESSION[TRANSACTION_ID_NAME])) { 155 $_SESSION[TRANSACTION_ID_NAME] = $this->createToken(); 155 // FIXME 156 //$_SESSION[TRANSACTION_ID_NAME] = $this->createToken(); 156 157 } 157 158 return $_SESSION[TRANSACTION_ID_NAME]; -
branches/version-2_5-dev/data/class/pages/LC_Page.php
r19661 r19662 85 85 */ 86 86 function init() { 87 // 開始時刻を設定する。 88 $this->timeStart = SC_Utils_Ex::sfMicrotimeFloat(); 89 87 90 $this->tpl_authority = $_SESSION['authority']; 88 91 // XXX すべてのページで宣言するべき … … 149 152 * @return void 150 153 */ 151 function destroy() {} 154 function destroy() { 155 // 一定時間以上かかったページの場合、ログ出力する。 156 if(defined('PAGE_DISPLAY_TIME_LOG_MODE') && PAGE_DISPLAY_TIME_LOG_MODE == true) { 157 $timeEnd = SC_Utils_Ex::sfMicrotimeFloat();; 158 $timeExecTime = $timeEnd - $this->timeStart; 159 if(defined('PAGE_DISPLAY_TIME_LOG_MIN_EXEC_TIME') && $timeExecTime >= (float)PAGE_DISPLAY_TIME_LOG_MIN_EXEC_TIME) { 160 $logMsg = sprintf("PAGE_DISPLAY_TIME_LOG [%.2fsec]", $timeExecTime); 161 GC_Utils_Ex::gfPrintLog($logMsg); 162 } 163 } 164 165 } 152 166 153 167 /** -
branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php
r19661 r19662 71 71 $objSess = new SC_Session(); 72 72 $objDb = new SC_Helper_DB_Ex(); 73 $objQuery = new SC_Query();74 73 75 74 // 認証可否の判定 … … 91 90 $this->lfConvertParam(); 92 91 93 $where = " del_flg = 0";92 $where = "alldtl.del_flg = 0"; 94 93 $arrval = array(); 95 94 … … 108 107 list($tmp_where, $tmp_arrval) = $objDb->sfGetCatWhere($val); 109 108 if($tmp_where != "") { 110 $where.= " AND product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")";109 $where.= " AND alldtl.product_id IN (SELECT product_id FROM dtb_product_categories WHERE " . $tmp_where . ")"; 111 110 $arrval = array_merge((array)$arrval, (array)$tmp_arrval); 112 111 } 113 112 break; 114 113 case 'search_product_code': 115 $where .= " AND product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)";114 $where .= " AND alldtl.product_id IN (SELECT product_id FROM dtb_products_class WHERE product_code LIKE ? GROUP BY product_id)"; 116 115 $arrval[] = "$val%"; 117 116 break; … … 121 120 } 122 121 122 // 検索結果対象となる商品の数を取得 123 $objQuery =& SC_Query::getSingletonInstance(); 124 $objQuery->setWhere($where); 123 125 $objProduct = new SC_Product(); 124 $productIds = $objProduct->findProductIds($objQuery, $arrval); 125 126 // 行数の取得 127 $linemax = count($productIds); 128 $this->tpl_linemax = $linemax; 126 $linemax = $objProduct->findProductCount($objQuery, $arrval); 127 $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 129 128 130 129 // ページ送りの処理 … … 141 140 $startno = $objNavi->start_row; 142 141 142 $objProduct = new SC_Product(); 143 $objQuery =& SC_Query::getSingletonInstance(); 144 $objQuery->setWhere($where); 145 143 146 // 取得範囲の指定(開始行番号、行数のセット) 144 147 $objQuery->setLimitOffset($page_max, $startno); … … 147 150 148 151 // 検索結果の取得 149 $this->arrProducts = $objProduct->lists($objQuery, $arrval); 150 $objProduct->setProductsClassByProductIds($productIds); 152 $arrProduct_id = $objProduct->findProductIdsOrder($objQuery, $arrval); 153 154 $where = ""; 155 if (is_array($arrProduct_id) && !empty($arrProduct_id)) { 156 $where = 'product_id IN (' . implode(',', $arrProduct_id) . ')'; 157 } else { 158 // 一致させない 159 $where = '0<>0'; 160 } 161 $objQuery =& SC_Query::getSingletonInstance(); 162 $objQuery->setWhere($where); 163 $arrProducts = $objProduct->lists($objQuery, $arrProduct_id); 164 165 //取得している並び順で並び替え 166 $arrProducts2 = array(); 167 foreach($arrProducts as $item) { 168 $arrProducts2[ $item['product_id'] ] = $item; 169 } 170 $this->arrProducts = array(); 171 foreach($arrProduct_id as $product_id) { 172 $this->arrProducts[] = $arrProducts2[$product_id]; 173 } 174 175 $objProduct->setProductsClassByProductIds($arrProduct_id); 151 176 $objJson = new Services_JSON(); 152 177 $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . '; '; -
branches/version-2_5-dev/data/class/pages/products/LC_Page_Products_List.php
r19661 r19662 328 328 /* 商品一覧の表示 */ 329 329 function lfDispProductsList() { 330 331 330 $objDb = new SC_Helper_DB_Ex(); 332 331 $arrval = array(); … … 338 337 list($where_category, $arrval_category) = $objDb->sfGetCatWhere($this->arrSearchData['category_id']); 339 338 } 340 341 339 // ▼対象商品IDの抽出 342 340 // 商品検索条件の作成(未削除、表示) 343 $where = "del_flg = 0 AND status = 1 "; 344 $where1 = "alldtl.del_flg = 0 AND alldtl.status = 1 "; 341 $where = "alldtl.del_flg = 0 AND alldtl.status = 1 "; 345 342 346 343 // 在庫無し商品の非表示 347 344 if (NOSTOCK_HIDDEN === true) { 348 $where .= ' AND (stock _max >= 1 OR stock_unlimited_max= 1)';345 $where .= ' AND (stock >= 1 OR stock_unlimited = 1)'; 349 346 } 350 347 351 348 if (strlen($where_category) >= 1) { 352 $where.= " AND $where_category"; 353 $where1 .= " AND T2.$where_category"; 349 $where .= " AND T2.$where_category"; 354 350 $arrval = array_merge($arrval, $arrval_category); 355 351 } … … 365 361 foreach ($names as $val) { 366 362 if ( strlen($val) > 0 ) { 367 $where .= " AND ( name ILIKE ? OR comment3 ILIKE ?) "; 368 $where1 .= " AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) "; 363 $where .= " AND ( alldtl.name ILIKE ? OR alldtl.comment3 ILIKE ?) "; 369 364 $arrval[] = "%$val%"; 370 365 $arrval[] = "%$val%"; … … 374 369 // メーカーらのWHERE文字列取得 375 370 if ($this->arrSearchData['maker_id']) { 376 $where .= " AND maker_id = ? "; 377 $where1 .= " AND alldtl.maker_id = ? "; 371 $where .= " AND alldtl.maker_id = ? "; 378 372 $arrval[] = $this->arrSearchData['maker_id']; 379 373 } 380 381 // 一覧表示する商品IDを取得374 375 // 検索結果対象となる商品の数を取得 382 376 $objQuery =& SC_Query::getSingletonInstance(); 383 $objQuery->setWhere($where 1);377 $objQuery->setWhere($where); 384 378 $objProduct = new SC_Product(); 385 $arrProduct_id = $objProduct->findProductIds($objQuery, $arrval); 386 387 // 行数の取得 388 $linemax = count($arrProduct_id); 389 379 $linemax = $objProduct->findProductCount($objQuery, $arrval); 390 380 $this->tpl_linemax = $linemax; // 何件が該当しました。表示用 391 381 … … 399 389 $startno = $this->objNavi->start_row; // 開始行 400 390 401 // WHERE 句 402 $where = '0=0'; 403 if (is_array($arrProduct_id) && !empty($arrProduct_id)) { 404 $where .= ' AND product_id IN (' . implode(',', $arrProduct_id) . ')'; 405 } else { 406 // 一致させない 407 $where .= ' AND 0<>0'; 408 } 409 391 $objProduct = new SC_Product(); 392 $objQuery =& SC_Query::getSingletonInstance(); 410 393 // 表示順序 411 394 switch ($this->orderby) { 412 413 // 販売価格順 395 // 販売価格が安い順 414 396 case 'price': 415 $o rder = "price02_min, product_id";397 $objProduct->setProductsOrder('price02', 'dtb_products_class', 'ASC'); 416 398 break; 417 399 418 400 // 新着順 419 401 case 'date': 420 $o rder = "create_date DESC, product_id";402 $objProduct->setProductsOrder('create_date', 'dtb_products', 'DESC'); 421 403 break; 422 404 … … 453 435 ,product_id 454 436 __EOS__; 437 $objQuery->setOrder($order); 455 438 break; 456 439 } 457 458 440 // 取得範囲の指定(開始行番号、行数のセット) 441 $objQuery->setLimitOffset($this->disp_number, $startno) 442 ->setWhere($where); 443 444 // 表示すべきIDとそのIDの並び順を一気に取得 445 $arrProduct_id = $objProduct->findProductIdsOrder($objQuery, array_merge($arrval, $arrval_order)); 446 447 // 取得した表示すべきIDだけを指定して情報を取得。 448 $where = ""; 449 if (is_array($arrProduct_id) && !empty($arrProduct_id)) { 450 $where = 'product_id IN (' . implode(',', $arrProduct_id) . ')'; 451 } else { 452 // 一致させない 453 $where = '0<>0'; 454 } 459 455 $objQuery =& SC_Query::getSingletonInstance(); 460 $objQuery->setLimitOffset($this->disp_number, $startno) 461 ->setOrder($order) 462 ->setWhere($where); 463 464 // 検索結果の取得 465 $objProduct = new SC_Product(); 466 $this->arrProducts = $objProduct->lists($objQuery, $arrval_order); 467 468 $arrProductId = array(); 469 // 規格セレクトボックス設定 470 foreach ($this->arrProducts as $product) { 471 $arrProductId[] = $product['product_id']; 456 $objQuery->setWhere($where); 457 $arrProducts = $objProduct->lists($objQuery, $arrProduct_id); 458 459 //取得している並び順で並び替え 460 $arrProducts2 = array(); 461 foreach($arrProducts as $item) { 462 $arrProducts2[ $item['product_id'] ] = $item; 463 } 464 $this->arrProducts = array(); 465 foreach($arrProduct_id as $product_id) { 466 $this->arrProducts[] = $arrProducts2[$product_id]; 472 467 } 473 468 474 469 // 規格を設定 475 $objProduct->setProductsClassByProductIds($arrProduct Id);470 $objProduct->setProductsClassByProductIds($arrProduct_id); 476 471 477 472 // 規格1クラス名 … … 494 489 495 490 // 商品ステータスを取得 496 $this->productStatus = $objProduct->getProductStatus($arrProduct Id);491 $this->productStatus = $objProduct->getProductStatus($arrProduct_id); 497 492 498 493 $productsClassCategories = $objProduct->classCategories;
Note: See TracChangeset
for help on using the changeset viewer.
