/** * SC_Queryインスタンスに設定された検索条件を元に並び替え済みの検索結果商品IDの配列を取得する。 * * 検索条件は, SC_Query::setWhere() 関数で設定しておく必要があります. * * @param SC_Query $objQuery SC_Query インスタンス * @param array $arrVal 検索パラメーターの配列 * @return array 商品IDの配列 */ public function findProductIdsOrder(&$objQuery, $arrVal = array()) { $table = 'dtb_products AS alldtl'; if (is_array($this->arrOrderData) and $objQuery->order == '') { $o_col = $this->arrOrderData['col']; $o_table = $this->arrOrderData['table']; $o_order = $this->arrOrderData['order']; $objQuery->setOrder("T2.{$o_col} {$o_order}"); $sub_sql = $objQuery->getSql($o_col, "{$o_table} AS T2", 'T2.product_id = alldtl.product_id'); $sub_sql = $objQuery->dbFactory->addLimitOffset($sub_sql, 1); $objQuery->setOrder("({$sub_sql}) {$o_order}, product_id"); } $arrReturn = $objQuery->getCol('alldtl.product_id', $table, '', $arrVal); return $arrReturn; }
static function search(LC_Page $objPage, SC_FormParam $objFormParam, SC_Query $objQuery) { // edit_** を除外する $objSql = new SC_DeviceAndroidSelect_Ex($objFormParam->getSearchArray(), "master"); $objPage->tpl_linemax = $objSql->getCount(); if ($objPage->tpl_linemax == 0) { return; } $objPage->page_max = $objFormParam->getValue("search_page_max", SEARCH_PMAX); $objPage->page = $objFormParam->getValue("search_pageno", 1); $objPage->objPageNavi = new SC_PageNavi_Ex($objPage->page, $objPage->tpl_linemax, $objPage->page_max, 'eccube.moveSearchPage', NAVI_PMAX); $objPage->arrPagenavi = $objPage->objPageNavi->arrPagenavi; $objSql->setOrder("device_name ASC"); $objPage->arrData = $objSql->getList($objPage->objPageNavi, $objPage->page_max); $objPage->arrData = SC_Utils_Ex::makeArrayIDToKey("device_id", $objPage->arrData); foreach ($objPage->arrData as $device_id => &$arrData) { $arrData["category_id"] = $objQuery->getCol("category_id", "cp_dtb_device_categories", "device_id=?", (array) $device_id); $release_date = SC_Utils_Ex::sfDispDBDate($arrData["release_date"], false); if ($release_date) { $arrData["release_date"] = str_replace("1970/01/01", "", $release_date); } $last_access_date = SC_Utils_Ex::sfDispDBDate($arrData["last_access_date"], false); if ($last_access_date) { $arrData["last_access_date"] = str_replace("1970/01/01", "", $last_access_date); } $device_name = trim($arrData["device_name"]); $arrData["disp_device_name"] = str_replace("(", "\n(", $device_name); } }
function lfGetURL() { $objQuery = new SC_Query(); $list_id = array(); $list_id = $objQuery->getCol('product_id', 'dtb_videoplayer'); foreach ($list_id as $value) { if ($value == $this->product_id) { $this->arrVideo = $objQuery->getRow('video_url,disp_width,disp_height', 'dtb_videoplayer', 'product_id = ?', array($this->product_id)); //var_dump($this->video_url); } } }
/** * テーブル一覧を取得する * * MDB2_Driver_Manager_pgsql#listTables の不具合回避を目的として独自実装している。 * @return array テーブル名の配列 */ public function listTables(SC_Query &$objQuery) { $col = 'tablename'; $from = 'pg_tables'; $where = "schemaname NOT IN ('pg_catalog', 'information_schema', 'sys')"; return $objQuery->getCol($col, $from, $where); }
function lfGetProduct($product_id) { $objQuery = new SC_Query(); $col = "*"; $table = "vw_products_nonclass AS noncls "; $where = "product_id = ?"; $arrRet = $objQuery->select($col, $table, $where, array($product_id)); // カテゴリID を取得 $arrRet[0]['category_id'] = $objQuery->getCol("dtb_product_categories", "category_id", "product_id = ?", array($product_id)); //編集時に規格IDが変わってしまうのを防ぐために規格が登録されていなければ規格IDを取得する if ($this->lfCheckNonClass($_POST['product_id'])) { $arrRet[0]['product_class_id'] = SC_Utils::sfGetProductClassId($product_id, "0", "0"); } return $arrRet[0]; }
function lfGetURL($objPage) { $objQuery = new SC_Query(); $list_id = array(); $list_id = $objQuery->getCol('product_id', 'dtb_videoplayer'); foreach ($list_id as $value) { if ($value == $objPage->arrProduct["product_id"]) { return $objQuery->getRow('video_url,disp_width,disp_height', 'dtb_videoplayer', 'product_id = ?', array($objPage->arrProduct["product_id"])); } } }
/** * 選択中の商品のカテゴリを取得する. * * @param integer $product_id プロダクトID * @param integer $category_id カテゴリID * @return array 選択中の商品のカテゴリIDの配列 * */ function sfGetCategoryId($product_id, $category_id = 0, $closed = false) { if ($closed) { $status = ""; } else { $status = "status = 1"; } if (!$this->g_category_on) { $this->g_category_on = true; $category_id = (int) $category_id; $product_id = (int) $product_id; if (SC_Utils_Ex::sfIsInt($category_id) && $this->sfIsRecord("dtb_category", "category_id", $category_id)) { $this->g_category_id = array($category_id); } else { if (SC_Utils_Ex::sfIsInt($product_id) && $this->sfIsRecord("dtb_products", "product_id", $product_id, $status)) { $objQuery = new SC_Query(); $where = "product_id = ?"; $category_id = $objQuery->getCol("dtb_product_categories", "category_id", "product_id = ?", array($product_id)); $this->g_category_id = $category_id; } else { // 不正な場合は、空の配列を返す。 $this->g_category_id = array(); } } } return $this->g_category_id; }
function lfGetProductsCSV($where, $option, $arrval, $arrOutputCols) { $objDb = new SC_Helper_DB_Ex(); $from = "vw_product_class AS prdcls"; $cols = SC_Utils_Ex::sfGetCommaList($arrOutputCols, true, array('category_id')); $objQuery = new SC_Query(); $objQuery->setoption($option); $list_data = $objQuery->select($cols, $from, $where, $arrval); $max = count($list_data); // 規格分類名一覧 if (in_array('classcategory_id1', $arrOutputCols) || in_array('classcategory_id2', $arrOutputCols)) { $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name"); } if (!isset($data)) { $data = ""; } for ($i = 0; $i < $max; $i++) { // 関連商品情報の付与 if (in_array('classcategory_id1', $arrOutputCols)) { $list_data[$i]['classcategory_id1'] = $arrClassCatName[$list_data[$i]['classcategory_id1']]; } if (in_array('classcategory_id2', $arrOutputCols)) { $list_data[$i]['classcategory_id2'] = $arrClassCatName[$list_data[$i]['classcategory_id2']]; } if (in_array('category_id', $arrOutputCols)) { $arrCategory_id = $objQuery->getCol("dtb_product_categories", "category_id", "product_id = ?", array($list_data[$i]['product_id'])); // カテゴリID 付与 for ($j = 0; $j < count($arrCategory_id); $j++) { $list_data[$i]['category_id'] .= $arrCategory_id[$j]; if ($j < count($arrCategory_id) - 1) { $list_data[$i]['category_id'] .= "|"; } } } // 各項目をCSV出力用に変換する。 $data .= $this->lfMakeProductsCSV($list_data[$i]); } return $data; }