function enablePlugin() { $objQuery = new SC_Query_Ex(); $name = preg_replace("/.php/", "", __FILE__); // XXX 正規表現エスケープ漏れでは? $objQuery->update("dtb_plugin", array('enable' => '0'), "plugin_name = ?", array($name)); }
/** * Page のアクション. * * @return void */ function action() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $layout = new SC_Helper_PageLayout_Ex(); $objDb = new SC_Helper_DB_Ex(); $this->arrOrder = $objDb->sfGetBasisData(); }
/** * CSVファイルを送信する * * @param integer $csv_id * CSVフォーマットID * @param string $where * WHERE条件文 * @param array $arrVal * プリペアドステートメントの実行時に使用される配列。配列の要素数は、クエリ内のプレースホルダの数と同じでなければなりません。 * @param string $order * ORDER文 * @param boolean $is_download * true:ダウンロード用出力までさせる false:CSVの内容を返す(旧方式、メモリを食います。) * @return boolean|string $is_download = true時 成功失敗フラグ(boolean) 、$is_downalod = false時 string */ public function sfDownloadCsv($csv_id, $where = '', $arrVal = array(), $order = '', $is_download = false) { switch ($csv_id) { case 1: case 2: case 3: case 4: case 5: return parent::sfDownloadCsv($csv_id, $where, $arrVal, $order, $is_download); } $objQuery =& SC_Query_Ex::getSingletonInstance(); // CSV出力タイトル行の作成 $arrOutput = SC_Utils_Ex::sfSwapArray($this->sfGetCsvOutput($csv_id, 'status = ' . CSV_COLUMN_STATUS_FLG_ENABLE)); if (count($arrOutput) <= 0) { SC_Utils_Ex::sfDispError(""); return false; // 失敗終了 } $arrOutputCols = $arrOutput['col']; $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true); switch ($csv_id) { case 6: // キャラクター $from = 'cp_dtb_character'; break; case 7: // 端末 $from = 'cp_dtb_device'; break; } $objQuery->setOrder($order); $sql = $objQuery->getSql($cols, $from, $where); return $this->sfDownloadCsvFromSql($sql, $arrVal, $this->arrSubnavi[$csv_id], $arrOutput['disp_name'], $is_download); }
protected function doApply() { $dataDir = $this->dataDir->getAbsolutePath(); $htmlDir = $this->htmlDir->getAbsolutePath(); define('HTML_REALDIR', rtrim(realpath($htmlDir), '/\\') . '/'); require_once HTML_REALDIR . '/define.php'; require_once HTML_REALDIR . HTML2DATA_DIR . '/require_base.php'; $query = SC_Query_Ex::getSingletonInstance(); $storage = new Zeclib_DefaultMigrationStorage($query, $this->system); $storage->versionTable = $this->versionTable; $storage->containerDirectories[] = $this->containerDir->getPath(); $migrator = new Zeclib_Migrator($storage, $query); $migrator->logger = new Zeclib_Phing_TaskMigrationLogger($this); $migrations = array(); $versions = preg_split('/[,\\s]+/', $this->version, 0, PREG_SPLIT_NO_EMPTY); foreach ($versions as $version) { try { $migrations[] = $migrator->loadMigration($version); } catch (Zeclib_MigrationException $e) { $message = $e->getMessage(); $this->log($message, Zeclib_MigrationLogger::TYPE_WARNING); } } $num = $migrator->apply($migrations); $this->log(sprintf('%d migrations are applied.', $num)); }
/** * アップデート * updateはアップデート時に実行されます. * 引数にはdtb_pluginのプラグイン情報が渡されます. * * @param array $arrPlugin プラグイン情報の連想配列(dtb_plugin) * @return void */ function update($arrPlugin) { // nop // バージョンの更新 $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); $plugin_id = $arrPlugin['plugin_id']; $plugin_version = '0.9.1'; // 新しいバージョン $objQuery =& SC_Query_Ex::getSingletonInstance(); $sqlval = array(); $table = "dtb_plugin"; $sqlval['plugin_version'] = $plugin_version; $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $where = "plugin_id = ?"; $objQuery->update($table, $sqlval, $where, array($plugin_id)); $objQuery->commit(); // 変更ファイルの上書き copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/VideoPlayer.php", PLUGIN_UPLOAD_REALDIR . $arrPlugin['plugin_code'] . "/VideoPlayer.php"); copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/logo.png", PLUGIN_UPLOAD_REALDIR . $arrPlugin['plugin_code'] . "/logo.png"); // ブロック画面の上書き // copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/bloc/plg_videoplayer.php", HTML_REALDIR . "frontparts/bloc/plg_videoplayer.php"); // copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/templates/default/plg_videoplayer.tpl", TEMPLATE_REALDIR . "frontparts/bloc/plg_videoplayer.tpl"); // copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/bloc/LC_Page_FrontParts_Bloc_VideoPlayer.php", CLASS_REALDIR . "pages/frontparts/bloc/LC_Page_FrontParts_Bloc_VideoPlayer.php"); // copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/bloc/LC_Page_FrontParts_Bloc_VideoPlayer_Ex.php", CLASS_EX_REALDIR . "page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_VideoPlayer_Ex.php"); // プラグイン設定画面の上書き // copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/config.php", PLUGIN_UPLOAD_REALDIR . $arrPlugin['plugin_code'] . "/config.php"); // copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/LC_Page_Plugin_VideoPlayer_Config.php", PLUGIN_UPLOAD_REALDIR . $arrPlugin['plugin_code'] . "/config.phpLC_Page_Plugin_VideoPlayer_Config.php"); // copy(DOWNLOADS_TEMP_PLUGIN_UPDATE_DIR . "/templates/config.tpl", PLUGIN_UPLOAD_REALDIR . $arrPlugin['plugin_code'] . "/templates/config.tpl"); }
function update(array $arrPlugin, SC_Plugin_Installer $installer) { $base_dir = dirname(__FILE__); GC_Utils_Ex::gfPrintLog("[" . $arrPlugin["plugin_code"] . "]更新処理を実行します。", PLUGIN_LOG_REALFILE, FALSE); $log = ""; $xdir = PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"]; if (!is_dir($xdir . "_" . date("Ymd") . "/")) { rename($xdir . "/", $xdir . "_" . date("Ymd") . "/"); } SC_Helper_FileManager_Ex::deleteFile($xdir . "/", false); $log .= SC_Utils_Ex::sfCopyDir("{$base_dir}/", PLUGIN_UPLOAD_REALDIR . $arrPlugin["plugin_code"] . "/", '', true); // logo コピー $installer->copyDirectory("copy/plugin_dir/", ""); GC_Utils_Ex::gfPrintLog($log, PLUGIN_LOG_REALFILE, false); $core = new SupportDeviceCore($arrPlugin); $plugin_version = $arrPlugin["plugin_version"]; switch ($plugin_version) { case "0.0.0": case "0.0.1": // 再インストール $core->install($arrPlugin, $installer); $core->update($arrPlugin, $installer, "0.0.0"); break; default: $core->update($arrPlugin, $installer, $plugin_version); break; } $core->createCash(); $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); GC_Utils_Ex::gfPrintLog("[" . $arrPlugin["plugin_code"] . "]更新処理を実行完了しました。", PLUGIN_LOG_REALFILE, FALSE); }
/** * Page のアクション. * * @return void */ function action() { parent::action(); $objQuery = SC_Query_Ex::getSingletonInstance(); if (is_array($this->arrHidden['search_customer_type'])) { $cnt = array_sum($this->arrHidden['search_customer_type']); // tpl表示切換用 $this->search_customer_type = $cnt; } elseif (is_array($this->arrForm['search_customer_type']['value'])) { $cnt = array_sum($this->arrForm['search_customer_type']['value']); // tpl表示切換用 $this->search_customer_type = $cnt; } else { $this->search_customer_type = 1; } if (is_array($this->arrData)) { foreach ($this->arrData as &$customer) { $customer_id = $customer["customer_id"]; if ($this->objDb->sfColumnExists("cp_dtb_customer_docomo_mymenu", "customer_id")) { $customer = array_merge(SC_Helper_Customer_Ex::sfGetCustomerData($customer_id), $customer); $customer["mymenu"] = call_user_func("CarrierPay::getCustomerMymenu", array($customer_id)); } if ($this->objDb->sfColumnExists("cp_dtb_point_history", "id")) { $point = $objQuery->getRow(implode(",", array("sum(add_point ) AS add_point", "sum(use_point ) AS use_point", "sum(lost_point) AS lost_point")), "cp_dtb_point_history", "customer_id = ?", array($customer_id)); foreach ($point as $key => $value) { $customer[$key] = $value; } } if ($this->objDb->sfColumnExists("cp_dtb_customer_transaction", "id")) { $customer["transaction"] = $objQuery->select("*", "cp_dtb_customer_transaction", "customer_id = ? AND del_flg = 0 AND continue_account_id IS NOT NULL", array($customer_id)); } } } }
/** * おすすめ商品検索. * * @return array $arrBestProducts 検索結果配列 */ public function lfGetRanking() { $objRecommend = new SC_Helper_BestProducts_Ex(); // おすすめ商品取得 $arrRecommends = $objRecommend->getList(RECOMMEND_NUM); $response = array(); if (count($arrRecommends) > 0) { // 商品一覧を取得 $objQuery =& SC_Query_Ex::getSingletonInstance(); $objProduct = new SC_Product_Ex(); // where条件生成&セット $arrProductId = array(); foreach ($arrRecommends as $key => $val) { $arrProductId[] = $val['product_id']; } $arrProducts = $objProduct->getListByProductIds($objQuery, $arrProductId); // 税込金額を設定する SC_Product_Ex::setIncTaxToProducts($arrProducts); // おすすめ商品情報にマージ foreach ($arrRecommends as $key => $value) { if (isset($arrProducts[$value['product_id']])) { $product = $arrProducts[$value['product_id']]; if ($product['status'] == 1 && (!NOSTOCK_HIDDEN || ($product['stock_max'] >= 1 || $product['stock_unlimited_max'] == 1))) { $response[] = array_merge($value, $arrProducts[$value['product_id']]); } } else { // 削除済み商品は除外 unset($arrRecommends[$key]); } } } return $response; }
/** * Page のアクション. * * @return void */ public function action() { $objFormParam = new SC_FormParam_Ex(); $this->initParam($objFormParam); $objFormParam->setParam($_POST); $this->arrForm = $objFormParam->getHashArray(); $this->arrHidden = $objFormParam->getSearchArray(); $objQuery = SC_Query_Ex::getSingletonInstance(); switch ($this->getMode()) { case "pre_edit": $this->initEdit(); $this->doPreEdit($objQuery, $objFormParam); break; default: case "add": $this->initRegist(); $this->arrForm = $objFormParam->getHashArray(); break; case "edit": $this->initConfirm(); $this->doCheck($objQuery, $objFormParam); $this->doEdit($objQuery, $objFormParam); break; } }
/** * オペレーション名に対応した認証の設定情報を取得する * Configが無い場合は、APIデフォルトを取得する * * @param string $operation_name * @return array 設定配列 */ public function getApiConfig($operation_name) { // 設定優先度 DB > plugin default > base $objQuery =& SC_Query_Ex::getSingletonInstance(); $where = 'operation_name Like ? AND del_flg = 0 AND enable = 1'; $arrApiConfig = $objQuery->getRow('*', 'dtb_api_config', $where, array($operation_name)); if (SC_Utils_Ex::isBlank($arrApiConfig)) { $objApi = SC_Api_Utils_Ex::loadApiOperation($operation_name); if (is_object($objApi)) { $arrApiConfig = $objApi->getDefaultConfig(); } if (!SC_Utils_Ex::isBlank($arrApiConfig)) { // デフォルト設定がロード出来た場合は自動で設定に反映 $arrData = $arrApiConfig; $arrData['update_date'] = 'CURRENT_TIMESTAMP'; $arrData['api_config_id'] = $objQuery->nextVal('dtb_api_config_api_config_id'); $objQuery->insert('dtb_api_config', $arrData); } else { // ロード出来ない場合はAPI_Defaultを適用 $operation_name = 'Default'; $objApi = SC_Api_Utils_Ex::loadApiOperation($operation_name); $arrApiConfig = $objApi->getDefaultConfig(); } } return $arrApiConfig; }
function changeProductStatus(LC_Page $objPage) { $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); $n = array(); $n2 = array("auto_display_status" => 0); $objSql = new SC_SelectSql_Ex(); $objSql->setWhere("auto_display_status = 1"); $objSql->setWhere("del_flg = 0"); $s = "auto_display_end_date"; $e = "auto_display_start_date"; // 公開日による状態変更 // {$s} > NOW() 公開開始前 // {$e} < NOW() 公開終了後 // その他 公開中 $objQuery->update("dtb_products", $n, $objSql->getWhere(), $n, array("status" => "CASE WHEN {$s} > NOW() THEN 2 WHEN {$e} < NOW() THEN 2 ELSE 1 END", "auto_display_status" => "CASE WHEN {$e} < NOW() THEN 0 ELSE 1 END")); $objSql->setWhere("{$e} < NOW() "); $objQuery->update("dtb_products", $n, $objSql->getWhere(), $n2); $objQuery->commit(); if (GC_Utils_Ex::isFrontFunction()) { // 商品数量を再計算 $objDb = new SC_Helper_DB_Ex(); $objDb->sfCountCategory($objQuery); $objDb->sfCountMaker($objQuery); } }
/** * カテゴリー一覧の取得. * * @param boolean $cid_to_key 配列のキーをカテゴリーIDにする場合はtrue * @return array カテゴリー一覧の配列 */ public function getList($cid_to_key = FALSE) { static $arrCategory = array(), $cidIsKey = array(); if (!isset($arrCategory[$this->count_check])) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = 'dtb_category.*, dtb_category_total_count.product_count'; $from = 'dtb_category left join dtb_category_total_count ON dtb_category.category_id = dtb_category_total_count.category_id'; // 登録商品数のチェック if ($this->count_check) { $where = 'del_flg = 0 AND product_count > 0'; } else { $where = 'del_flg = 0'; } $objQuery->setOption('ORDER BY rank DESC'); $arrTmp = $objQuery->select($col, $from, $where); $arrCategory[$this->count_check] = $arrTmp; } if ($cid_to_key) { if (!isset($cidIsKey[$this->count_check])) { // 配列のキーをカテゴリーIDに $cidIsKey[$this->count_check] = SC_Utils_Ex::makeArrayIDToKey('category_id', $arrCategory[$this->count_check]); } return $cidIsKey[$this->count_check]; } return $arrCategory[$this->count_check]; }
/** * * メールの履歴を取り出す。 * @param int $send_id */ function getMailHistory($send_id) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = 'subject, mail_body'; $where = 'send_id = ?'; $mailHistory = $objQuery->select($col, 'dtb_mail_history', $where, array($send_id)); return $mailHistory; }
/** * DBに規約情報を登録します. */ protected function setUpKiyaku() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $kiyaku = array(array('kiyaku_id' => '1000', 'kiyaku_title' => 'test1', 'kiyaku_text' => 'test_text', 'rank' => '12', 'creator_id' => '0', 'create_date' => '2000-01-01 00:00:00', 'update_date' => '2000-01-01 00:00:00', 'del_flg' => '0'), array('kiyaku_id' => '1001', 'kiyaku_title' => 'test2', 'kiyaku_text' => 'test_text2', 'rank' => '11', 'creator_id' => '0', 'create_date' => '2000-01-01 00:00:00', 'update_date' => '2000-01-01 00:00:00', 'del_flg' => '0'), array('kiyaku_id' => '1002', 'kiyaku_title' => 'test3', 'kiyaku_text' => 'test_text', 'rank' => '10', 'creator_id' => '0', 'create_date' => '2000-01-01 00:00:00', 'update_date' => '2000-01-01 00:00:00', 'del_flg' => '1')); $this->objQuery->delete('dtb_kiyaku'); foreach ($kiyaku as $key => $item) { $ret = $objQuery->insert('dtb_kiyaku', $item); } }
/** * インストール * installはプラグインのインストール時に実行されます. * 引数にはdtb_pluginのプラグイン情報が渡されます. * * @param array $arrPlugin plugin_infoを元にDBに登録されたプラグイン情報(dtb_plugin) * @return void */ function install($arrPlugin) { // 【データベースの設定】 // ■プラグイン設定の初期化 $objQuery = SC_Query_Ex::getSingletonInstance(); $objQuery->begin(); // プラグイン独自の設定データを追加 $sqlval = array(); $sqlval['free_field1'] = "Any"; $sqlval['free_field2'] = ""; $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; $where = "plugin_code = 'AddProduct'"; // UPDATEの実行 $objQuery->update('dtb_plugin', $sqlval, $where); // ■インストール用SQLを実行 if (!AddProduct::lfExecuteSQL(PLUGIN_UPLOAD_REALDIR . "AddProduct/sql/plg_AddProduct_Install_" . DB_TYPE . '.sql', DEFAULT_DSN)) { AddProduct::lfTriggerError('インストール用のSQLの実行に失敗しました.'); } $objQuery->commit(); // ■マスタデータのキャッシュをクリア $masterData = new SC_DB_MasterData_Ex(); $masterData->clearCache('mtb_auth_excludes'); // 【必要なファイルをコピー】 // ■ロゴ画像 AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/logo.png", PLUGIN_HTML_REALDIR . 'AddProduct/logo.png'); // ■アクセストークン取得画面 // コールPHP AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/html/addproduct", HTML_REALDIR . ADMIN_DIR, true); // ディレクトリごとコピー // 拡張クラス AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/page_extends/addproduct", CLASS_EX_REALDIR . 'page_extends/admin/', true); // ディレクトリごとコピー // 基本クラス AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/pages/addproduct", CLASS_REALDIR . 'pages/admin/', true); // ディレクトリごとコピー // テンプレート AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/templates/addproduct", SMARTY_TEMPLATES_REALDIR . 'admin/', true); // ディレクトリごとコピー // CSS AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/html/plg_AddProduct_addproduct.css", USER_TEMPLATE_REALDIR . 'admin/css/plg_AddProduct_addproduct.css'); // ■API // API共通関数(継承元クラス) AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/api/plg_AddProduct_AddProductCommon.php", CLASS_REALDIR . 'api/operations/plg_AddProduct_AddProductCommon.php'); // 各種パラメータ取得API AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/api/plg_AddProduct_GetParamList.php", CLASS_REALDIR . 'api/operations/plg_AddProduct_GetParamList.php'); // 商品登録用API AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/api/plg_AddProduct_AddProduct.php", CLASS_REALDIR . 'api/operations/plg_AddProduct_AddProduct.php'); // ■トークン管理画面 // コールPHP AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/html/plg_AddProduct_addproduct.php", HTML_REALDIR . ADMIN_DIR . 'system/plg_AddProduct_addproduct.php'); // 拡張クラス AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/plg_AddProduct_LC_Page_Admin_System_AddProduct_Ex.php", CLASS_EX_REALDIR . 'page_extends/admin/system/plg_AddProduct_LC_Page_Admin_System_AddProduct_Ex.php'); // 基本クラス AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/plg_AddProduct_LC_Page_Admin_System_AddProduct.php", CLASS_REALDIR . 'pages/admin/system/plg_AddProduct_LC_Page_Admin_System_AddProduct.php'); // テンプレート AddProduct::lfCopyFile(PLUGIN_UPLOAD_REALDIR . "AddProduct/data/plg_AddProduct_addproduct.tpl", SMARTY_TEMPLATES_REALDIR . 'admin/system/plg_AddProduct_addproduct.tpl'); }
public function clear() { $where = "{$this->systemColumn} = ?"; $whereValues = array($this->system); $result = $this->query->delete($this->versionTable, $where, $whereValues); if (PEAR::isError($result)) { throw new Zeclib_MigrationException($result->getMessage(), $result->getCode()); } }
/** * DBに規約情報を登録します. */ protected function setUpAddress() { $objQuery =& SC_Query_Ex::getSingletonInstance(); // シーケンス初期化 $kiyaku = array(array('other_deliv_id' => '1000', 'customer_id' => '1', 'name01' => 'テスト', 'name02' => 'いち', 'kana01' => 'テスト', 'kana02' => 'イチ', 'zip01' => '000', 'zip02' => '0000', 'pref' => '1', 'addr01' => 'テスト', 'addr02' => 'テスト2', 'tel01' => '000', 'tel02' => '0000', 'tel03' => '0000', 'fax01' => '111', 'fax02' => '1111', 'fax03' => '1111'), array('other_deliv_id' => '1001', 'customer_id' => '1', 'name01' => 'テスト', 'name02' => 'に', 'kana01' => 'テスト', 'kana02' => 'ニ', 'zip01' => '222', 'zip02' => '2222', 'pref' => '2', 'addr01' => 'テスト1', 'addr02' => 'テスト2', 'tel01' => '000', 'tel02' => '0000', 'tel03' => '0000', 'fax01' => '111', 'fax02' => '1111', 'fax03' => '1111')); $this->objQuery->delete('dtb_other_deliv'); foreach ($kiyaku as $key => $item) { $ret = $objQuery->insert('dtb_other_deliv', $item); } }
/** * @param array $arrSelfInfo */ function __construct($arrSelfInfo) { parent::__construct($arrSelfInfo); $this->objQuery = SC_Query_Ex::getSingletonInstance(); $this->objDb = new SC_Helper_DB_Ex(); $this->masterdata = new SC_DB_MasterData_Ex(); $this->objCategory = new SC_Helper_Category_Ex(); $this->objManager = $this->objQuery->conn->loadModule('Manager'); $this->objDbFuctory = SC_DB_DBFactory_Ex::getInstance(DB_TYPE); }
public function testgetListTest_一覧を取得できた場合削除した商品は取得しない_一覧のarrayを返す() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $this->setUpKiyaku(); $has_deleted = FALSE; //期待値 $this->expected = array(array('kiyaku_id' => '1000', 'kiyaku_title' => 'test1', 'kiyaku_text' => 'test_text'), array('kiyaku_id' => '1001', 'kiyaku_title' => 'test2', 'kiyaku_text' => 'test_text2')); $this->actual = $this->objKiyaku->getList($has_deleted); $this->verify('規約一覧取得'); }
public function testgetKiyakuTest_削除された情報を含む規約情報を規約idから取得する際削除された規約を指定した場合_nullを返す() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $this->setUpKiyaku(); $has_deleted = TRUE; $kiyaku_id = 1002; //期待値 $this->expected = array('kiyaku_id' => '1002', 'kiyaku_title' => 'test3', 'kiyaku_text' => 'test_text', 'rank' => '10', 'creator_id' => '0', 'create_date' => '2000-01-01 00:00:00', 'update_date' => '2000-01-01 00:00:00', 'del_flg' => '1'); $this->actual = $this->objKiyaku->getKiyaku($kiyaku_id, $has_deleted); $this->verify('規約詳細取得'); }
/** * 最近購入された商品を5件取得する */ function getPurchaseProducts() { $col = 'dtb_order_detail.product_id, dtb_order_detail.product_name,dtb_order.create_date'; $table = 'dtb_order_detail JOIN dtb_order ON dtb_order_detail.order_id = dtb_order.order_id'; $where = 'dtb_order.del_flg = 0'; $objQuery =& SC_Query_Ex::getSingletonInstance(); $objQuery->setLimit(5); $objQuery->setOrder('dtb_order.create_date DESC'); $arrPurchaseProducts = $objQuery->select($col, $table, $where); return $arrPurchaseProducts; }
/** * Page のAction. * * @return void */ function action() { // 会員クラス $objCustomer = new SC_Customer_Ex(); $objQuery = SC_Query_Ex::getSingletonInstance(); $col = '*'; $from = 'dtb_news'; $where = 'news_id = ? and del_flg = 0'; $arrval = array($_GET['news_id']); $arrNews = $objQuery->select($col, $from, $where, $arrval); $this->arrNews = $arrNews[0]; }
public function testGetList_表示件数1かつページ番号0の場合_対象のニュースが取得できる() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $this->setUpNews(); $dispNumber = 1; $pageNumber = 0; $has_deleted = false; $this->expected = array('update_date' => '2000-01-01 00:00:00', 'news_id' => '1004', 'news_title' => 'ニュース情報04', 'creator_id' => '1', 'del_flg' => '0'); $result = $this->objNews->getList($dispNumber, $pageNumber, $has_deleted); $this->actual = Test_Utils::mapArray($result[0], array('update_date', 'news_id', 'news_title', 'creator_id', 'del_flg')); $this->verify(); }
public function revert(array $migrations) { $migrations = $this->sort($migrations, SORT_DESC); $reverteds = 0; try { foreach ($migrations as $migration) { $this->query->begin(); if (!$this->storage->isAppliedVersion($migration->version)) { $this->logger->log(sprintf('Revert migration skipped, Already reverted.: {system:"%s", version:"%s"}', $this->storage->system, $migration->version)); continue; } $migration->down(); $migration->applied = false; $this->storage->markReverted($migration->version); $this->query->commit(); $this->logger->log(sprintf('Revert migration successful: {system:"%s", version:"%s"}', $this->storage->system, $migration->version)); $reverteds++; } $this->query->commit(); } catch (Exception $e) { if ($this->query->inTransaction()) { $this->query->rollback(); } $this->logger->log(sprintf('Revert migration failed: {system:"%s", version:"%s"}', $this->storage->system, $migration->version)); throw $e; } return $reverteds; }
static function saveConfig($value = array(), $key = "free_field1", $plugin_code = "KisekaeTouch") { $objPlugin = new SC_Plugin_Util_Ex(); $arrPlugin = $objPlugin->getPluginByPluginCode($plugin_code); if (!SC_Utils_Ex::isBlank($value) && is_array($value)) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $table = 'dtb_plugin'; $where = 'plugin_code = ?'; $objQuery->update($table, array($key => serialize($value)), $where, array("KisekaeTouch")); } $config = unserialize($arrPlugin[$key]); return $config; }
public function testSaveNewsTest_news_idが存在する場合_対象のニュースが更新される() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $this->setUpNews(); $sqlval = array('news_id' => '1002', 'news_title' => 'ニュース情報05更新', 'creator_id' => '1', 'del_flg' => '0'); $this->expected['count'] = '4'; $this->expected['content'] = array('news_id' => '1002', 'news_title' => 'ニュース情報05更新', 'creator_id' => '1', 'del_flg' => '0'); $ret_id = $this->objNews->saveNews($sqlval); $this->actual['count'] = $objQuery->count('dtb_news'); $result = $objQuery->select('news_id, news_title, creator_id, del_flg', 'dtb_news', 'news_id = ?', array($ret_id)); $this->actual['content'] = $result[0]; $this->verify(); }
public function testdeleteAddressTest_会員の登録配送先を削除する() { $this->setUpAddress(); $other_deliv_id = '1000'; $this->expected = NULL; $this->objAddress->deleteAddress($other_deliv_id); $objQuery =& SC_Query_Ex::getSingletonInstance(); $select = '*'; $from = 'dtb_other_deliv'; $where = 'other_deliv_id = ?'; $whereVal = array($other_deliv_id); $this->actual = $objQuery->getRow($select, $from, $where, $whereVal); $this->verify('登録配送先削除'); }
public function testregistAddressTest_会員の登録配送先を更新する() { $this->setUpAddress(); $arrSql = array('other_deliv_id' => '1000', 'customer_id' => '1', 'name01' => 'テスト', 'name02' => '更新', 'kana01' => 'テスト', 'kana02' => 'コウシン', 'zip01' => '222', 'zip02' => '2222', 'pref' => '4', 'addr01' => 'テスト1', 'addr02' => 'テスト1', 'tel01' => '001', 'tel02' => '0002', 'tel03' => '0003', 'fax01' => '112', 'fax02' => '1113', 'fax03' => '1114', 'country_id' => null, 'company_name' => null, 'zipcode' => null); $objQuery =& SC_Query_Ex::getSingletonInstance(); $this->objAddress->registAddress($arrSql); $this->expected = $arrSql; $col = '*'; $from = 'dtb_other_deliv'; $where = 'other_deliv_id = ?'; $arrWhere = array($arrSql['other_deliv_id']); $this->actual = $objQuery->getRow($col, $from, $where, $arrWhere); $this->verify('登録配送先更新'); }
/** * シングルトンの SC_Query インスタンスを取得する. * * @param string $dsn データソース名 * @param boolean $force_run エラーが発生しても処理を続行する場合 true * @param boolean $new 新規に接続を行うかどうか * @return SC_Query シングルトンの SC_Query インスタンス */ static function getSingletonInstance($dsn = '', $force_run = false, $new = false) { $objThis = SC_Query_Ex::getPoolInstance($dsn); if (is_null($objThis)) { $objThis = SC_Query_Ex::setPoolInstance(new SC_Query_Ex($dsn, $force_run, $new), $dsn); } /* * 歴史的な事情で、このメソッドの呼び出し元は参照で受け取る確率がある。 * 退避しているインスタンスをそのまま返すと、退避している SC_Query の * プロパティを直接書き換えることになる。これを回避するため、クローンを返す。 * 厳密な意味でのシングルトンではないが、パフォーマンス的に大差は無い。 */ return clone $objThis; }
public function testRankUpTest_ニュースIDを指定した場合_対象のランクが1増加する() { $objQuery =& SC_Query_Ex::getSingletonInstance(); $this->setUpNews(); $news_id = 1002; $this->expected = '3'; $this->objNews->rankUp($news_id); $col = 'rank'; $from = 'dtb_news'; $where = 'news_id = ?'; $whereVal = array($news_id); $res = $objQuery->getCol($col, $from, $where, $whereVal); $this->actual = $res[0]; $this->verify(); }