| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. |
---|
| 4 | * |
---|
| 5 | * http://www.lockon.co.jp/ |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | /** |
---|
| 9 | * DB関連のヘルパークラス. |
---|
| 10 | * |
---|
| 11 | * @package Helper |
---|
| 12 | * @author LOCKON CO.,LTD. |
---|
| 13 | * @version $Id:SC_Helper_DB.php 15532 2007-08-31 14:39:46Z nanasess $ |
---|
| 14 | */ |
---|
| 15 | class SC_Helper_DB { |
---|
| 16 | |
---|
| 17 | // {{{ properties |
---|
| 18 | |
---|
| 19 | /** ルートカテゴリ取得フラグ */ |
---|
| 20 | var $g_root_on; |
---|
| 21 | |
---|
| 22 | /** ルートカテゴリID */ |
---|
| 23 | var $g_root_id; |
---|
| 24 | |
---|
| 25 | /** 選択中カテゴリ取得フラグ */ |
---|
| 26 | var $g_category_on; |
---|
| 27 | |
---|
| 28 | /** 選択中カテゴリID */ |
---|
| 29 | var $g_category_id; |
---|
| 30 | |
---|
| 31 | // }}} |
---|
| 32 | // {{{ functions |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * データベースのバージョンを所得する. |
---|
| 36 | * |
---|
| 37 | * @param string $dsn データソース名 |
---|
| 38 | * @return string データベースのバージョン |
---|
| 39 | */ |
---|
| 40 | function sfGetDBVersion($dsn = "") { |
---|
| 41 | $dbFactory = SC_DB_DBFactory::getInstance(); |
---|
| 42 | return $dbFactory->sfGetDBVersion($dsn); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | /** |
---|
| 46 | * テーブルの存在をチェックする. |
---|
| 47 | * |
---|
| 48 | * @param string $table_name チェック対象のテーブル名 |
---|
| 49 | * @param string $dsn データソース名 |
---|
| 50 | * @return テーブルが存在する場合 true |
---|
| 51 | */ |
---|
| 52 | function sfTabaleExists($table_name, $dsn = "") { |
---|
| 53 | $dbFactory = SC_DB_DBFactory::getInstance(); |
---|
| 54 | $dsn = $dbFactory->getDSN($dsn); |
---|
| 55 | |
---|
| 56 | $objQuery = new SC_Query($dsn, true, true); |
---|
| 57 | // 正常に接続されている場合 |
---|
| 58 | if(!$objQuery->isError()) { |
---|
| 59 | list($db_type) = split(":", $dsn); |
---|
| 60 | $sql = $dbFactory->getTableExistsSql(); |
---|
| 61 | $arrRet = $objQuery->getAll($sql, array($table_name)); |
---|
| 62 | if(count($arrRet) > 0) { |
---|
| 63 | return true; |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | return false; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * カラムの存在チェックと作成を行う. |
---|
| 71 | * |
---|
| 72 | * チェック対象のテーブルに, 該当のカラムが存在するかチェックする. |
---|
| 73 | * 引数 $add が true の場合, 該当のカラムが存在しない場合は, カラムの生成を行う. |
---|
| 74 | * カラムの生成も行う場合は, $col_type も必須となる. |
---|
| 75 | * |
---|
| 76 | * @param string $table_name テーブル名 |
---|
| 77 | * @param string $column_name カラム名 |
---|
| 78 | * @param string $col_type カラムのデータ型 |
---|
| 79 | * @param string $dsn データソース名 |
---|
| 80 | * @param bool $add カラムの作成も行う場合 true |
---|
| 81 | * @return bool カラムが存在する場合とカラムの生成に成功した場合 true, |
---|
| 82 | * テーブルが存在しない場合 false, |
---|
| 83 | * 引数 $add == false でカラムが存在しない場合 false |
---|
| 84 | */ |
---|
| 85 | function sfColumnExists($table_name, $col_name, $col_type = "", $dsn = "", $add = false) { |
---|
| 86 | $dbFactory = SC_DB_DBFactory::getInstance(); |
---|
| 87 | $dsn = $dbFactory->getDSN($dsn); |
---|
| 88 | |
---|
| 89 | // テーブルが無ければエラー |
---|
| 90 | if(!$this->sfTabaleExists($table_name, $dsn)) return false; |
---|
| 91 | |
---|
| 92 | $objQuery = new SC_Query($dsn, true, true); |
---|
| 93 | // 正常に接続されている場合 |
---|
| 94 | if(!$objQuery->isError()) { |
---|
| 95 | list($db_type) = split(":", $dsn); |
---|
| 96 | |
---|
| 97 | // カラムリストを取得 |
---|
| 98 | $arrRet = $dbFactory->sfGetColumnList($table_name); |
---|
| 99 | if(count($arrRet) > 0) { |
---|
| 100 | if(in_array($col_name, $arrRet)){ |
---|
| 101 | return true; |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | } |
---|
| 105 | |
---|
| 106 | // カラムを追加する |
---|
| 107 | if($add){ |
---|
| 108 | $objQuery->query("ALTER TABLE $table_name ADD $col_name $col_type "); |
---|
| 109 | return true; |
---|
| 110 | } |
---|
| 111 | return false; |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | * インデックスの存在チェックと作成を行う. |
---|
| 116 | * |
---|
| 117 | * チェック対象のテーブルに, 該当のインデックスが存在するかチェックする. |
---|
| 118 | * 引数 $add が true の場合, 該当のインデックスが存在しない場合は, インデックスの生成を行う. |
---|
| 119 | * インデックスの生成も行う場合で, DB_TYPE が mysql の場合は, $length も必須となる. |
---|
| 120 | * |
---|
| 121 | * @param string $table_name テーブル名 |
---|
| 122 | * @param string $column_name カラム名 |
---|
| 123 | * @param string $index_name インデックス名 |
---|
| 124 | * @param integer|string $length インデックスを作成するデータ長 |
---|
| 125 | * @param string $dsn データソース名 |
---|
| 126 | * @param bool $add インデックスの生成もする場合 true |
---|
| 127 | * @return bool インデックスが存在する場合とインデックスの生成に成功した場合 true, |
---|
| 128 | * テーブルが存在しない場合 false, |
---|
| 129 | * 引数 $add == false でインデックスが存在しない場合 false |
---|
| 130 | */ |
---|
| 131 | function sfIndexExists($table_name, $col_name, $index_name, $length = "", $dsn = "", $add = false) { |
---|
| 132 | $dbFactory = SC_DB_DBFactory::getInstance(); |
---|
| 133 | $dsn = $dbFactory->getDSN($dsn); |
---|
| 134 | |
---|
| 135 | // テーブルが無ければエラー |
---|
| 136 | if (!$this->sfTabaleExists($table_name, $dsn)) return false; |
---|
| 137 | |
---|
| 138 | $objQuery = new SC_Query($dsn, true, true); |
---|
| 139 | $arrRet = $dbFactory->getTableIndex($index_name, $table_name); |
---|
| 140 | |
---|
| 141 | // すでにインデックスが存在する場合 |
---|
| 142 | if(count($arrRet) > 0) { |
---|
| 143 | return true; |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | // インデックスを作成する |
---|
| 147 | if($add){ |
---|
| 148 | $dbFactory->createTableIndex($index_name, $table_name, $col_name, $length()); |
---|
| 149 | return true; |
---|
| 150 | } |
---|
| 151 | return false; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | /** |
---|
| 155 | * データの存在チェックを行う. |
---|
| 156 | * |
---|
| 157 | * @param string $table_name テーブル名 |
---|
| 158 | * @param string $where データを検索する WHERE 句 |
---|
| 159 | * @param string $dsn データソース名 |
---|
| 160 | * @param string $sql データの追加を行う場合の SQL文 |
---|
| 161 | * @param bool $add データの追加も行う場合 true |
---|
| 162 | * @return bool データが存在する場合 true, データの追加に成功した場合 true, |
---|
| 163 | * $add == false で, データが存在しない場合 false |
---|
| 164 | */ |
---|
| 165 | function sfDataExists($table_name, $where, $arrval, $dsn = "", $sql = "", $add = false) { |
---|
| 166 | $dbFactory = SC_DB_DBFactory::getInstance(); |
---|
| 167 | $dsn = $dbFactory->getDSN($dsn); |
---|
| 168 | |
---|
| 169 | $objQuery = new SC_Query($dsn, true, true); |
---|
| 170 | $count = $objQuery->count($table_name, $where, $arrval); |
---|
| 171 | |
---|
| 172 | if($count > 0) { |
---|
| 173 | $ret = true; |
---|
| 174 | } else { |
---|
| 175 | $ret = false; |
---|
| 176 | } |
---|
| 177 | // データを追加する |
---|
| 178 | if(!$ret && $add) { |
---|
| 179 | $objQuery->exec($sql); |
---|
| 180 | } |
---|
| 181 | return $ret; |
---|
| 182 | } |
---|
| 183 | |
---|
| 184 | /** |
---|
| 185 | * 店舗基本情報を取得する. |
---|
| 186 | * |
---|
| 187 | * @return array 店舗基本情報の配列 |
---|
| 188 | */ |
---|
| 189 | function sf_getBasisData() { |
---|
| 190 | $objQuery = new SC_Query(); |
---|
| 191 | $arrRet = $objQuery->select('*', 'dtb_baseinfo'); |
---|
| 192 | |
---|
| 193 | if (isset($arrRet[0])) return $arrRet[0]; |
---|
| 194 | |
---|
| 195 | return array(); |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | /* 選択中のアイテムのルートカテゴリIDを取得する */ |
---|
| 199 | function sfGetRootId() { |
---|
| 200 | |
---|
| 201 | if(!$this->g_root_on) { |
---|
| 202 | $this->g_root_on = true; |
---|
| 203 | $objQuery = new SC_Query(); |
---|
| 204 | |
---|
| 205 | if (!isset($_GET['product_id'])) $_GET['product_id'] = ""; |
---|
| 206 | if (!isset($_GET['category_id'])) $_GET['category_id'] = ""; |
---|
| 207 | |
---|
| 208 | if(!empty($_GET['product_id']) || !empty($_GET['category_id'])) { |
---|
| 209 | // 選択中のカテゴリIDを判定する |
---|
| 210 | $category_id = $this->sfGetCategoryId($_GET['product_id'], $_GET['category_id']); |
---|
| 211 | // ROOTカテゴリIDの取得 |
---|
| 212 | $arrRet = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $category_id); |
---|
| 213 | $root_id = $arrRet[0]; |
---|
| 214 | } else { |
---|
| 215 | // ROOTカテゴリIDをなしに設定する |
---|
| 216 | $root_id = ""; |
---|
| 217 | } |
---|
| 218 | $this->g_root_id = $root_id; |
---|
| 219 | } |
---|
| 220 | return $this->g_root_id; |
---|
| 221 | } |
---|
| 222 | |
---|
| 223 | /** |
---|
| 224 | * 商品規格情報を取得する. |
---|
| 225 | * |
---|
| 226 | * @param array $arrID 規格ID |
---|
| 227 | * @return array 規格情報の配列 |
---|
| 228 | */ |
---|
| 229 | function sfGetProductsClass($arrID) { |
---|
| 230 | list($product_id, $classcategory_id1, $classcategory_id2) = $arrID; |
---|
| 231 | |
---|
| 232 | if($classcategory_id1 == "") { |
---|
| 233 | $classcategory_id1 = '0'; |
---|
| 234 | } |
---|
| 235 | if($classcategory_id2 == "") { |
---|
| 236 | $classcategory_id2 = '0'; |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | // 商品規格取得 |
---|
| 240 | $objQuery = new SC_Query(); |
---|
| 241 | $col = "product_id, deliv_fee, name, product_code, main_list_image, main_image, price01, price02, point_rate, product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited, sale_limit, sale_unlimited"; |
---|
| 242 | $table = "vw_product_class AS prdcls"; |
---|
| 243 | $where = "product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?"; |
---|
| 244 | $objQuery->setorder("rank1 DESC, rank2 DESC"); |
---|
| 245 | $arrRet = $objQuery->select($col, $table, $where, array($product_id, $classcategory_id1, $classcategory_id2)); |
---|
| 246 | return $arrRet[0]; |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | /** |
---|
| 250 | * 支払い方法を取得する. |
---|
| 251 | * |
---|
| 252 | * @return void |
---|
| 253 | */ |
---|
| 254 | function sfGetPayment() { |
---|
| 255 | $objQuery = new SC_Query(); |
---|
| 256 | // 購入金額が条件額以下の項目を取得 |
---|
| 257 | $where = "del_flg = 0"; |
---|
| 258 | $objQuery->setorder("fix, rank DESC"); |
---|
| 259 | $arrRet = $objQuery->select("payment_id, payment_method, rule", "dtb_payment", $where); |
---|
| 260 | return $arrRet; |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | /** |
---|
| 264 | * カート内商品の集計処理を行う. |
---|
| 265 | * |
---|
| 266 | * @param LC_Page $objPage ページクラスのインスタンス |
---|
| 267 | * @param SC_CartSession $objCartSess カートセッションのインスタンス |
---|
| 268 | * @param array $arrInfo 商品情報の配列 |
---|
| 269 | * @return LC_Page 集計処理後のページクラスインスタンス |
---|
| 270 | */ |
---|
| 271 | function sfTotalCart(&$objPage, $objCartSess, $arrInfo) { |
---|
| 272 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 273 | // 規格名一覧 |
---|
| 274 | $arrClassName = $objDb->sfGetIDValueList("dtb_class", "class_id", "name"); |
---|
| 275 | // 規格分類名一覧 |
---|
| 276 | $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); |
---|
| 277 | |
---|
| 278 | $objPage->tpl_total_pretax = 0; // 費用合計(税込み) |
---|
| 279 | $objPage->tpl_total_tax = 0; // 消費税合計 |
---|
| 280 | $objPage->tpl_total_point = 0; // ポイント合計 |
---|
| 281 | |
---|
| 282 | // カート内情報の取得 |
---|
| 283 | $arrCart = $objCartSess->getCartList(); |
---|
| 284 | $max = count($arrCart); |
---|
| 285 | $cnt = 0; |
---|
| 286 | |
---|
| 287 | for ($i = 0; $i < $max; $i++) { |
---|
| 288 | // 商品規格情報の取得 |
---|
| 289 | $arrData = $this->sfGetProductsClass($arrCart[$i]['id']); |
---|
| 290 | $limit = ""; |
---|
| 291 | // DBに存在する商品 |
---|
| 292 | if (count($arrData) > 0) { |
---|
| 293 | |
---|
| 294 | // 購入制限数を求める。 |
---|
| 295 | if ($arrData['stock_unlimited'] != '1' && $arrData['sale_unlimited'] != '1') { |
---|
| 296 | if($arrData['sale_limit'] < $arrData['stock']) { |
---|
| 297 | $limit = $arrData['sale_limit']; |
---|
| 298 | } else { |
---|
| 299 | $limit = $arrData['stock']; |
---|
| 300 | } |
---|
| 301 | } else { |
---|
| 302 | if ($arrData['sale_unlimited'] != '1') { |
---|
| 303 | $limit = $arrData['sale_limit']; |
---|
| 304 | } |
---|
| 305 | if ($arrData['stock_unlimited'] != '1') { |
---|
| 306 | $limit = $arrData['stock']; |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | |
---|
| 310 | if($limit != "" && $limit < $arrCart[$i]['quantity']) { |
---|
| 311 | // カート内商品数を制限に合わせる |
---|
| 312 | $objCartSess->setProductValue($arrCart[$i]['id'], 'quantity', $limit); |
---|
| 313 | $quantity = $limit; |
---|
| 314 | $objPage->tpl_message = "※「" . $arrData['name'] . "」は販売制限しております、一度にこれ以上の購入はできません。"; |
---|
| 315 | } else { |
---|
| 316 | $quantity = $arrCart[$i]['quantity']; |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | $objPage->arrProductsClass[$cnt] = $arrData; |
---|
| 320 | $objPage->arrProductsClass[$cnt]['quantity'] = $quantity; |
---|
| 321 | $objPage->arrProductsClass[$cnt]['cart_no'] = $arrCart[$i]['cart_no']; |
---|
| 322 | $objPage->arrProductsClass[$cnt]['class_name1'] = |
---|
| 323 | isset($arrClassName[$arrData['class_id1']]) |
---|
| 324 | ? $arrClassName[$arrData['class_id1']] : ""; |
---|
| 325 | |
---|
| 326 | $objPage->arrProductsClass[$cnt]['class_name2'] = |
---|
| 327 | isset($arrClassName[$arrData['class_id2']]) |
---|
| 328 | ? $arrClassName[$arrData['class_id2']] : ""; |
---|
| 329 | |
---|
| 330 | $objPage->arrProductsClass[$cnt]['classcategory_name1'] = |
---|
| 331 | $arrClassCatName[$arrData['classcategory_id1']]; |
---|
| 332 | |
---|
| 333 | $objPage->arrProductsClass[$cnt]['classcategory_name2'] = |
---|
| 334 | $arrClassCatName[$arrData['classcategory_id2']]; |
---|
| 335 | |
---|
| 336 | // 画像サイズ |
---|
| 337 | list($image_width, $image_height) = getimagesize(IMAGE_SAVE_DIR . basename($objPage->arrProductsClass[$cnt]["main_image"])); |
---|
| 338 | $objPage->arrProductsClass[$cnt]["tpl_image_width"] = $image_width + 60; |
---|
| 339 | $objPage->arrProductsClass[$cnt]["tpl_image_height"] = $image_height + 80; |
---|
| 340 | |
---|
| 341 | // 価格の登録 |
---|
| 342 | if ($arrData['price02'] != "") { |
---|
| 343 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price02']); |
---|
| 344 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price02']; |
---|
| 345 | } else { |
---|
| 346 | $objCartSess->setProductValue($arrCart[$i]['id'], 'price', $arrData['price01']); |
---|
| 347 | $objPage->arrProductsClass[$cnt]['uniq_price'] = $arrData['price01']; |
---|
| 348 | } |
---|
| 349 | // ポイント付与率の登録 |
---|
| 350 | $objCartSess->setProductValue($arrCart[$i]['id'], 'point_rate', $arrData['point_rate']); |
---|
| 351 | // 商品ごとの合計金額 |
---|
| 352 | $objPage->arrProductsClass[$cnt]['total_pretax'] = $objCartSess->getProductTotal($arrInfo, $arrCart[$i]['id']); |
---|
| 353 | // 送料の合計を計算する |
---|
| 354 | $objPage->tpl_total_deliv_fee+= ($arrData['deliv_fee'] * $arrCart[$i]['quantity']); |
---|
| 355 | $cnt++; |
---|
| 356 | } else { |
---|
| 357 | // DBに商品が見つからない場合はカート商品の削除 |
---|
| 358 | $objCartSess->delProductKey('id', $arrCart[$i]['id']); |
---|
| 359 | } |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | // 全商品合計金額(税込み) |
---|
| 363 | $objPage->tpl_total_pretax = $objCartSess->getAllProductsTotal($arrInfo); |
---|
| 364 | // 全商品合計消費税 |
---|
| 365 | $objPage->tpl_total_tax = $objCartSess->getAllProductsTax($arrInfo); |
---|
| 366 | // 全商品合計ポイント |
---|
| 367 | $objPage->tpl_total_point = $objCartSess->getAllProductsPoint(); |
---|
| 368 | |
---|
| 369 | return $objPage; |
---|
| 370 | } |
---|
| 371 | |
---|
| 372 | /** |
---|
| 373 | * 受注一時テーブルへの書き込み処理を行う. |
---|
| 374 | * |
---|
| 375 | * @param string $uniqid ユニークID |
---|
| 376 | * @param array $sqlval SQLの値の配列 |
---|
| 377 | * @return void |
---|
| 378 | */ |
---|
| 379 | function sfRegistTempOrder($uniqid, $sqlval) { |
---|
| 380 | if($uniqid != "") { |
---|
| 381 | // 既存データのチェック |
---|
| 382 | $objQuery = new SC_Query(); |
---|
| 383 | $where = "order_temp_id = ?"; |
---|
| 384 | $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid)); |
---|
| 385 | // 既存データがない場合 |
---|
| 386 | if ($cnt == 0) { |
---|
| 387 | // 初回書き込み時に会員の登録済み情報を取り込む |
---|
| 388 | $sqlval = $this->sfGetCustomerSqlVal($uniqid, $sqlval); |
---|
| 389 | $sqlval['create_date'] = "now()"; |
---|
| 390 | $objQuery->insert("dtb_order_temp", $sqlval); |
---|
| 391 | } else { |
---|
| 392 | $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); |
---|
| 393 | } |
---|
| 394 | } |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | /** |
---|
| 398 | * 会員情報から SQL文の値を生成する. |
---|
| 399 | * |
---|
| 400 | * @param string $uniqid ユニークID |
---|
| 401 | * @param array $sqlval SQL の値の配列 |
---|
| 402 | * @return array 会員情報を含んだ SQL の値の配列 |
---|
| 403 | */ |
---|
| 404 | function sfGetCustomerSqlVal($uniqid, $sqlval) { |
---|
| 405 | $objCustomer = new SC_Customer(); |
---|
| 406 | // 会員情報登録処理 |
---|
| 407 | if ($objCustomer->isLoginSuccess()) { |
---|
| 408 | // 登録データの作成 |
---|
| 409 | $sqlval['order_temp_id'] = $uniqid; |
---|
| 410 | $sqlval['update_date'] = 'Now()'; |
---|
| 411 | $sqlval['customer_id'] = $objCustomer->getValue('customer_id'); |
---|
| 412 | $sqlval['order_name01'] = $objCustomer->getValue('name01'); |
---|
| 413 | $sqlval['order_name02'] = $objCustomer->getValue('name02'); |
---|
| 414 | $sqlval['order_kana01'] = $objCustomer->getValue('kana01'); |
---|
| 415 | $sqlval['order_kana02'] = $objCustomer->getValue('kana02'); |
---|
| 416 | $sqlval['order_sex'] = $objCustomer->getValue('sex'); |
---|
| 417 | $sqlval['order_zip01'] = $objCustomer->getValue('zip01'); |
---|
| 418 | $sqlval['order_zip02'] = $objCustomer->getValue('zip02'); |
---|
| 419 | $sqlval['order_pref'] = $objCustomer->getValue('pref'); |
---|
| 420 | $sqlval['order_addr01'] = $objCustomer->getValue('addr01'); |
---|
| 421 | $sqlval['order_addr02'] = $objCustomer->getValue('addr02'); |
---|
| 422 | $sqlval['order_tel01'] = $objCustomer->getValue('tel01'); |
---|
| 423 | $sqlval['order_tel02'] = $objCustomer->getValue('tel02'); |
---|
| 424 | $sqlval['order_tel03'] = $objCustomer->getValue('tel03'); |
---|
| 425 | if (defined('MOBILE_SITE')) { |
---|
| 426 | $sqlval['order_email'] = $objCustomer->getValue('email_mobile'); |
---|
| 427 | } else { |
---|
| 428 | $sqlval['order_email'] = $objCustomer->getValue('email'); |
---|
| 429 | } |
---|
| 430 | $sqlval['order_job'] = $objCustomer->getValue('job'); |
---|
| 431 | $sqlval['order_birth'] = $objCustomer->getValue('birth'); |
---|
| 432 | } |
---|
| 433 | return $sqlval; |
---|
| 434 | } |
---|
| 435 | |
---|
| 436 | /** |
---|
| 437 | * 会員編集登録処理を行う. |
---|
| 438 | * |
---|
| 439 | * @param array $array パラメータの配列 |
---|
| 440 | * @param array $arrRegistColumn 登録するカラムの配列 |
---|
| 441 | * @return void |
---|
| 442 | */ |
---|
| 443 | function sfEditCustomerData($array, $arrRegistColumn) { |
---|
| 444 | $objQuery = new SC_Query(); |
---|
| 445 | |
---|
| 446 | foreach ($arrRegistColumn as $data) { |
---|
| 447 | if ($data["column"] != "password") { |
---|
| 448 | if($array[ $data['column'] ] != "") { |
---|
| 449 | $arrRegist[ $data["column"] ] = $array[ $data["column"] ]; |
---|
| 450 | } else { |
---|
| 451 | $arrRegist[ $data['column'] ] = NULL; |
---|
| 452 | } |
---|
| 453 | } |
---|
| 454 | } |
---|
| 455 | if (strlen($array["year"]) > 0 && strlen($array["month"]) > 0 && strlen($array["day"]) > 0) { |
---|
| 456 | $arrRegist["birth"] = $array["year"] ."/". $array["month"] ."/". $array["day"] ." 00:00:00"; |
---|
| 457 | } else { |
---|
| 458 | $arrRegist["birth"] = NULL; |
---|
| 459 | } |
---|
| 460 | |
---|
| 461 | //-- パスワードの更新がある場合は暗号化。(更新がない場合はUPDATE文を構成しない) |
---|
| 462 | if ($array["password"] != DEFAULT_PASSWORD) $arrRegist["password"] = sha1($array["password"] . ":" . AUTH_MAGIC); |
---|
| 463 | $arrRegist["update_date"] = "NOW()"; |
---|
| 464 | |
---|
| 465 | //-- 編集登録実行 |
---|
| 466 | if (defined('MOBILE_SITE')) { |
---|
| 467 | $arrRegist['email_mobile'] = $arrRegist['email']; |
---|
| 468 | unset($arrRegist['email']); |
---|
| 469 | } |
---|
| 470 | $objQuery->begin(); |
---|
| 471 | $objQuery->update("dtb_customer", $arrRegist, "customer_id = ? ", array($array['customer_id'])); |
---|
| 472 | $objQuery->commit(); |
---|
| 473 | } |
---|
| 474 | |
---|
| 475 | /** |
---|
| 476 | * 受注番号、利用ポイント、加算ポイントから最終ポイントを取得する. |
---|
| 477 | * |
---|
| 478 | * @param integer $order_id 受注番号 |
---|
| 479 | * @param integer $use_point 利用ポイント |
---|
| 480 | * @param integer $add_point 加算ポイント |
---|
| 481 | * @return array 最終ポイントの配列 |
---|
| 482 | */ |
---|
| 483 | function sfGetCustomerPoint($order_id, $use_point, $add_point) { |
---|
| 484 | $objQuery = new SC_Query(); |
---|
| 485 | $arrRet = $objQuery->select("customer_id", "dtb_order", "order_id = ?", array($order_id)); |
---|
| 486 | $customer_id = $arrRet[0]['customer_id']; |
---|
| 487 | if($customer_id != "" && $customer_id >= 1) { |
---|
| 488 | $arrRet = $objQuery->select("point", "dtb_customer", "customer_id = ?", array($customer_id)); |
---|
| 489 | $point = $arrRet[0]['point']; |
---|
| 490 | $total_point = $arrRet[0]['point'] - $use_point + $add_point; |
---|
| 491 | } else { |
---|
| 492 | $total_point = ""; |
---|
| 493 | $point = ""; |
---|
| 494 | } |
---|
| 495 | return array($point, $total_point); |
---|
| 496 | } |
---|
| 497 | |
---|
| 498 | /** |
---|
| 499 | * カテゴリツリーの取得を行う. |
---|
| 500 | * |
---|
| 501 | * @param integer $parent_category_id 親カテゴリID |
---|
| 502 | * @param bool $count_check 登録商品数のチェックを行う場合 true |
---|
| 503 | * @return array カテゴリツリーの配列 |
---|
| 504 | */ |
---|
| 505 | function sfGetCatTree($parent_category_id, $count_check = false) { |
---|
| 506 | $objQuery = new SC_Query(); |
---|
| 507 | $col = ""; |
---|
| 508 | $col .= " cat.category_id,"; |
---|
| 509 | $col .= " cat.category_name,"; |
---|
| 510 | $col .= " cat.parent_category_id,"; |
---|
| 511 | $col .= " cat.level,"; |
---|
| 512 | $col .= " cat.rank,"; |
---|
| 513 | $col .= " cat.creator_id,"; |
---|
| 514 | $col .= " cat.create_date,"; |
---|
| 515 | $col .= " cat.update_date,"; |
---|
| 516 | $col .= " cat.del_flg, "; |
---|
| 517 | $col .= " ttl.product_count"; |
---|
| 518 | $from = "dtb_category as cat left join dtb_category_total_count as ttl on ttl.category_id = cat.category_id"; |
---|
| 519 | // 登録商品数のチェック |
---|
| 520 | if($count_check) { |
---|
| 521 | $where = "del_flg = 0 AND product_count > 0"; |
---|
| 522 | } else { |
---|
| 523 | $where = "del_flg = 0"; |
---|
| 524 | } |
---|
| 525 | $objQuery->setoption("ORDER BY rank DESC"); |
---|
| 526 | $arrRet = $objQuery->select($col, $from, $where); |
---|
| 527 | |
---|
| 528 | $arrParentID = $this->sfGetParents($objQuery, 'dtb_category', 'parent_category_id', 'category_id', $parent_category_id); |
---|
| 529 | |
---|
| 530 | foreach($arrRet as $key => $array) { |
---|
| 531 | foreach($arrParentID as $val) { |
---|
| 532 | if($array['category_id'] == $val) { |
---|
| 533 | $arrRet[$key]['display'] = 1; |
---|
| 534 | break; |
---|
| 535 | } |
---|
| 536 | } |
---|
| 537 | } |
---|
| 538 | |
---|
| 539 | return $arrRet; |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | /** |
---|
| 543 | * 親カテゴリーを連結した文字列を取得する. |
---|
| 544 | * |
---|
| 545 | * @param integer $category_id カテゴリID |
---|
| 546 | * @return string 親カテゴリーを連結した文字列 |
---|
| 547 | */ |
---|
| 548 | function sfGetCatCombName($category_id){ |
---|
| 549 | // 商品が属するカテゴリIDを縦に取得 |
---|
| 550 | $objQuery = new SC_Query(); |
---|
| 551 | $arrCatID = sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
---|
| 552 | $ConbName = ""; |
---|
| 553 | |
---|
| 554 | // カテゴリー名称を取得する |
---|
| 555 | foreach($arrCatID as $key => $val){ |
---|
| 556 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
---|
| 557 | $arrVal = array($val); |
---|
| 558 | $CatName = $objQuery->getOne($sql,$arrVal); |
---|
| 559 | $ConbName .= $CatName . ' | '; |
---|
| 560 | } |
---|
| 561 | // 最後の | をカットする |
---|
| 562 | $ConbName = substr_replace($ConbName, "", strlen($ConbName) - 2, 2); |
---|
| 563 | |
---|
| 564 | return $ConbName; |
---|
| 565 | } |
---|
| 566 | |
---|
| 567 | /** |
---|
| 568 | * 指定したカテゴリーIDの大カテゴリーを取得する. |
---|
| 569 | * |
---|
| 570 | * @param integer $category_id カテゴリID |
---|
| 571 | * @return array 指定したカテゴリーIDの大カテゴリー |
---|
| 572 | */ |
---|
| 573 | function sfGetFirstCat($category_id){ |
---|
| 574 | // 商品が属するカテゴリIDを縦に取得 |
---|
| 575 | $objQuery = new SC_Query(); |
---|
| 576 | $arrRet = array(); |
---|
| 577 | $arrCatID = $this->sfGetParents($objQuery, "dtb_category", "parent_category_id", "category_id", $category_id); |
---|
| 578 | $arrRet['id'] = $arrCatID[0]; |
---|
| 579 | |
---|
| 580 | // カテゴリー名称を取得する |
---|
| 581 | $sql = "SELECT category_name FROM dtb_category WHERE category_id = ?"; |
---|
| 582 | $arrVal = array($arrRet['id']); |
---|
| 583 | $arrRet['name'] = $objQuery->getOne($sql,$arrVal); |
---|
| 584 | |
---|
| 585 | return $arrRet; |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | /** |
---|
| 589 | * カテゴリツリーの取得を行う. |
---|
| 590 | * |
---|
| 591 | * $products_check:true商品登録済みのものだけ取得する |
---|
| 592 | * |
---|
| 593 | * @param string $addwhere 追加する WHERE 句 |
---|
| 594 | * @param bool $products_check 商品の存在するカテゴリのみ取得する場合 true |
---|
| 595 | * @param string $head カテゴリ名のプレフィックス文字列 |
---|
| 596 | * @return array カテゴリツリーの配列 |
---|
| 597 | */ |
---|
| 598 | function sfGetCategoryList($addwhere = "", $products_check = false, $head = CATEGORY_HEAD) { |
---|
| 599 | $objQuery = new SC_Query(); |
---|
| 600 | $where = "del_flg = 0"; |
---|
| 601 | |
---|
| 602 | if($addwhere != "") { |
---|
| 603 | $where.= " AND $addwhere"; |
---|
| 604 | } |
---|
| 605 | |
---|
| 606 | $objQuery->setoption("ORDER BY rank DESC"); |
---|
| 607 | |
---|
| 608 | if($products_check) { |
---|
| 609 | $col = "T1.category_id, category_name, level"; |
---|
| 610 | $from = "dtb_category AS T1 LEFT JOIN dtb_category_total_count AS T2 ON T1.category_id = T2.category_id"; |
---|
| 611 | $where .= " AND product_count > 0"; |
---|
| 612 | } else { |
---|
| 613 | $col = "category_id, category_name, level"; |
---|
| 614 | $from = "dtb_category"; |
---|
| 615 | } |
---|
| 616 | |
---|
| 617 | $arrRet = $objQuery->select($col, $from, $where); |
---|
| 618 | |
---|
| 619 | $max = count($arrRet); |
---|
| 620 | for($cnt = 0; $cnt < $max; $cnt++) { |
---|
| 621 | $id = $arrRet[$cnt]['category_id']; |
---|
| 622 | $name = $arrRet[$cnt]['category_name']; |
---|
| 623 | $arrList[$id] = ""; |
---|
| 624 | /* |
---|
| 625 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
---|
| 626 | $arrList[$id].= " "; |
---|
| 627 | } |
---|
| 628 | */ |
---|
| 629 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
---|
| 630 | $arrList[$id].= $head; |
---|
| 631 | } |
---|
| 632 | $arrList[$id].= $name; |
---|
| 633 | } |
---|
| 634 | return $arrList; |
---|
| 635 | } |
---|
| 636 | |
---|
| 637 | /** |
---|
| 638 | * カテゴリーツリーの取得を行う. |
---|
| 639 | * |
---|
| 640 | * 親カテゴリの Value=0 を対象とする |
---|
| 641 | * |
---|
| 642 | * @param bool $parent_zero 親カテゴリの Value=0 の場合 true |
---|
| 643 | * @return array カテゴリツリーの配列 |
---|
| 644 | */ |
---|
| 645 | function sfGetLevelCatList($parent_zero = true) { |
---|
| 646 | $objQuery = new SC_Query(); |
---|
| 647 | $col = "category_id, category_name, level"; |
---|
| 648 | $where = "del_flg = 0"; |
---|
| 649 | $objQuery->setoption("ORDER BY rank DESC"); |
---|
| 650 | $arrRet = $objQuery->select($col, "dtb_category", $where); |
---|
| 651 | $max = count($arrRet); |
---|
| 652 | |
---|
| 653 | for($cnt = 0; $cnt < $max; $cnt++) { |
---|
| 654 | if($parent_zero) { |
---|
| 655 | if($arrRet[$cnt]['level'] == LEVEL_MAX) { |
---|
| 656 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
---|
| 657 | } else { |
---|
| 658 | $arrValue[$cnt] = ""; |
---|
| 659 | } |
---|
| 660 | } else { |
---|
| 661 | $arrValue[$cnt] = $arrRet[$cnt]['category_id']; |
---|
| 662 | } |
---|
| 663 | |
---|
| 664 | $arrOutput[$cnt] = ""; |
---|
| 665 | /* |
---|
| 666 | for($n = 1; $n < $arrRet[$cnt]['level']; $n++) { |
---|
| 667 | $arrOutput[$cnt].= " "; |
---|
| 668 | } |
---|
| 669 | */ |
---|
| 670 | for($cat_cnt = 0; $cat_cnt < $arrRet[$cnt]['level']; $cat_cnt++) { |
---|
| 671 | $arrOutput[$cnt].= CATEGORY_HEAD; |
---|
| 672 | } |
---|
| 673 | $arrOutput[$cnt].= $arrRet[$cnt]['category_name']; |
---|
| 674 | } |
---|
| 675 | return array($arrValue, $arrOutput); |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | /** |
---|
| 679 | * 選択中のカテゴリを取得する. |
---|
| 680 | * |
---|
| 681 | * @param integer $product_id プロダクトID |
---|
| 682 | * @param integer $category_id カテゴリID |
---|
| 683 | * @return integer 選択中のカテゴリID |
---|
| 684 | * |
---|
| 685 | */ |
---|
| 686 | function sfGetCategoryId($product_id, $category_id) { |
---|
| 687 | |
---|
| 688 | if(!$this->g_category_on) { |
---|
| 689 | $this->g_category_on = true; |
---|
| 690 | $category_id = (int) $category_id; |
---|
| 691 | $product_id = (int) $product_id; |
---|
| 692 | if(SC_Utils_Ex::sfIsInt($category_id) && $this->sfIsRecord("dtb_category","category_id", $category_id)) { |
---|
| 693 | $this->g_category_id = $category_id; |
---|
| 694 | } else if (SC_Utils_Ex::sfIsInt($product_id) && $this->sfIsRecord("dtb_products","product_id", $product_id, "status = 1")) { |
---|
| 695 | $objQuery = new SC_Query(); |
---|
| 696 | $where = "product_id = ?"; |
---|
| 697 | $category_id = $objQuery->get("dtb_products", "category_id", $where, array($product_id)); |
---|
| 698 | $this->g_category_id = $category_id; |
---|
| 699 | } else { |
---|
| 700 | // 不正な場合は、0を返す。 |
---|
| 701 | $this->g_category_id = 0; |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | return $this->g_category_id; |
---|
| 705 | } |
---|
| 706 | |
---|
| 707 | /** |
---|
| 708 | * カテゴリ数の登録を行う. |
---|
| 709 | * |
---|
| 710 | * @param SC_Query $objQuery SC_Query インスタンス |
---|
| 711 | * @return void |
---|
| 712 | */ |
---|
| 713 | function sfCategory_Count($objQuery){ |
---|
| 714 | $sql = ""; |
---|
| 715 | |
---|
| 716 | //テーブル内容の削除 |
---|
| 717 | $objQuery->query("DELETE FROM dtb_category_count"); |
---|
| 718 | $objQuery->query("DELETE FROM dtb_category_total_count"); |
---|
| 719 | |
---|
| 720 | //各カテゴリ内の商品数を数えて格納 |
---|
| 721 | $sql = " INSERT INTO dtb_category_count(category_id, product_count, create_date) "; |
---|
| 722 | $sql .= " SELECT T1.category_id, count(T2.category_id), now() FROM dtb_category AS T1 LEFT JOIN dtb_products AS T2 "; |
---|
| 723 | $sql .= " ON T1.category_id = T2.category_id "; |
---|
| 724 | $sql .= " WHERE T2.del_flg = 0 AND T2.status = 1 "; |
---|
| 725 | $sql .= " GROUP BY T1.category_id, T2.category_id "; |
---|
| 726 | $objQuery->query($sql); |
---|
| 727 | |
---|
| 728 | //子カテゴリ内の商品数を集計する |
---|
| 729 | $arrCat = $objQuery->getAll("SELECT * FROM dtb_category"); |
---|
| 730 | |
---|
| 731 | $sql = ""; |
---|
| 732 | foreach($arrCat as $key => $val){ |
---|
| 733 | |
---|
| 734 | // 子ID一覧を取得 |
---|
| 735 | $arrRet = $this->sfGetChildrenArray('dtb_category', 'parent_category_id', 'category_id', $val['category_id']); |
---|
| 736 | $line = SC_Utils_Ex::sfGetCommaList($arrRet); |
---|
| 737 | |
---|
| 738 | $sql = " INSERT INTO dtb_category_total_count(category_id, product_count, create_date) "; |
---|
| 739 | $sql .= " SELECT ?, SUM(product_count), now() FROM dtb_category_count "; |
---|
| 740 | $sql .= " WHERE category_id IN (" . $line . ")"; |
---|
| 741 | |
---|
| 742 | $objQuery->query($sql, array($val['category_id'])); |
---|
| 743 | } |
---|
| 744 | } |
---|
| 745 | |
---|
| 746 | /** |
---|
| 747 | * 子IDの配列を返す. |
---|
| 748 | * |
---|
| 749 | * @param string $table テーブル名 |
---|
| 750 | * @param string $pid_name 親ID名 |
---|
| 751 | * @param string $id_name ID名 |
---|
| 752 | * @param integer $id ID |
---|
| 753 | * @param array 子ID の配列 |
---|
| 754 | */ |
---|
| 755 | function sfGetChildsID($table, $pid_name, $id_name, $id) { |
---|
| 756 | $arrRet = $this->sfGetChildrenArray($table, $pid_name, $id_name, $id); |
---|
| 757 | return $arrRet; |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | /** |
---|
| 761 | * 階層構造のテーブルから子ID配列を取得する. |
---|
| 762 | * |
---|
| 763 | * @param string $table テーブル名 |
---|
| 764 | * @param string $pid_name 親ID名 |
---|
| 765 | * @param string $id_name ID名 |
---|
| 766 | * @param integer $id ID番号 |
---|
| 767 | * @return array 子IDの配列 |
---|
| 768 | */ |
---|
| 769 | function sfGetChildrenArray($table, $pid_name, $id_name, $id) { |
---|
| 770 | $objQuery = new SC_Query(); |
---|
| 771 | $col = $pid_name . "," . $id_name; |
---|
| 772 | $arrData = $objQuery->select($col, $table); |
---|
| 773 | |
---|
| 774 | $arrPID = array(); |
---|
| 775 | $arrPID[] = $id; |
---|
| 776 | $arrChildren = array(); |
---|
| 777 | $arrChildren[] = $id; |
---|
| 778 | |
---|
| 779 | $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID); |
---|
| 780 | |
---|
| 781 | while(count($arrRet) > 0) { |
---|
| 782 | $arrChildren = array_merge($arrChildren, $arrRet); |
---|
| 783 | $arrRet = $this->sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrRet); |
---|
| 784 | } |
---|
| 785 | |
---|
| 786 | return $arrChildren; |
---|
| 787 | } |
---|
| 788 | |
---|
| 789 | /** |
---|
| 790 | * 親ID直下の子IDをすべて取得する. |
---|
| 791 | * |
---|
| 792 | * @param array $arrData 親カテゴリの配列 |
---|
| 793 | * @param string $pid_name 親ID名 |
---|
| 794 | * @param string $id_name ID名 |
---|
| 795 | * @param array $arrPID 親IDの配列 |
---|
| 796 | * @return array 子IDの配列 |
---|
| 797 | */ |
---|
| 798 | function sfGetChildrenArraySub($arrData, $pid_name, $id_name, $arrPID) { |
---|
| 799 | $arrChildren = array(); |
---|
| 800 | $max = count($arrData); |
---|
| 801 | |
---|
| 802 | for($i = 0; $i < $max; $i++) { |
---|
| 803 | foreach($arrPID as $val) { |
---|
| 804 | if($arrData[$i][$pid_name] == $val) { |
---|
| 805 | $arrChildren[] = $arrData[$i][$id_name]; |
---|
| 806 | } |
---|
| 807 | } |
---|
| 808 | } |
---|
| 809 | return $arrChildren; |
---|
| 810 | } |
---|
| 811 | |
---|
| 812 | /** |
---|
| 813 | * 所属するすべての階層の親IDを配列で返す. |
---|
| 814 | * |
---|
| 815 | * @param SC_Query $objQuery SC_Query インスタンス |
---|
| 816 | * @param string $table テーブル名 |
---|
| 817 | * @param string $pid_name 親ID名 |
---|
| 818 | * @param string $id_name ID名 |
---|
| 819 | * @param integer $id ID |
---|
| 820 | * @return array 親IDの配列 |
---|
| 821 | */ |
---|
| 822 | function sfGetParents($objQuery, $table, $pid_name, $id_name, $id) { |
---|
| 823 | $arrRet = $this->sfGetParentsArray($table, $pid_name, $id_name, $id); |
---|
| 824 | // 配列の先頭1つを削除する。 |
---|
| 825 | array_shift($arrRet); |
---|
| 826 | return $arrRet; |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | /** |
---|
| 830 | * 階層構造のテーブルから親ID配列を取得する. |
---|
| 831 | * |
---|
| 832 | * @param string $table テーブル名 |
---|
| 833 | * @param string $pid_name 親ID名 |
---|
| 834 | * @param string $id_name ID名 |
---|
| 835 | * @param integer $id ID |
---|
| 836 | * @return array 親IDの配列 |
---|
| 837 | */ |
---|
| 838 | function sfGetParentsArray($table, $pid_name, $id_name, $id) { |
---|
| 839 | $objQuery = new SC_Query(); |
---|
| 840 | $col = $pid_name . "," . $id_name; |
---|
| 841 | $arrData = $objQuery->select($col, $table); |
---|
| 842 | |
---|
| 843 | $arrParents = array(); |
---|
| 844 | $arrParents[] = $id; |
---|
| 845 | $child = $id; |
---|
| 846 | |
---|
| 847 | $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $child); |
---|
| 848 | |
---|
| 849 | while($ret != "") { |
---|
| 850 | $arrParents[] = $ret; |
---|
| 851 | $ret = SC_Utils::sfGetParentsArraySub($arrData, $pid_name, $id_name, $ret); |
---|
| 852 | } |
---|
| 853 | |
---|
| 854 | $arrParents = array_reverse($arrParents); |
---|
| 855 | |
---|
| 856 | return $arrParents; |
---|
| 857 | } |
---|
| 858 | |
---|
| 859 | /** |
---|
| 860 | * カテゴリから商品を検索する場合のWHERE文と値を返す. |
---|
| 861 | * |
---|
| 862 | * @param integer $category_id カテゴリID |
---|
| 863 | * @return array 商品を検索する場合の配列 |
---|
| 864 | */ |
---|
| 865 | function sfGetCatWhere($category_id) { |
---|
| 866 | // 子カテゴリIDの取得 |
---|
| 867 | $arrRet = $this->sfGetChildsID("dtb_category", "parent_category_id", "category_id", $category_id); |
---|
| 868 | $tmp_where = ""; |
---|
| 869 | foreach ($arrRet as $val) { |
---|
| 870 | if($tmp_where == "") { |
---|
| 871 | $tmp_where.= " category_id IN ( ?"; |
---|
| 872 | } else { |
---|
| 873 | $tmp_where.= ",? "; |
---|
| 874 | } |
---|
| 875 | $arrval[] = $val; |
---|
| 876 | } |
---|
| 877 | $tmp_where.= " ) "; |
---|
| 878 | return array($tmp_where, $arrval); |
---|
| 879 | } |
---|
| 880 | |
---|
| 881 | /** |
---|
| 882 | * 受注一時テーブルから情報を取得する. |
---|
| 883 | * |
---|
| 884 | * @param integer $order_temp_id 受注一時ID |
---|
| 885 | * @return array 受注一時情報の配列 |
---|
| 886 | */ |
---|
| 887 | function sfGetOrderTemp($order_temp_id) { |
---|
| 888 | $objQuery = new SC_Query(); |
---|
| 889 | $where = "order_temp_id = ?"; |
---|
| 890 | $arrRet = $objQuery->select("*", "dtb_order_temp", $where, array($order_temp_id)); |
---|
| 891 | return $arrRet[0]; |
---|
| 892 | } |
---|
| 893 | |
---|
| 894 | /** |
---|
| 895 | * SELECTボックス用リストを作成する. |
---|
| 896 | * |
---|
| 897 | * @param string $table テーブル名 |
---|
| 898 | * @param string $keyname プライマリーキーのカラム名 |
---|
| 899 | * @param string $valname データ内容のカラム名 |
---|
| 900 | * @return array SELECT ボックス用リストの配列 |
---|
| 901 | */ |
---|
| 902 | function sfGetIDValueList($table, $keyname, $valname) { |
---|
| 903 | $objQuery = new SC_Query(); |
---|
| 904 | $col = "$keyname, $valname"; |
---|
| 905 | $objQuery->setwhere("del_flg = 0"); |
---|
| 906 | $objQuery->setorder("rank DESC"); |
---|
| 907 | $arrList = $objQuery->select($col, $table); |
---|
| 908 | $count = count($arrList); |
---|
| 909 | for($cnt = 0; $cnt < $count; $cnt++) { |
---|
| 910 | $key = $arrList[$cnt][$keyname]; |
---|
| 911 | $val = $arrList[$cnt][$valname]; |
---|
| 912 | $arrRet[$key] = $val; |
---|
| 913 | } |
---|
| 914 | return $arrRet; |
---|
| 915 | } |
---|
| 916 | |
---|
| 917 | /** |
---|
| 918 | * ランキングを上げる. |
---|
| 919 | * |
---|
| 920 | * @param string $table テーブル名 |
---|
| 921 | * @param string $colname カラム名 |
---|
| 922 | * @param string|integer $id テーブルのキー |
---|
| 923 | * @param string $andwhere SQL の AND 条件である WHERE 句 |
---|
| 924 | * @return void |
---|
| 925 | */ |
---|
| 926 | function sfRankUp($table, $colname, $id, $andwhere = "") { |
---|
| 927 | $objQuery = new SC_Query(); |
---|
| 928 | $objQuery->begin(); |
---|
| 929 | $where = "$colname = ?"; |
---|
| 930 | if($andwhere != "") { |
---|
| 931 | $where.= " AND $andwhere"; |
---|
| 932 | } |
---|
| 933 | // 対象項目のランクを取得 |
---|
| 934 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
| 935 | // ランクの最大値を取得 |
---|
| 936 | $maxrank = $objQuery->max($table, "rank", $andwhere); |
---|
| 937 | // ランクが最大値よりも小さい場合に実行する。 |
---|
| 938 | if($rank < $maxrank) { |
---|
| 939 | // ランクが一つ上のIDを取得する。 |
---|
| 940 | $where = "rank = ?"; |
---|
| 941 | if($andwhere != "") { |
---|
| 942 | $where.= " AND $andwhere"; |
---|
| 943 | } |
---|
| 944 | $uprank = $rank + 1; |
---|
| 945 | $up_id = $objQuery->get($table, $colname, $where, array($uprank)); |
---|
| 946 | // ランク入れ替えの実行 |
---|
| 947 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
---|
| 948 | $objQuery->exec($sqlup, array($rank + 1, $id)); |
---|
| 949 | $objQuery->exec($sqlup, array($rank, $up_id)); |
---|
| 950 | } |
---|
| 951 | $objQuery->commit(); |
---|
| 952 | } |
---|
| 953 | |
---|
| 954 | /** |
---|
| 955 | * ランキングを下げる. |
---|
| 956 | * |
---|
| 957 | * @param string $table テーブル名 |
---|
| 958 | * @param string $colname カラム名 |
---|
| 959 | * @param string|integer $id テーブルのキー |
---|
| 960 | * @param string $andwhere SQL の AND 条件である WHERE 句 |
---|
| 961 | * @return void |
---|
| 962 | */ |
---|
| 963 | function sfRankDown($table, $colname, $id, $andwhere = "") { |
---|
| 964 | $objQuery = new SC_Query(); |
---|
| 965 | $objQuery->begin(); |
---|
| 966 | $where = "$colname = ?"; |
---|
| 967 | if($andwhere != "") { |
---|
| 968 | $where.= " AND $andwhere"; |
---|
| 969 | } |
---|
| 970 | // 対象項目のランクを取得 |
---|
| 971 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
| 972 | |
---|
| 973 | // ランクが1(最小値)よりも大きい場合に実行する。 |
---|
| 974 | if($rank > 1) { |
---|
| 975 | // ランクが一つ下のIDを取得する。 |
---|
| 976 | $where = "rank = ?"; |
---|
| 977 | if($andwhere != "") { |
---|
| 978 | $where.= " AND $andwhere"; |
---|
| 979 | } |
---|
| 980 | $downrank = $rank - 1; |
---|
| 981 | $down_id = $objQuery->get($table, $colname, $where, array($downrank)); |
---|
| 982 | // ランク入れ替えの実行 |
---|
| 983 | $sqlup = "UPDATE $table SET rank = ?, update_date = Now() WHERE $colname = ?"; |
---|
| 984 | $objQuery->exec($sqlup, array($rank - 1, $id)); |
---|
| 985 | $objQuery->exec($sqlup, array($rank, $down_id)); |
---|
| 986 | } |
---|
| 987 | $objQuery->commit(); |
---|
| 988 | } |
---|
| 989 | |
---|
| 990 | /** |
---|
| 991 | * 指定順位へ移動する. |
---|
| 992 | * |
---|
| 993 | * @param string $tableName テーブル名 |
---|
| 994 | * @param string $keyIdColumn キーを保持するカラム名 |
---|
| 995 | * @param string|integer $keyId キーの値 |
---|
| 996 | * @param integer $pos 指定順位 |
---|
| 997 | * @param string $where SQL の AND 条件である WHERE 句 |
---|
| 998 | * @return void |
---|
| 999 | */ |
---|
| 1000 | function sfMoveRank($tableName, $keyIdColumn, $keyId, $pos, $where = "") { |
---|
| 1001 | $objQuery = new SC_Query(); |
---|
| 1002 | $objQuery->begin(); |
---|
| 1003 | |
---|
| 1004 | // 自身のランクを取得する |
---|
| 1005 | $rank = $objQuery->get($tableName, "rank", "$keyIdColumn = ?", array($keyId)); |
---|
| 1006 | $max = $objQuery->max($tableName, "rank", $where); |
---|
| 1007 | |
---|
| 1008 | // 値の調整(逆順) |
---|
| 1009 | if($pos > $max) { |
---|
| 1010 | $position = 1; |
---|
| 1011 | } else if($pos < 1) { |
---|
| 1012 | $position = $max; |
---|
| 1013 | } else { |
---|
| 1014 | $position = $max - $pos + 1; |
---|
| 1015 | } |
---|
| 1016 | |
---|
| 1017 | if( $position > $rank ) $term = "rank - 1"; //入れ替え先の順位が入れ換え元の順位より大きい場合 |
---|
| 1018 | if( $position < $rank ) $term = "rank + 1"; //入れ替え先の順位が入れ換え元の順位より小さい場合 |
---|
| 1019 | |
---|
| 1020 | // 指定した順位の商品から移動させる商品までのrankを1つずらす |
---|
| 1021 | $sql = "UPDATE $tableName SET rank = $term, update_date = NOW() WHERE rank BETWEEN ? AND ? AND del_flg = 0"; |
---|
| 1022 | if($where != "") { |
---|
| 1023 | $sql.= " AND $where"; |
---|
| 1024 | } |
---|
| 1025 | |
---|
| 1026 | if( $position > $rank ) $objQuery->exec( $sql, array( $rank + 1, $position )); |
---|
| 1027 | if( $position < $rank ) $objQuery->exec( $sql, array( $position, $rank - 1 )); |
---|
| 1028 | |
---|
| 1029 | // 指定した順位へrankを書き換える。 |
---|
| 1030 | $sql = "UPDATE $tableName SET rank = ?, update_date = NOW() WHERE $keyIdColumn = ? AND del_flg = 0 "; |
---|
| 1031 | if($where != "") { |
---|
| 1032 | $sql.= " AND $where"; |
---|
| 1033 | } |
---|
| 1034 | |
---|
| 1035 | $objQuery->exec( $sql, array( $position, $keyId ) ); |
---|
| 1036 | $objQuery->commit(); |
---|
| 1037 | } |
---|
| 1038 | |
---|
| 1039 | /** |
---|
| 1040 | * ランクを含むレコードを削除する. |
---|
| 1041 | * |
---|
| 1042 | * レコードごと削除する場合は、$deleteをtrueにする |
---|
| 1043 | * |
---|
| 1044 | * @param string $table テーブル名 |
---|
| 1045 | * @param string $colname カラム名 |
---|
| 1046 | * @param string|integer $id テーブルのキー |
---|
| 1047 | * @param string $andwhere SQL の AND 条件である WHERE 句 |
---|
| 1048 | * @param bool $delete レコードごと削除する場合 true, |
---|
| 1049 | * レコードごと削除しない場合 false |
---|
| 1050 | * @return void |
---|
| 1051 | */ |
---|
| 1052 | function sfDeleteRankRecord($table, $colname, $id, $andwhere = "", |
---|
| 1053 | $delete = false) { |
---|
| 1054 | $objQuery = new SC_Query(); |
---|
| 1055 | $objQuery->begin(); |
---|
| 1056 | // 削除レコードのランクを取得する。 |
---|
| 1057 | $where = "$colname = ?"; |
---|
| 1058 | if($andwhere != "") { |
---|
| 1059 | $where.= " AND $andwhere"; |
---|
| 1060 | } |
---|
| 1061 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
| 1062 | |
---|
| 1063 | if(!$delete) { |
---|
| 1064 | // ランクを最下位にする、DELフラグON |
---|
| 1065 | $sqlup = "UPDATE $table SET rank = 0, del_flg = 1, update_date = Now() "; |
---|
| 1066 | $sqlup.= "WHERE $colname = ?"; |
---|
| 1067 | // UPDATEの実行 |
---|
| 1068 | $objQuery->exec($sqlup, array($id)); |
---|
| 1069 | } else { |
---|
| 1070 | $objQuery->delete($table, "$colname = ?", array($id)); |
---|
| 1071 | } |
---|
| 1072 | |
---|
| 1073 | // 追加レコードのランクより上のレコードを一つずらす。 |
---|
| 1074 | $where = "rank > ?"; |
---|
| 1075 | if($andwhere != "") { |
---|
| 1076 | $where.= " AND $andwhere"; |
---|
| 1077 | } |
---|
| 1078 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
---|
| 1079 | $objQuery->exec($sqlup, array($rank)); |
---|
| 1080 | $objQuery->commit(); |
---|
| 1081 | } |
---|
| 1082 | |
---|
| 1083 | /** |
---|
| 1084 | * 親IDの配列を元に特定のカラムを取得する. |
---|
| 1085 | * |
---|
| 1086 | * @param SC_Query $objQuery SC_Query インスタンス |
---|
| 1087 | * @param string $table テーブル名 |
---|
| 1088 | * @param string $id_name ID名 |
---|
| 1089 | * @param string $col_name カラム名 |
---|
| 1090 | * @param array $arrId IDの配列 |
---|
| 1091 | * @return array 特定のカラムの配列 |
---|
| 1092 | */ |
---|
| 1093 | function sfGetParentsCol($objQuery, $table, $id_name, $col_name, $arrId ) { |
---|
| 1094 | $col = $col_name; |
---|
| 1095 | $len = count($arrId); |
---|
| 1096 | $where = ""; |
---|
| 1097 | |
---|
| 1098 | for($cnt = 0; $cnt < $len; $cnt++) { |
---|
| 1099 | if($where == "") { |
---|
| 1100 | $where = "$id_name = ?"; |
---|
| 1101 | } else { |
---|
| 1102 | $where.= " OR $id_name = ?"; |
---|
| 1103 | } |
---|
| 1104 | } |
---|
| 1105 | |
---|
| 1106 | $objQuery->setorder("level"); |
---|
| 1107 | $arrRet = $objQuery->select($col, $table, $where, $arrId); |
---|
| 1108 | return $arrRet; |
---|
| 1109 | } |
---|
| 1110 | |
---|
| 1111 | /** |
---|
| 1112 | * カテゴリ変更時の移動処理を行う. |
---|
| 1113 | * |
---|
| 1114 | * @param SC_Query $objQuery SC_Query インスタンス |
---|
| 1115 | * @param string $table テーブル名 |
---|
| 1116 | * @param string $id_name ID名 |
---|
| 1117 | * @param string $cat_name カテゴリ名 |
---|
| 1118 | * @param integer $old_catid 旧カテゴリID |
---|
| 1119 | * @param integer $new_catid 新カテゴリID |
---|
| 1120 | * @param integer $id ID |
---|
| 1121 | * @return void |
---|
| 1122 | */ |
---|
| 1123 | function sfMoveCatRank($objQuery, $table, $id_name, $cat_name, $old_catid, $new_catid, $id) { |
---|
| 1124 | if ($old_catid == $new_catid) { |
---|
| 1125 | return; |
---|
| 1126 | } |
---|
| 1127 | // 旧カテゴリでのランク削除処理 |
---|
| 1128 | // 移動レコードのランクを取得する。 |
---|
| 1129 | $where = "$id_name = ?"; |
---|
| 1130 | $rank = $objQuery->get($table, "rank", $where, array($id)); |
---|
| 1131 | // 削除レコードのランクより上のレコードを一つ下にずらす。 |
---|
| 1132 | $where = "rank > ? AND $cat_name = ?"; |
---|
| 1133 | $sqlup = "UPDATE $table SET rank = (rank - 1) WHERE $where"; |
---|
| 1134 | $objQuery->exec($sqlup, array($rank, $old_catid)); |
---|
| 1135 | // 新カテゴリでの登録処理 |
---|
| 1136 | // 新カテゴリの最大ランクを取得する。 |
---|
| 1137 | $max_rank = $objQuery->max($table, "rank", "$cat_name = ?", array($new_catid)) + 1; |
---|
| 1138 | $where = "$id_name = ?"; |
---|
| 1139 | $sqlup = "UPDATE $table SET rank = ? WHERE $where"; |
---|
| 1140 | $objQuery->exec($sqlup, array($max_rank, $id)); |
---|
| 1141 | } |
---|
| 1142 | |
---|
| 1143 | /** |
---|
| 1144 | * 配送時間を取得する. |
---|
| 1145 | * |
---|
| 1146 | * @param integer $payment_id 支払い方法ID |
---|
| 1147 | * @return array 配送時間の配列 |
---|
| 1148 | */ |
---|
| 1149 | function sfGetDelivTime($payment_id = "") { |
---|
| 1150 | $objQuery = new SC_Query(); |
---|
| 1151 | |
---|
| 1152 | $deliv_id = ""; |
---|
| 1153 | $arrRet = array(); |
---|
| 1154 | |
---|
| 1155 | if($payment_id != "") { |
---|
| 1156 | $where = "del_flg = 0 AND payment_id = ?"; |
---|
| 1157 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
---|
| 1158 | $deliv_id = $arrRet[0]['deliv_id']; |
---|
| 1159 | } |
---|
| 1160 | |
---|
| 1161 | if($deliv_id != "") { |
---|
| 1162 | $objQuery->setorder("time_id"); |
---|
| 1163 | $where = "deliv_id = ?"; |
---|
| 1164 | $arrRet= $objQuery->select("time_id, deliv_time", "dtb_delivtime", $where, array($deliv_id)); |
---|
| 1165 | } |
---|
| 1166 | |
---|
| 1167 | return $arrRet; |
---|
| 1168 | } |
---|
| 1169 | |
---|
| 1170 | /** |
---|
| 1171 | * 都道府県、支払い方法から配送料金を取得する. |
---|
| 1172 | * |
---|
| 1173 | * @param integer $pref 都道府県ID |
---|
| 1174 | * @param integer $payment_id 支払い方法ID |
---|
| 1175 | * @return string 指定の都道府県, 支払い方法の配送料金 |
---|
| 1176 | */ |
---|
| 1177 | function sfGetDelivFee($pref, $payment_id = "") { |
---|
| 1178 | $objQuery = new SC_Query(); |
---|
| 1179 | |
---|
| 1180 | $deliv_id = ""; |
---|
| 1181 | |
---|
| 1182 | // 支払い方法が指定されている場合は、対応した配送業者を取得する |
---|
| 1183 | if($payment_id != "") { |
---|
| 1184 | $where = "del_flg = 0 AND payment_id = ?"; |
---|
| 1185 | $arrRet = $objQuery->select("deliv_id", "dtb_payment", $where, array($payment_id)); |
---|
| 1186 | $deliv_id = $arrRet[0]['deliv_id']; |
---|
| 1187 | // 支払い方法が指定されていない場合は、先頭の配送業者を取得する |
---|
| 1188 | } else { |
---|
| 1189 | $where = "del_flg = 0"; |
---|
| 1190 | $objQuery->setOrder("rank DESC"); |
---|
| 1191 | $objQuery->setLimitOffset(1); |
---|
| 1192 | $arrRet = $objQuery->select("deliv_id", "dtb_deliv", $where); |
---|
| 1193 | $deliv_id = $arrRet[0]['deliv_id']; |
---|
| 1194 | } |
---|
| 1195 | |
---|
| 1196 | // 配送業者から配送料を取得 |
---|
| 1197 | if($deliv_id != "") { |
---|
| 1198 | |
---|
| 1199 | // 都道府県が指定されていない場合は、東京都の番号を指定しておく |
---|
| 1200 | if($pref == "") { |
---|
| 1201 | $pref = 13; |
---|
| 1202 | } |
---|
| 1203 | |
---|
| 1204 | $objQuery = new SC_Query(); |
---|
| 1205 | $where = "deliv_id = ? AND pref = ?"; |
---|
| 1206 | $arrRet= $objQuery->select("fee", "dtb_delivfee", $where, array($deliv_id, $pref)); |
---|
| 1207 | } |
---|
| 1208 | return $arrRet[0]['fee']; |
---|
| 1209 | } |
---|
| 1210 | |
---|
| 1211 | /** |
---|
| 1212 | * 集計情報を元に最終計算を行う. |
---|
| 1213 | * |
---|
| 1214 | * @param array $arrData 各種情報 |
---|
| 1215 | * @param LC_Page $objPage LC_Page インスタンス |
---|
| 1216 | * @param SC_CartSession $objCartSess SC_CartSession インスタンス |
---|
| 1217 | * @param array $arrInfo 店舗情報の配列 |
---|
| 1218 | * @param SC_Customer $objCustomer SC_Customer インスタンス |
---|
| 1219 | * @return array 最終計算後の配列 |
---|
| 1220 | */ |
---|
| 1221 | function sfTotalConfirm($arrData, &$objPage, &$objCartSess, $arrInfo, $objCustomer = "") { |
---|
| 1222 | // 未定義変数を定義 |
---|
| 1223 | if (!isset($arrData['deliv_pref'])) $arrData['deliv_pref'] = ""; |
---|
| 1224 | if (!isset($arrData['payment_id'])) $arrData['payment_id'] = ""; |
---|
| 1225 | if (!isset($arrData['charge'])) $arrData['charge'] = ""; |
---|
| 1226 | if (!isset($arrData['use_point'])) $arrData['use_point'] = ""; |
---|
| 1227 | |
---|
| 1228 | // 商品の合計個数 |
---|
| 1229 | $total_quantity = $objCartSess->getTotalQuantity(true); |
---|
| 1230 | |
---|
| 1231 | // 税金の取得 |
---|
| 1232 | $arrData['tax'] = $objPage->tpl_total_tax; |
---|
| 1233 | // 小計の取得 |
---|
| 1234 | $arrData['subtotal'] = $objPage->tpl_total_pretax; |
---|
| 1235 | |
---|
| 1236 | // 合計送料の取得 |
---|
| 1237 | $arrData['deliv_fee'] = 0; |
---|
| 1238 | |
---|
| 1239 | // 商品ごとの送料が有効の場合 |
---|
| 1240 | if (OPTION_PRODUCT_DELIV_FEE == 1) { |
---|
| 1241 | $arrData['deliv_fee']+= $objCartSess->getAllProductsDelivFee(); |
---|
| 1242 | } |
---|
| 1243 | |
---|
| 1244 | // 配送業者の送料が有効の場合 |
---|
| 1245 | if (OPTION_DELIV_FEE == 1) { |
---|
| 1246 | // 送料の合計を計算する |
---|
| 1247 | $arrData['deliv_fee'] |
---|
| 1248 | += $this->sfGetDelivFee($arrData['deliv_pref'], |
---|
| 1249 | $arrData['payment_id']); |
---|
| 1250 | |
---|
| 1251 | } |
---|
| 1252 | |
---|
| 1253 | // 送料無料の購入数が設定されている場合 |
---|
| 1254 | if(DELIV_FREE_AMOUNT > 0) { |
---|
| 1255 | if($total_quantity >= DELIV_FREE_AMOUNT) { |
---|
| 1256 | $arrData['deliv_fee'] = 0; |
---|
| 1257 | } |
---|
| 1258 | } |
---|
| 1259 | |
---|
| 1260 | // 送料無料条件が設定されている場合 |
---|
| 1261 | if($arrInfo['free_rule'] > 0) { |
---|
| 1262 | // 小計が無料条件を超えている場合 |
---|
| 1263 | if($arrData['subtotal'] >= $arrInfo['free_rule']) { |
---|
| 1264 | $arrData['deliv_fee'] = 0; |
---|
| 1265 | } |
---|
| 1266 | } |
---|
| 1267 | |
---|
| 1268 | // 合計の計算 |
---|
| 1269 | $arrData['total'] = $objPage->tpl_total_pretax; // 商品合計 |
---|
| 1270 | $arrData['total']+= $arrData['deliv_fee']; // 送料 |
---|
| 1271 | $arrData['total']+= $arrData['charge']; // 手数料 |
---|
| 1272 | // お支払い合計 |
---|
| 1273 | $arrData['payment_total'] = $arrData['total'] - ($arrData['use_point'] * POINT_VALUE); |
---|
| 1274 | // 加算ポイントの計算 |
---|
| 1275 | $arrData['add_point'] = SC_Utils::sfGetAddPoint($objPage->tpl_total_point, $arrData['use_point'], $arrInfo); |
---|
| 1276 | |
---|
| 1277 | if($objCustomer != "") { |
---|
| 1278 | // 誕生日月であった場合 |
---|
| 1279 | if($objCustomer->isBirthMonth()) { |
---|
| 1280 | $arrData['birth_point'] = BIRTH_MONTH_POINT; |
---|
| 1281 | $arrData['add_point'] += $arrData['birth_point']; |
---|
| 1282 | } |
---|
| 1283 | } |
---|
| 1284 | |
---|
| 1285 | if($arrData['add_point'] < 0) { |
---|
| 1286 | $arrData['add_point'] = 0; |
---|
| 1287 | } |
---|
| 1288 | return $arrData; |
---|
| 1289 | } |
---|
| 1290 | |
---|
| 1291 | /** |
---|
| 1292 | * レコードの存在チェックを行う. |
---|
| 1293 | * |
---|
| 1294 | * @param string $table テーブル名 |
---|
| 1295 | * @param string $col カラム名 |
---|
| 1296 | * @param array $arrval 要素の配列 |
---|
| 1297 | * @param array $addwhere SQL の AND 条件である WHERE 句 |
---|
| 1298 | * @return bool レコードが存在する場合 true |
---|
| 1299 | */ |
---|
| 1300 | function sfIsRecord($table, $col, $arrval, $addwhere = "") { |
---|
| 1301 | $objQuery = new SC_Query(); |
---|
| 1302 | $arrCol = split("[, ]", $col); |
---|
| 1303 | |
---|
| 1304 | $where = "del_flg = 0"; |
---|
| 1305 | |
---|
| 1306 | if($addwhere != "") { |
---|
| 1307 | $where.= " AND $addwhere"; |
---|
| 1308 | } |
---|
| 1309 | |
---|
| 1310 | foreach($arrCol as $val) { |
---|
| 1311 | if($val != "") { |
---|
| 1312 | if($where == "") { |
---|
| 1313 | $where = "$val = ?"; |
---|
| 1314 | } else { |
---|
| 1315 | $where.= " AND $val = ?"; |
---|
| 1316 | } |
---|
| 1317 | } |
---|
| 1318 | } |
---|
| 1319 | $ret = $objQuery->get($table, $col, $where, $arrval); |
---|
| 1320 | |
---|
| 1321 | if($ret != "") { |
---|
| 1322 | return true; |
---|
| 1323 | } |
---|
| 1324 | return false; |
---|
| 1325 | } |
---|
| 1326 | |
---|
| 1327 | } |
---|
| 1328 | ?> |
---|