/** * 規格データをコピーする * * @param array $arrList フォーム入力パラメーター配列 * @param SC_Query $objQuery SC_Queryインスタンス * @return boolean エラーフラグ */ public function lfCopyProductClass($arrList, &$objQuery) { // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得) $col = '*'; $table = 'dtb_products_class'; $where = 'product_id = ?'; $arrProductClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id'])); //トランザクション開始 $objQuery->begin(); $err_flag = false; //非編集項目は複製、編集項目は上書きして登録 foreach ($arrProductClass as $records) { foreach ($records as $key => $value) { if (isset($arrList[$key])) { switch ($key) { case 'stock_unlimited': $records[$key] = (int) $arrList[$key]; break; default: $records[$key] = $arrList[$key]; break; } } } $records['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); $records['update_date'] = 'CURRENT_TIMESTAMP'; $records['create_date'] = 'CURRENT_TIMESTAMP'; $objQuery->insert($table, $records); //エラー発生時は中断 if ($objQuery->isError()) { $err_flag = true; continue; } } //トランザクション終了 if ($err_flag) { $objQuery->rollback(); } else { $objQuery->commit(); } return !$err_flag; }
function lfSetNewAddr($uniqid, $customer_id) { $objQuery = new SC_Query(); $diff = false; $find_same = false; $col = "deliv_name01,deliv_name02,deliv_kana01,deliv_kana02,deliv_tel01,deliv_tel02,deliv_tel03,deliv_zip01,deliv_zip02,deliv_pref,deliv_addr01,deliv_addr02"; $where = "order_temp_id = ?"; $arrRet = $objQuery->select($col, "dtb_order_temp", $where, array($uniqid)); // 要素名のdeliv_を削除する。 foreach ($arrRet[0] as $key => $val) { $keyname = ereg_replace("^deliv_", "", $key); $arrNew[$keyname] = $val; } // 会員情報テーブルとの比較 $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02"; $where = "customer_id = ?"; $arrCustomerAddr = $objQuery->select($col, "dtb_customer", $where, array($customer_id)); // 会員情報の住所と異なる場合 if ($arrNew != $arrCustomerAddr[0]) { // 別のお届け先テーブルの住所と比較する $col = "name01,name02,kana01,kana02,tel01,tel02,tel03,zip01,zip02,pref,addr01,addr02"; $where = "customer_id = ?"; $arrOtherAddr = $objQuery->select($col, "dtb_other_deliv", $where, array($customer_id)); foreach ($arrOtherAddr as $arrval) { if ($arrNew == $arrval) { // すでに同じ住所が登録されている $find_same = true; } } if (!$find_same) { $diff = true; } } // 新しいお届け先が登録済みのものと異なる場合は別のお届け先テーブルに登録する if ($diff) { $sqlval = $arrNew; $sqlval['customer_id'] = $customer_id; $objQuery->insert("dtb_other_deliv", $sqlval); } }
function lfInsertProductClass($arrList, $product_id) { $objQuery = new SC_Query(); $objQuery->begin(); // 既存規格の削除 $where = "product_id = ?"; $objQuery->delete("dtb_products_class", $where, array($product_id)); $cnt = 1; // すべての規格を登録する。 while ($arrList["classcategory_id1:" . $cnt] != "") { if ($arrList["check:" . $cnt] == 1) { $sqlval = array(); $sqlval['product_id'] = $product_id; $sqlval['classcategory_id1'] = $arrList["classcategory_id1:" . $cnt]; $sqlval['classcategory_id2'] = $arrList["classcategory_id2:" . $cnt]; if (strlen($arrList["product_class_id:" . $cnt]) > 0) { $sqlval['product_class_id'] = $arrList["product_class_id:" . $cnt]; } $sqlval['product_code'] = $arrList["product_code:" . $cnt]; $sqlval['stock'] = $arrList["stock:" . $cnt]; $sqlval['stock_unlimited'] = $arrList["stock_unlimited:" . $cnt]; $sqlval['price01'] = $arrList['price01:' . $cnt]; $sqlval['price02'] = $arrList['price02:' . $cnt]; $sqlval['creator_id'] = $_SESSION['member_id']; $sqlval['create_date'] = "now()"; $sqlval['update_date'] = "now()"; // INSERTの実行 $objQuery->insert("dtb_products_class", $sqlval); } $cnt++; } $objQuery->commit(); }
/** * CSVファイルからインサート実行. * * @param SC_Query $objQuery * @param string $dir * @param string $mode * @return boolean */ public function lfExeInsertSQL(&$objQuery, $dir, $mode) { $tbl_flg = false; $col_flg = false; $ret = true; $pagelayout_flg = false; $arrVal = array(); $arrCol = array(); $arrAllTableList = $objQuery->listTables(); $objDir = dir($dir); while (false !== ($file_name = $objDir->read())) { if (!preg_match('/^((dtb|mtb|plg)_(\\w+))\\.csv$/', $file_name, $matches)) { continue; } $file_path = $dir . $file_name; $table = $matches[1]; // テーブル存在チェック if (!in_array($table, $arrAllTableList)) { if ($mode === 'restore_config') { continue; } return false; } // csvファイルからデータの取得 $fp = fopen($file_path, 'r'); if ($fp === false) { trigger_error($file_name . ' のファイルオープンに失敗しました。', E_USER_ERROR); } GC_Utils_Ex::gfPrintLog('リストア実行: ' . $table); $objQuery->delete($table); $line = 0; $arrColName = array(); while (!feof($fp)) { $line++; $arrCsvLine = fgetcsv($fp, 1024 * 1024); // 1行目: 列名 if ($line === 1) { $arrColName = $arrCsvLine; continue; } // 空行を無視 // false との比較は PHP 5.2.x Windows バグ対応 // 参考: http://www.php.net/manual/ja/function.fgetcsv.php#98502 if ($arrCsvLine === array(null) || $arrCsvLine === false) { continue; } $arrVal = array_combine($arrColName, $arrCsvLine); $objQuery->insert($table, $arrVal); SC_Utils_Ex::extendTimeOut(); } fclose($fp); } return $ret; }
/** * カテゴリ数の登録を行う. * * * @param SC_Query $objQuery SC_Query インスタンス * @param boolean $is_force_all_count 全カテゴリの集計を強制する場合 true * @return void */ public function sfCountCategory($objQuery = NULL, $is_force_all_count = false) { $objProduct = new SC_Product_Ex(); if ($objQuery == NULL) { $objQuery =& SC_Query_Ex::getSingletonInstance(); } $is_out_trans = false; if (!$objQuery->inTransaction()) { $objQuery->begin(); $is_out_trans = true; } //共通のfrom/where文の構築 $sql_where = SC_Product_Ex::getProductDispConditions('alldtl'); // 在庫無し商品の非表示 if (NOSTOCK_HIDDEN) { $where_products_class = '(stock >= 1 OR stock_unlimited = 1)'; $from = $objProduct->alldtlSQL($where_products_class); } else { $from = 'dtb_products as alldtl'; } //dtb_category_countの構成 // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを含まない。 //まずテーブル内容の元を取得 if (!$is_force_all_count) { $arrCategoryCountOld = $objQuery->select('category_id,product_count', 'dtb_category_count'); } else { $arrCategoryCountOld = array(); } //各カテゴリ内の商品数を数えて取得 $sql = <<<__EOS__ SELECT T1.category_id, count(T2.category_id) as product_count FROM dtb_category AS T1 LEFT JOIN dtb_product_categories AS T2 ON T1.category_id = T2.category_id LEFT JOIN {$from} ON T2.product_id = alldtl.product_id WHERE {$sql_where} GROUP BY T1.category_id, T2.category_id __EOS__; $arrCategoryCountNew = $objQuery->getAll($sql); // 各カテゴリに所属する商品の数を集計。集計対象には子カテゴリを「含む」。 //差分を取得して、更新対象カテゴリだけを確認する。 //各カテゴリ毎のデータ値において以前との差を見る //古いデータの構造入れ替え $arrOld = array(); foreach ($arrCategoryCountOld as $item) { $arrOld[$item['category_id']] = $item['product_count']; } //新しいデータの構造入れ替え $arrNew = array(); foreach ($arrCategoryCountNew as $item) { $arrNew[$item['category_id']] = $item['product_count']; } unset($arrCategoryCountOld); unset($arrCategoryCountNew); $arrDiffCategory_id = array(); //新しいカテゴリ一覧から見て商品数が異なるデータが無いか確認 foreach ($arrNew as $cid => $count) { if ($arrOld[$cid] != $count) { $arrDiffCategory_id[] = $cid; } } //削除カテゴリを想定して、古いカテゴリ一覧から見て商品数が異なるデータが無いか確認。 foreach ($arrOld as $cid => $count) { if ($arrNew[$cid] != $count && $count > 0) { $arrDiffCategory_id[] = $cid; } } //対象IDが無ければ終了 if (count($arrDiffCategory_id) == 0) { if ($is_out_trans) { $objQuery->commit(); } return; } //差分対象カテゴリIDの重複を除去 $arrDiffCategory_id = array_unique($arrDiffCategory_id); //dtb_category_countの更新 差分のあったカテゴリだけ更新する。 foreach ($arrDiffCategory_id as $cid) { $sqlval = array(); $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; $sqlval['product_count'] = (string) $arrNew[$cid]; if ($sqlval['product_count'] == '') { $sqlval['product_count'] = (string) '0'; } if (isset($arrOld[$cid])) { $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid)); } else { if ($is_force_all_count) { $ret = $objQuery->update('dtb_category_count', $sqlval, 'category_id = ?', array($cid)); if ($ret > 0) { continue; } } $sqlval['category_id'] = $cid; $objQuery->insert('dtb_category_count', $sqlval); } } unset($arrOld); unset($arrNew); //差分があったIDとその親カテゴリIDのリストを取得する $arrTgtCategory_id = array(); foreach ($arrDiffCategory_id as $parent_category_id) { $arrTgtCategory_id[] = $parent_category_id; $arrParentID = $this->sfGetParents('dtb_category', 'parent_category_id', 'category_id', $parent_category_id); $arrTgtCategory_id = array_unique(array_merge($arrTgtCategory_id, $arrParentID)); } unset($arrDiffCategory_id); //dtb_category_total_count 集計処理開始 //更新対象カテゴリIDだけ集計しなおす。 $arrUpdateData = array(); $where_products_class = ''; if (NOSTOCK_HIDDEN) { $where_products_class .= '(stock >= 1 OR stock_unlimited = 1)'; } $from = $objProduct->alldtlSQL($where_products_class); foreach ($arrTgtCategory_id as $category_id) { $arrWhereVal = array(); list($tmp_where, $arrTmpVal) = $this->sfGetCatWhere($category_id); if ($tmp_where != '') { $sql_where_product_ids = 'product_id IN (SELECT product_id FROM dtb_product_categories WHERE ' . $tmp_where . ')'; $arrWhereVal = $arrTmpVal; } else { $sql_where_product_ids = '0<>0'; // 一致させない } $where = "({$sql_where}) AND ({$sql_where_product_ids})"; $arrUpdateData[$category_id] = $objQuery->count($from, $where, $arrWhereVal); } unset($arrTgtCategory_id); // 更新対象だけを更新。 foreach ($arrUpdateData as $cid => $count) { $sqlval = array(); $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; $sqlval['product_count'] = $count; if ($sqlval['product_count'] == '') { $sqlval['product_count'] = (string) '0'; } $ret = $objQuery->update('dtb_category_total_count', $sqlval, 'category_id = ?', array($cid)); if (!$ret) { $sqlval['category_id'] = $cid; $objQuery->insert('dtb_category_total_count', $sqlval); } } // トランザクション終了処理 if ($is_out_trans) { $objQuery->commit(); } }
function lfInsertData() { // 入力データを渡す。 $sqlval = $this->objFormParam->getHashArray(); $sqlval['update_date'] = 'Now()'; $objQuery = new SC_Query(); // INSERTの実行 $ret = $objQuery->insert("dtb_baseinfo", $sqlval); }
/** * カテゴリ登録を行う. * * @param SC_Query $objQuery SC_Queryインスタンス * @param string|integer $line 処理中の行数 * @return void */ function lfRegistProduct($objQuery, $line = "") { $objDb = new SC_Helper_DB_Ex(); $arrRet = $this->objFormParam->getHashArray(); //カテゴリID if ($arrRet['category_id'] == 0) { $category_id = $objQuery->max("dtb_category", "category_id") + 1; $sqlval['category_id'] = $category_id; $update = false; } else { $sqlval['category_id'] = $arrRet['category_id']; $update = true; } // カテゴリ名 $sqlval['category_name'] = $arrRet['category_name']; // 親カテゴリID、レベル if ($arrRet['parent_category_id'] == 0) { $sqlval['parent_category_id'] = "0"; $sqlval['level'] = 1; } else { $sqlval['parent_category_id'] = $arrRet['parent_category_id']; $parent_level = $objQuery->get("dtb_category", "level", "category_id = ?", array($sqlval['parent_category_id'])); $sqlval['level'] = $parent_level + 1; } // その他 $time = date("Y-m-d H:i:s"); if ($line != "") { $microtime = sprintf("%06d", $line); $time .= ".{$microtime}"; } $sqlval['update_date'] = $time; $sqlval['creator_id'] = $_SESSION['member_id']; // 更新 if ($update) { echo "UPDATE "; $where = "category_id = ?"; $objQuery->update("dtb_category", $sqlval, $where, array($sqlval['category_id'])); // 新規登録 } else { echo "INSERT "; $sqlval['create_date'] = $time; // ランク if ($sqlval['parent_category_id'] == 0) { // ROOT階層で最大のランクを取得する。 $where = "parent_category_id = ?"; $sqlval['rank'] = $objQuery->max("dtb_category", "rank", $where, array($sqlval['parent_category_id'])) + 1; } else { // 親のランクを自分のランクとする。 $where = "category_id = ?"; $sqlval['rank'] = $objQuery->get("dtb_category", "rank", $where, array($sqlval['parent_category_id'])); // 追加レコードのランク以上のレコードを一つあげる。 $sqlup = "UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?"; $objQuery->exec($sqlup, array($sqlval['rank'])); } $objQuery->insert("dtb_category", $sqlval); } }
/** * Page のプロセス. * * @return void */ function process() { $objQuery = new SC_Query(); $objSess = new SC_Session(); // 認証可否の判定 SC_Utils_Ex::sfIsSuccess($objSess); $fp = fopen(ZIP_CSV_FILE_PATH, "r"); $img_path = USER_URL . "packages/" . TEMPLATE_NAME . "/img/"; // 一部のIEは256バイト以上受け取ってから表示を開始する。 for ($i = 0; $i < 256; $i++) { print " "; } print "\n"; $this->myFlush(); if (!$fp) { SC_Utils_Ex::sfErrorHeader(">> " . ZIP_CSV_FILE_PATH . "の取得に失敗しました。"); } else { print "<img src='" . $img_path . "install/main_w.jpg'><br>"; $this->myFlush(); // CSVの件数を数える $line = 0; while (!feof($fp)) { fgets($fp, ZIP_CSV_LINE_MAX); $line++; } print "<img src='" . $img_path . "install/space_w.gif'>"; $this->myFlush(); // ファイルポインタを戻す fseek($fp, 0); // 画像を一個表示する件数を求める。 $disp_line = intval($line / IMAGE_MAX); // 既に書き込まれたデータを数える $end_cnt = $objQuery->count("mtb_zip"); $cnt = 1; $img_cnt = 0; while (!feof($fp)) { $arrCSV = fgetcsv($fp, ZIP_CSV_LINE_MAX); // すでに書き込まれたデータを飛ばす。 if ($cnt > $end_cnt) { $sqlval['code'] = $arrCSV[0]; $sqlval['old_zipcode'] = $arrCSV[1]; $sqlval['zipcode'] = $arrCSV[2]; $sqlval['state_kana'] = $arrCSV[3]; $sqlval['city_kana'] = $arrCSV[4]; $sqlval['town_kana'] = $arrCSV[5]; $sqlval['state'] = $arrCSV[6]; $sqlval['city'] = $arrCSV[7]; $sqlval['town'] = $arrCSV[8]; $sqlval['flg1'] = $arrCSV[9]; $sqlval['flg2'] = $arrCSV[10]; $sqlval['flg3'] = $arrCSV[11]; $sqlval['flg4'] = $arrCSV[12]; $sqlval['flg5'] = $arrCSV[13]; $sqlval['flg6'] = $arrCSV[14]; $objQuery->insert("mtb_zip", $sqlval); } $cnt++; // $disp_line件ごとに進捗表示する if ($cnt % $disp_line == 0 && $img_cnt < IMAGE_MAX) { print "<img src='" . $img_path . "install/graph_1_w.gif'>"; $this->myFlush(); $img_cnt++; } } fclose($fp); print "<img src='" . $img_path . "install/space_w.gif'><br>\n"; print "<table width='700' height='50' border='0' cellpadding='0' cellspacing='0' bgcolor='#494E5F'>\n"; print "<tr>\n"; print "<td align='center'><a href='javascript:window.close()'><img src='" . $img_path . "install/close.gif' alt='CLOSE' width='85' height='22' border='0' /></a></td>\n"; print "</tr>\n"; print "</table>\n"; } }
function lfInsertClass($arrData) { $objQuery = new SC_Query(); // INSERTする値を作成する。 $sqlval['name'] = $arrData['name']; $sqlval['creator_id'] = $_SESSION['member_id']; $sqlval['rank'] = $objQuery->max("dtb_class", "rank") + 1; $sqlval['create_date'] = "now()"; $sqlval['update_date'] = "now()"; // INSERTの実行 $ret = $objQuery->insert("dtb_class", $sqlval); return $ret; }
/** * 配送情報を登録する * * @return $deliv_id */ function lfRegistData() { $arrRet = $this->objFormParam->getHashArray(); $objQuery = new SC_Query(); $objQuery->begin(); // 入力データを渡す。 $sqlval['name'] = $arrRet['name']; $sqlval['service_name'] = $arrRet['service_name']; $sqlval['confirm_url'] = $arrRet['confirm_url']; $sqlval['creator_id'] = $_SESSION['member_id']; $sqlval['update_date'] = 'Now()'; // deliv_id が決まっていた場合 if ($_POST['deliv_id'] != "") { $deliv_id = $_POST['deliv_id']; $where = "deliv_id = ?"; $objQuery->update("dtb_deliv", $sqlval, $where, array($deliv_id)); // 配送時間の登録 $table = "dtb_delivtime"; $where = "deliv_id = ? AND time_id = ?"; for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) { $sqlval = array(); $keyname = "deliv_time" . $cnt; $arrval = array($deliv_id, $cnt * $deliv_id); // 既存データの有無を確認 $curData = $objQuery->select("*", $table, $where, $arrval); if (strcmp($arrRet[$keyname], "") != 0) { $sqlval['deliv_time'] = $arrRet[$keyname]; // 入力が空ではなく、DBに情報があれば更新 if (count($curData)) { $objQuery->update($table, $sqlval, $where, $arrval); } else { $sqlval['deliv_id'] = $deliv_id; $sqlval['time_id'] = $cnt * $deliv_id; $objQuery->insert($table, $sqlval); } } else { if (count($curData)) { $objQuery->delete($table, $where, $arrval); } } } // 配送料の登録 if (INPUT_DELIV_FEE) { for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) { $keyname = "fee" . $cnt; if (strcmp($arrRet[$keyname], "") != 0) { $sqlval = array('fee' => $arrRet[$keyname]); $objQuery->update("dtb_delivfee", $sqlval, "deliv_id = ? AND pref = ?", array($deliv_id, $cnt)); } } } } else { // 登録する配送業者IDの取得 if (DB_TYPE == "pgsql") { $deliv_id = $objQuery->nextval('dtb_deliv', 'deliv_id'); $sqlval['deliv_id'] = $deliv_id; } $sqlval['rank'] = $objQuery->max("dtb_deliv", "rank") + 1; $sqlval['create_date'] = 'Now()'; // INSERTの実行 $objQuery->insert("dtb_deliv", $sqlval); if (DB_TYPE == "mysql") { $deliv_id = $objQuery->nextval('dtb_deliv', 'deliv_id'); } $sqlval = array(); // 配送時間の設定 for ($cnt = 1; $cnt <= DELIVTIME_MAX; $cnt++) { $keyname = "deliv_time{$cnt}"; if ($arrRet[$keyname] != "") { $sqlval['deliv_id'] = $deliv_id; $sqlval['time_id'] = $cnt * $deliv_id; $sqlval['deliv_time'] = $arrRet[$keyname]; // INSERTの実行 $objQuery->insert("dtb_delivtime", $sqlval); } } if (INPUT_DELIV_FEE) { $sqlval = array(); // 配送料金の設定 for ($cnt = 1; $cnt <= DELIVFEE_MAX; $cnt++) { $keyname = "fee{$cnt}"; if ($arrRet[$keyname] != "") { $sqlval['deliv_id'] = $deliv_id; $sqlval['fee'] = $arrRet[$keyname]; $sqlval['pref'] = $cnt; // INSERTの実行 $objQuery->insert("dtb_delivfee", $sqlval); } } } } $objQuery->commit(); return $deliv_id; }
/** * DBへ入力内容を登録する. * * @param array $arrSettingsData オーナーズストア設定の連想配列 * @return void */ function registerOwnersStoreSettings($arrSettingsData) { $table = 'dtb_ownersstore_settings'; $objQuery = new SC_Query(); $count = $objQuery->count($table); if ($count) { $objQuery->update($table, $arrSettingsData); } else { $objQuery->insert($table, $arrSettingsData); } }
function lfDispComplete($objPage) { global $objWebParam; global $objDBParam; // hiddenに入力値を保持 $objPage->arrHidden = $objWebParam->getHashArray(); // hiddenに入力値を保持 $objPage->arrHidden = array_merge($objPage->arrHidden, $objDBParam->getHashArray()); $arrDsn = getArrayDsn($objDBParam); $sqlval['id'] = 1; $sqlval['shop_name'] = $objWebParam->getValue('shop_name'); $sqlval['email01'] = $objWebParam->getValue('admin_mail'); $sqlval['email02'] = $objWebParam->getValue('admin_mail'); $sqlval['email03'] = $objWebParam->getValue('admin_mail'); $sqlval['email04'] = $objWebParam->getValue('admin_mail'); $sqlval['email05'] = $objWebParam->getValue('admin_mail'); $sqlval['top_tpl'] = 'default1'; $sqlval['product_tpl'] = 'default1'; $sqlval['detail_tpl'] = 'default1'; $sqlval['mypage_tpl'] = 'default1'; $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $objQuery = new SC_Query($arrDsn); $cnt = $objQuery->count('dtb_baseinfo'); if ($cnt > 0) { $objQuery->update('dtb_baseinfo', $sqlval); } else { $objQuery->insert('dtb_baseinfo', $sqlval); } // 管理者登録 $login_id = $objWebParam->getValue('login_id'); $salt = SC_Utils_Ex::sfGetRandomString(10); $login_pass = SC_Utils_Ex::sfGetHashString($objWebParam->getValue('login_pass'), $salt); $arrVal = array('login_id' => $login_id, 'password' => $login_pass, 'salt' => $salt, 'work' => 1, 'del_flg' => 0, 'update_date' => 'CURRENT_TIMESTAMP'); $member_id = $objQuery->get('member_id', 'dtb_member', 'login_id = ? AND del_flg = 0', array($login_id)); if (strlen($member_id) == 0) { $member_id = $objQuery->nextVal('dtb_member_member_id'); $arrVal['member_id'] = $member_id; $arrVal['name'] = '管理者'; $arrVal['creator_id'] = 0; $arrVal['authority'] = 0; $arrVal['rank'] = 1; $objQuery->insert('dtb_member', $arrVal); } else { $objQuery->update('dtb_member', $arrVal, 'member_id = ?', array($member_id)); } $objPage->arrHidden['db_skip'] = $_POST['db_skip']; $objPage->tpl_mainpage = 'complete.tpl'; $objPage->tpl_mode = 'complete'; $secure_url = $objWebParam->getValue('secure_url'); // 語尾に'/'をつける $secure_url = rtrim($secure_url, '/') . '/'; $objPage->tpl_sslurl = $secure_url; //EC-CUBEオフィシャルサイトからのお知らせURL $objPage->install_info_url = INSTALL_INFO_URL; return $objPage; }
function lfRegistRecommendData($array, $arrRegistColumn) { // 仮登録 foreach ($arrRegistColumn as $data) { if (strlen($array[$data["column"]]) > 0) { $arrRegist[$data["column"]] = $array[$data["column"]]; } } $arrRegist['create_date'] = 'now()'; $arrRegist['update_date'] = 'now()'; $arrRegist['creator_id'] = '0'; //-- 登録実行 $objQuery = new SC_Query(); $objQuery->begin(); $objQuery->insert("dtb_review", $arrRegist); $objQuery->commit(); }
function sfSaveMailHistory($order_id, $template_id, $subject, $body) { $sqlval['subject'] = $subject; $sqlval['order_id'] = $order_id; $sqlval['template_id'] = $template_id; $sqlval['send_date'] = "Now()"; if (!isset($_SESSION['member_id'])) { $_SESSION['member_id'] = ""; } if ($_SESSION['member_id'] != "") { $sqlval['creator_id'] = $_SESSION['member_id']; } else { $sqlval['creator_id'] = '0'; } $sqlval['mail_body'] = $body; $objQuery = new SC_Query(); $objQuery->insert("dtb_mail_history", $sqlval); }
function lfInsertClass() { $objQuery = new SC_Query(); $objQuery->begin(); // 親規格IDの存在チェック $where = "del_flg <> 1 AND class_id = ?"; $ret = $objQuery->get("dtb_class", "class_id", $where, array($_POST['class_id'])); if ($ret != "") { // INSERTする値を作成する。 $sqlval['name'] = $_POST['name']; $sqlval['class_id'] = $_POST['class_id']; $sqlval['creator_id'] = $_SESSION['member_id']; $sqlval['rank'] = $objQuery->max("dtb_classcategory", "rank", $where, array($_POST['class_id'])) + 1; $sqlval['create_date'] = "now()"; $sqlval['update_date'] = "now()"; // INSERTの実行 $ret = $objQuery->insert("dtb_classcategory", $sqlval); } $objQuery->commit(); return $ret; }
$sqlval['shop_name'] = $objWebParam->getValue('shop_name'); $sqlval['email01'] = $objWebParam->getValue('admin_mail'); $sqlval['email02'] = $objWebParam->getValue('admin_mail'); $sqlval['email03'] = $objWebParam->getValue('admin_mail'); $sqlval['email04'] = $objWebParam->getValue('admin_mail'); $sqlval['email05'] = $objWebParam->getValue('admin_mail'); $sqlval['top_tpl'] = "default1"; $sqlval['product_tpl'] = "default1"; $sqlval['detail_tpl'] = "default1"; $sqlval['mypage_tpl'] = "default1"; $objQuery = new SC_Query($dsn); $cnt = $objQuery->count("dtb_baseinfo"); if ($cnt > 0) { $objQuery->update("dtb_baseinfo", $sqlval); } else { $objQuery->insert("dtb_baseinfo", $sqlval); } // 管理者登録 $login_id = $objWebParam->getValue('login_id'); $login_pass = sha1($objWebParam->getValue('login_pass') . ":" . AUTH_MAGIC); $sql = "DELETE FROM dtb_member WHERE login_id = ?"; $objQuery->query($sql, array($login_id)); $sql = "INSERT INTO dtb_member (name, login_id, password, creator_id, authority, work, del_flg, rank, create_date, update_date)\n VALUES ('管理者',?,?,0,0,1,0,1, now(), now());"; $objQuery->query($sql, array($login_id, $login_pass)); global $GLOBAL_ERR; $GLOBAL_ERR = ""; $objPage = lfDispComplete($objPage); // サイト情報を送信 $req = new HTTP_Request("http://www.ec-cube.net/mall/use_site.php"); $req->setMethod(HTTP_REQUEST_METHOD_POST); $arrSendData = array();
/** * dtb_templatesへ入力内容を登録する. * * @param array $arrForm POSTされたパラメータ * @return void */ function lfRegisterTemplates($arrForm) { $objQuery = new SC_Query(); $sqlval = $arrForm; $sqlval['create_date'] = "now()"; $sqlval['update_date'] = "now()"; $objQuery->insert('dtb_templates', $sqlval); }
/** * 関連商品登録を行う. * * FIXME: 商品規格登録の実処理自体は、LC_Page_Admin_Products_Productと共通化して欲しい。 * DELETE/INSERT ではなく UPDATEへの変更も・・・ * * @param SC_Query $objQuery SC_Queryインスタンス * @param array $arrList 商品規格情報配列 * @param integer $product_id 商品ID * @return void */ public function lfRegistReccomendProducts($objQuery, $arrList, $product_id) { $objQuery->delete('dtb_recommend_products', 'product_id = ?', array($product_id)); for ($i = 1; $i <= RECOMMEND_PRODUCT_MAX; $i++) { $keyname = 'recommend_product_id' . $i; $comment_key = 'recommend_comment' . $i; if ($arrList[$keyname] != '') { $arrProduct = $objQuery->select('product_id', 'dtb_products', 'product_id = ?', array($arrList[$keyname])); if ($arrProduct[0]['product_id'] != '') { $arrWhereVal = array(); $arrWhereVal['product_id'] = $product_id; $arrWhereVal['recommend_product_id'] = $arrProduct[0]['product_id']; $arrWhereVal['comment'] = $arrList[$comment_key]; $arrWhereVal['update_date'] = $arrList['update_date']; $arrWhereVal['create_date'] = $arrList['update_date']; $arrWhereVal['creator_id'] = $_SESSION['member_id']; $arrWhereVal['rank'] = RECOMMEND_PRODUCT_MAX - $i + 1; $objQuery->insert('dtb_recommend_products', $arrWhereVal); } } } }
/** * 外部サイト連携用にセッションIDとパラメーターの組み合わせを保存する。 * * @param string $param_key パラメーター名 * @param string $param_value パラメーター値 * @param string $url URL * @return void */ function setExtSessionId($param_key, $param_value, $url) { $objQuery = new SC_Query(); // GC $lifetime = $this->state->getLifeTime(); $time = date('Y-m-d H:i:s', time() - $lifetime); $objQuery->delete('dtb_mobile_ext_session_id', 'create_date < ?', array($time)); $arrValues = array('session_id' => session_id(), 'param_key' => $param_key, 'param_value' => $param_value, 'url' => $url); $objQuery->insert('dtb_mobile_ext_session_id', $arrValues); }
/** * 商品規格登録を行う. * * @param SC_Query $objQuery SC_Queryインスタンス * @param array $arrList 商品規格情報配列 * @param integer $product_id 商品ID * @param integer $product_class_id 商品規格ID * @return void */ function lfRegistProductClass($objQuery, $arrList, $product_id, $product_class_id) { $sqlval['product_code'] = $arrList["product_code"]; $sqlval['stock'] = $arrList["stock"]; if ($sqlval['stock'] == "") { $sqlval['stock_unlimited'] = '1'; } else { $sqlval['stock_unlimited'] = '0'; } $sqlval['price01'] = $arrList['price01']; $sqlval['price02'] = $arrList['price02']; $sqlval['creator_id'] = $_SESSION['member_id']; // TODO $sqlval['member_id'] は何処から出てくる? if ($sqlval['member_id'] == "") { $sqlval['creator_id'] = '0'; } if ($product_class_id == "") { // 新規登録 $where = "product_id = ?"; // 念のために既存の規格を削除 $objQuery->delete("dtb_products_class", $where, array($product_id)); $sqlval['product_id'] = $product_id; $sqlval['classcategory_id1'] = '0'; $sqlval['classcategory_id2'] = '0'; $sqlval['create_date'] = "now()"; $objQuery->insert("dtb_products_class", $sqlval); } else { // 既存編集 $where = "product_id = ? AND product_class_id = ?"; $objQuery->update("dtb_products_class", $sqlval, $where, array($product_id, $product_class_id)); } }
function lfRegistData($email, &$objConn) { $count = 1; while ($count != 0) { $uniqid = SC_Utils_Ex::sfGetUniqRandomId("t"); $count = $objConn->getOne("SELECT COUNT(*) FROM dtb_customer_mail WHERE secret_key = ?", array($uniqid)); } $arrRegist["email"] = $email; // メールアドレス $arrRegist["mail_flag"] = 5; // 登録状態 $arrRegist["secret_key"] = $uniqid; // ID発行 $arrRegist["create_date"] = "now()"; // 作成日 $arrRegist["update_date"] = "now()"; // 更新日 //-- 仮登録実行 $objConn->query("BEGIN"); $objQuery = new SC_Query(); //-- 既にメルマガ登録しているかの判定 $sql = "SELECT count(*) FROM dtb_customer_mail WHERE email = ?"; $mailResult = $objConn->getOne($sql, array($arrRegist["email"])); if ($mailResult == 1) { $objQuery->update("dtb_customer_mail", $arrRegist, "email = " . SC_Utils_Ex::sfQuoteSmart($arrRegist["email"])); } else { $objQuery->insert("dtb_customer_mail", $arrRegist); } $objConn->query("COMMIT"); return $uniqid; }
function lfRegistProduct($arrList) { $objQuery = new SC_Query(); $objDb = new SC_Helper_DB_Ex(); $objQuery->begin(); // 配列の添字を定義 $checkArray = array("name", "status", "product_flag", "main_list_comment", "main_comment", "point_rate", "deliv_fee", "comment1", "comment2", "comment3", "comment4", "comment5", "comment6", "main_list_comment", "sale_limit", "sale_unlimited", "deliv_date_id", "note"); $arrList = SC_Utils_Ex::arrayDefineIndexes($arrList, $checkArray); // INSERTする値を作成する。 $sqlval['name'] = $arrList['name']; $sqlval['status'] = $arrList['status']; $sqlval['product_flag'] = $arrList['product_flag']; $sqlval['main_list_comment'] = $arrList['main_list_comment']; $sqlval['main_comment'] = $arrList['main_comment']; $sqlval['point_rate'] = $arrList['point_rate']; $sqlval['deliv_fee'] = $arrList['deliv_fee']; $sqlval['comment1'] = $arrList['comment1']; $sqlval['comment2'] = $arrList['comment2']; $sqlval['comment3'] = $arrList['comment3']; $sqlval['comment4'] = $arrList['comment4']; $sqlval['comment5'] = $arrList['comment5']; $sqlval['comment6'] = $arrList['comment6']; $sqlval['main_list_comment'] = $arrList['main_list_comment']; $sqlval['sale_limit'] = $arrList['sale_limit']; $sqlval['sale_unlimited'] = $arrList['sale_unlimited']; $sqlval['deliv_date_id'] = $arrList['deliv_date_id']; $sqlval['note'] = $arrList['note']; $sqlval['update_date'] = "Now()"; $sqlval['creator_id'] = $_SESSION['member_id']; $arrRet = $this->objUpFile->getDBFileList(); $sqlval = array_merge($sqlval, $arrRet); $arrList['category_id'] = unserialize($arrList['category_id']); for ($cnt = 1; $cnt <= PRODUCTSUB_MAX; $cnt++) { $sqlval['sub_title' . $cnt] = $arrList['sub_title' . $cnt]; $sqlval['sub_comment' . $cnt] = $arrList['sub_comment' . $cnt]; } if ($arrList['product_id'] == "") { // product_id 取得(PostgreSQLの場合) if (DB_TYPE == 'pgsql') { $product_id = $objQuery->nextval("dtb_products", "product_id"); $sqlval['product_id'] = $product_id; } // INSERTの実行 $sqlval['create_date'] = "Now()"; $objQuery->insert("dtb_products", $sqlval); // product_id 取得(MySQLの場合) if (DB_TYPE == 'mysql') { $product_id = $objQuery->nextval("dtb_products", "product_id"); } // カテゴリを更新 $objDb->updateProductCategories($arrList['category_id'], $product_id); // コピー商品の場合には規格もコピーする if ($_POST["copy_product_id"] != "" and SC_Utils_Ex::sfIsInt($_POST["copy_product_id"])) { if ($this->tpl_nonclass) { //規格なしの場合、コピーは価格等の入力が発生しているため、その内容で追加登録を行う $arrList['product_id'] = $product_id; $this->lfCopyProductClass($arrList, $objQuery); } else { //規格がある場合のコピーは複製元の内容で追加登録を行う // dtb_products_class のカラムを取得 $dbFactory = SC_DB_DBFactory_Ex::getInstance(); $arrColList = $dbFactory->sfGetColumnList("dtb_products_class", $objQuery); $arrColList_tmp = array_flip($arrColList); // コピーしない列 unset($arrColList[$arrColList_tmp["product_class_id"]]); //規格ID unset($arrColList[$arrColList_tmp["product_id"]]); //商品ID unset($arrColList[$arrColList_tmp["create_date"]]); $col = SC_Utils_Ex::sfGetCommaList($arrColList); $objQuery->query("INSERT INTO dtb_products_class (product_id, create_date, " . $col . ") SELECT ?, now(), " . $col . " FROM dtb_products_class WHERE product_id = ? ORDER BY product_class_id", array($product_id, $_POST["copy_product_id"])); } } } else { $product_id = $arrList['product_id']; // 削除要求のあった既存ファイルの削除 $arrRet = $this->lfGetProduct($arrList['product_id']); $this->objUpFile->deleteDBFile($arrRet); // UPDATEの実行 $where = "product_id = ?"; $objQuery->update("dtb_products", $sqlval, $where, array($product_id)); // カテゴリを更新 $objDb->updateProductCategories($arrList['category_id'], $product_id); } //商品登録の時は規格を生成する。複製の場合は規格も複製されるのでこの処理は不要。 if ($_POST["copy_product_id"] == "") { // 規格登録 SC_Utils_Ex::sfInsertProductClass($objQuery, $arrList, $product_id, $arrList['product_class_id']); } // おすすめ商品登録 $this->lfInsertRecommendProducts($objQuery, $arrList, $product_id); $objQuery->commit(); return $product_id; }
static function productSupportinitial($device_id, SC_Query $objQuery) { $objQuery->delete("cp_dtb_device_products", "device_id=?", (array) $device_id); $objQuery->insert("cp_dtb_device_products", array(), array("product_id" => "product_id", "device_id" => "device_id"), array(), "\n FROM dtb_product_categories\n INNER JOIN cp_dtb_device_categories USING(category_id)\n WHERE product_id IN (SELECT product_id FROM cp_dtb_device_products)\n AND device_id = ?", (array) $device_id); $objQuery->commit(); }
/** * 商品登録を行う. * * FIXME: 商品登録の実処理自体は、LC_Page_Admin_Products_Productと共通化して欲しい。 * * @param SC_Query $objQuery * SC_Queryインスタンス * @param string|integer $line * 処理中の行数 * @return void */ public function lfRegistProduct($objQuery, $line = '', &$objFormParam) { // 登録データ対象取得 $arrList = $objFormParam->getDbArray(); // 登録時間を生成(DBのCURRENT_TIMESTAMPだとcommitした際、全て同一の時間になってしまう) $arrList['update_date'] = $this->lfGetDbFormatTimeWithLine($line); // 商品登録情報を生成する。 // 商品テーブルのカラムに存在しているもののうち、Form投入設定されていないデータは上書きしない。 $sqlval = SC_Utils_Ex::sfArrayIntersectKeys($arrList, $this->arrProductColumn); // 必須入力では無い項目だが、空文字では問題のある特殊なカラム値の初期値設定 $sqlval = $this->lfSetProductDefaultData($sqlval); GC_Utils_Ex::gfPrintLog(print_r(array(__LINE__, $sqlval, $arrList), true), DEBUG_LOG_REALFILE); $sqlval = $objQuery->extractOnlyColsOf($this->table, $sqlval); if ($sqlval[$this->id_column] != '') { // 同じidが存在すればupdate存在しなければinsert $where = $this->id_column . ' = ?'; $product_exists = $objQuery->exists($this->table, $where, array($sqlval[$this->id_column])); if ($product_exists) { GC_Utils_Ex::gfPrintLog(print_r(array(__LINE__, $sqlval, $arrList), true), DEBUG_LOG_REALFILE); $objQuery->update($this->table, $sqlval, $where, array($sqlval[$this->id_column])); } else { $sqlval['create_date'] = $arrList['update_date']; // INSERTの実行 GC_Utils_Ex::gfPrintLog(print_r(array(__LINE__, $sqlval, $arrList), true), DEBUG_LOG_REALFILE); $objQuery->insert($this->table, $sqlval); // シーケンスの調整 $seq_count = $objQuery->currVal($this->seq_name); if ($seq_count < $sqlval[$this->id_column]) { $objQuery->setVal($this->seq_name, $sqlval[$this->id_column] + 1); } } $product_id = $sqlval[$this->id_column]; } else { // 新規登録 $sqlval[$this->id_column] = $objQuery->nextVal($this->seq_name); $product_id = $sqlval[$this->id_column]; $sqlval['create_date'] = $arrList['update_date']; // INSERTの実行 GC_Utils_Ex::gfPrintLog(print_r(array(__LINE__, $sqlval, $arrList), true), DEBUG_LOG_REALFILE); $objQuery->insert($this->table, $sqlval); } $objDb = new SC_Helper_DB_Ex(); // カテゴリ登録 if (isset($arrList['category_ids'])) { if ($objDb->sfColumnExists($this->categories_table, $this->id_column)) { $objQuery->delete($this->categories_table, $this->id_column . " = ?", array($sqlval[$this->id_column])); $arrCategory_id = explode(',', $arrList['category_ids']); $rank = 1; foreach ($arrCategory_id as $category_id) { $sqlval2 = array($this->id_column => $sqlval[$this->id_column], "category_id" => $category_id, "rank" => $rank++); $sqlval2 = $objQuery->extractOnlyColsOf($this->categories_table, $sqlval2); $objQuery->insert($this->categories_table, $sqlval2); } } } elseif (count($this->arrCategory) == 1) { if ($objDb->sfColumnExists($this->categories_table, $this->id_column)) { $objQuery->delete($this->categories_table, $this->id_column . " = ?", array($sqlval[$this->id_column])); $keys = array_keys($this->arrCategory); $sqlval2 = array($this->id_column => $sqlval[$this->id_column], "category_id" => $keys[0], "rank" => 1); $sqlval2 = $objQuery->extractOnlyColsOf($this->categories_table, $sqlval2); $objQuery->insert($this->categories_table, $sqlval2); } } }
function lfBatOrderAgeSub($sql, $start, $end, $start_age, $end_age, $member) { $objQuery = new SC_Query(); $arrRet = $objQuery->getall($sql, array($start, $end)); $sqlval = $arrRet[0]; // 空文字を"0"に変換 foreach ($sqlval as $key => $val) { if ($val == "") { $sqlval[$key] = "0"; } } $sqlval['create_date'] = "now()"; $sqlval['order_date'] = $start; $sqlval['start_age'] = "{$start_age}"; $sqlval['end_age'] = "{$end_age}"; $sqlval['member'] = "{$member}"; $objQuery->insert("dtb_bat_order_daily_age", $sqlval); }
/** * Page のプロセス. * * @return void */ function process() { $conn = new SC_DBConn(); $objPage = new LC_Page(); $objView = new SC_SiteView(); $objSess = new SC_Session(); // 都道府県プルダウン用配列 $masterData = new SC_DB_MasterData_Ex(); $this->arrPref = $masterData->getMasterData("mtb_pref", array("pref_id", "pref_name", "rank")); // CSV保存項目 //---- 登録用カラム配列 オプション以外 $arrRegistColumn = array(array("column" => "name01", "convert" => "aKV"), array("column" => "name02", "convert" => "aKV"), array("column" => "kana01", "convert" => "CKV"), array("column" => "kana02", "convert" => "CKV"), array("column" => "zip01", "convert" => "n"), array("column" => "zip02", "convert" => "n"), array("column" => "pref", "convert" => "n"), array("column" => "addr01", "convert" => "aKV"), array("column" => "addr02", "convert" => "aKV"), array("column" => "email", "convert" => "a"), array("column" => "email02", "convert" => "a"), array("column" => "tel01", "convert" => "n"), array("column" => "tel02", "convert" => "n"), array("column" => "tel03", "convert" => "n")); if (!isset($_POST['mode'])) { $_POST['mode'] = ""; } if (!$_POST['mode'] == 'confirm' && !is_numeric($_REQUEST['question_id'])) { SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); } // テンプレート登録項目取得 $sql = "SELECT question_id, question FROM dtb_question WHERE question_id = ?"; $result = $conn->getAll($sql, array($_REQUEST['question_id'])); if (count($result) <= 0) { SC_Utils_Ex::sfDispSiteError(PAGE_ERROR); } $this->QUESTION = $this->lfGetArrInput(unserialize($result[0]['question'])); $this->question_id = $_REQUEST['question_id']; $this->arrHidden = SC_Utils_Ex::sfMakeHiddenArray($_POST); unset($this->arrHidden['mode']); if (isset($this->QUESTION["delete"]) && (int) $this->QUESTION["delete"] !== 0) { $objPage->tpl_mainpage = "inquiry/closed.tpl"; } elseif ($_POST['mode'] == "confirm") { //-- 入力エラーチェック $this->arrForm = $_POST; $this->arrForm = $this->lfConvertParam($this->arrForm, $arrRegistColumn); $this->arrErr = $this->lfErrorCheck($this->arrForm); $this->arrErr = $this->lfGetArrInput($this->arrErr); if (!$this->arrErr) { $this->tpl_mainpage = "inquiry/confirm.tpl"; } } elseif ($_POST['mode'] == "return") { $this->arrForm = $_POST; } elseif ($_POST['mode'] == "regist") { //-- 入力文字・変換&エラーチェック $this->arrForm = $_POST; $this->arrForm = $this->lfConvertParam($this->arrForm, $arrRegistColumn); $this->arrErr = $this->lfErrorCheck($this->arrForm); $this->arrErr = $this->lfGetArrInput($this->arrErr); if (!$this->arrErr) { //完了画面 $this->tpl_mainpage = "inquiry/complete.tpl"; //--------- ▼ SQL ---------// // テーブルに入れるように整形する $arrOption = $this->arrForm['option']; unset($this->arrForm['email02']); $this->arrForm['mail01'] = $this->arrForm['email']; unset($this->arrForm['email']); unset($this->arrForm['option']); $this->arrForm['question_id'] = $this->question_id; $this->arrForm['question_name'] = $this->QUESTION['title']; for ($i = 0; $i < count($arrOption); $i++) { $tmp = ""; if (is_array($arrOption[$i])) { for ($j = 0; $j < count($arrOption[$i]); $j++) { if ($j > 0) { $tmp .= ","; } $tmp .= $arrOption[$i][$j]; } $this->arrForm['question0' . ($i + 1)] = $tmp; } else { $this->arrForm['question0' . ($i + 1)] = $arrOption[$i]; } } $this->arrForm['create_date'] = "now()"; // DB登録 $objQuery = new SC_Query(); $objQuery->insert("dtb_question_result", $this->arrForm); //--------- ▲ SQL ---------// } } $this->cnt_question = 6; $this->arrActive = isset($arrActive) ? $arrActive : ""; $this->arrQuestion = isset($arrQuestion) ? $arrQuestion : ""; //---- ページ表示 $objView->_smarty->register_function("lfArray_Search_key_Smarty", array("LC_Page_Inquiry", "lfArray_Search_key_Smarty")); $objView->assignobj($this); $objView->display($this->tpl_mainpage); }
/** * セッションのデータをDBに書き込む. * * @param string $id セッションID * @param string $sess_data セッションデータの値 * @return bool セッションの書き込みに成功した場合 true */ function sfSessWrite($id, $sess_data) { if (!$this->objDb->sfTabaleExists("dtb_session")) { return false; } $objQuery = new SC_Query(); $count = $objQuery->count("dtb_session", "sess_id = ?", array($id)); $sqlval = array(); if ($count > 0) { // レコード更新 $sqlval['sess_data'] = $sess_data; $sqlval['update_date'] = 'Now()'; $objQuery->update("dtb_session", $sqlval, "sess_id = ?", array($id)); } else { // セッションデータがある場合は、レコード作成 if (strlen($sess_data) > 0) { $sqlval['sess_id'] = $id; $sqlval['sess_data'] = $sess_data; $sqlval['update_date'] = 'Now()'; $sqlval['create_date'] = 'Now()'; $objQuery->insert("dtb_session", $sqlval); } } return true; }
function lfInsertCat($parent_category_id) { $objQuery = new SC_Query(); $objQuery->begin(); // トランザクションの開始 if ($parent_category_id == 0) { // ROOT階層で最大のランクを取得する。 $where = "parent_category_id = ?"; $rank = $objQuery->max("dtb_category", "rank", $where, array($parent_category_id)) + 1; } else { // 親のランクを自分のランクとする。 $where = "category_id = ?"; $rank = $objQuery->get("dtb_category", "rank", $where, array($parent_category_id)); // 追加レコードのランク以上のレコードを一つあげる。 $sqlup = "UPDATE dtb_category SET rank = (rank + 1) WHERE rank >= ?"; $objQuery->exec($sqlup, array($rank)); } $where = "category_id = ?"; // 自分のレベルを取得する(親のレベル + 1) $level = $objQuery->get("dtb_category", "level", $where, array($parent_category_id)) + 1; // 入力データを渡す。 $sqlval = $this->objFormParam->getHashArray(); $sqlval['create_date'] = "Now()"; $sqlval['update_date'] = "Now()"; $sqlval['creator_id'] = $_SESSION['member_id']; $sqlval['parent_category_id'] = $parent_category_id; $sqlval['rank'] = $rank; $sqlval['level'] = $level; // INSERTの実行 $objQuery->insert("dtb_category", $sqlval); $objQuery->commit(); // トランザクションの終了 }
function lfRegistData($payment_id = "") { $objQuery = new SC_Query(); $sqlval = $this->objFormParam->getHashArray(); $arrRet = $this->objUpFile->getDBFileList(); // ファイル名の取得 $sqlval = array_merge($sqlval, $arrRet); $sqlval['update_date'] = 'Now()'; if ($sqlval['fix'] != '1') { $sqlval['fix'] = 2; // 自由設定 } // 新規登録 if ($payment_id == "") { // INSERTの実行 $sqlval['creator_id'] = $_SESSION['member_id']; $sqlval['rank'] = $objQuery->max("dtb_payment", "rank") + 1; $sqlval['create_date'] = 'Now()'; $objQuery->insert("dtb_payment", $sqlval); // 既存編集 } else { $where = "payment_id = ?"; $objQuery->update("dtb_payment", $sqlval, $where, array($payment_id)); } }
function lfRegistData($uniqid) { $arrRet = $this->objFormParam->getHashArray(); $sqlval = $this->objFormParam->getDbArray(); // 登録データの作成 $sqlval['order_temp_id'] = $uniqid; $sqlval['order_birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']); $sqlval['update_date'] = 'Now()'; $sqlval['customer_id'] = '0'; // 既存データのチェック $objQuery = new SC_Query(); $where = "order_temp_id = ?"; $cnt = $objQuery->count("dtb_order_temp", $where, array($uniqid)); // 既存データがない場合 if ($cnt == 0) { $sqlval['create_date'] = 'Now()'; $objQuery->insert("dtb_order_temp", $sqlval); } else { $objQuery->update("dtb_order_temp", $sqlval, $where, array($uniqid)); } }