function selectSubquery($column, $table, $where, $arrWhereVal)
 {
     if (is_string($column)) {
         $objQuery = new SC_Query_Ex();
         $subquery = $objQuery->getSql($column, $table, $where, $arrWhereVal);
         $this->setWhere("{$column} IN ({$subquery})");
     } else {
         $objQuery = new SC_Query_Ex();
         $_column = $column["column"];
         $_from = $column["from"];
         $_where = $column["where"];
         $column1 = sprintf("(%s)", $objQuery->getSql($_column, $_from, $_where));
         $subquery = $objQuery->getSql($column1, $table, $where, $arrWhereVal);
         $this->setWhere("{$_column} IN ({$subquery})");
     }
     if (is_array($arrWhereVal)) {
         foreach ($arrWhereVal as $value) {
             $this->arrVal[] = $value;
         }
     } elseif (!is_null($arrWhereVal)) {
         $this->arrVal[] = $arrWhereVal;
     }
 }
 /**
  * クエリを構築する.
  *
  * 検索条件のキーに応じた WHERE 句と, クエリパラメーターを構築する.
  * クエリパラメーターは, SC_FormParam の入力値から取得する.
  *
  * 構築内容は, 引数の $where 及び $arrValues にそれぞれ追加される.
  *
  * @param  string       $key          検索条件のキー
  * @param  string       $where        構築する WHERE 句
  * @param  array        $arrValues    構築するクエリパラメーター
  * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
  * @param  SC_FormParam $objDb        SC_Helper_DB_Ex インスタンス
  * @return void
  */
 public function buildQuery($key, &$where, &$arrValues, SC_FormParam &$objFormParam, SC_Helper_DB &$objDb)
 {
     $objSql = new SC_SelectSql_Ex();
     $objSql->setWhere($where);
     $objQuery = new SC_Query_Ex("", false, true);
     $data = array();
     $id = "product_id";
     $extends = true;
     $value = $objFormParam->getValue($key);
     switch ($key) {
         case "search_orderby":
             $column = "update_date";
             switch ($value) {
                 default:
                 case "date":
                     $column = "auto_display_start_date";
             }
             if ($objDb->sfColumnExists("dtb_products", $column)) {
                 $this->order = $column;
             }
             break;
         case "search_character_id":
             $sub_query = $objQuery->getSql($id, "cp_dtb_product_characters", "character_id=?");
             $objSql->setWhere("{$id} IN ({$sub_query})");
             $arrValues[] = $value;
             break;
         case "search_auto_display_status":
             if (is_array($value)) {
                 $data = $objSql->setItemTerm($value, "auto_display_status");
             } elseif (is_string($value)) {
                 $data = $objSql->setItemTerm((array) $value, "auto_display_status");
             }
             break;
         case "search_auto_display_start_date_start_year":
         case "search_auto_display_start_date_end_year":
         case "search_auto_display_end_date_start_year":
         case "search_auto_display_end_date_end_year":
         case "search_spass_provide_start_date_start_year":
         case "search_spass_provide_start_date_end_year":
         case "search_spass_provide_end_date_start_year":
         case "search_spass_provide_end_date_end_year":
             $y = $objFormParam->getValue($key);
             $m = $objFormParam->getValue(str_replace("_year", "_month", $key));
             $d = $objFormParam->getValue(str_replace("_year", "_day", $key));
             switch ($key) {
                 case "search_auto_display_start_date_start_year":
                     $data = $objSql->selectTermRange($y, $m, $d, "", "", "", "auto_display_start_date");
                     break;
                 case "search_auto_display_start_date_end_year":
                     $data = $objSql->selectTermRange("", "", "", $y, $m, $d, "auto_display_start_date");
                     break;
                 case "search_auto_display_end_date_start_year":
                     $data = $objSql->selectTermRange($y, $m, $d, "", "", "", "auto_display_end_date");
                     break;
                 case "search_auto_display_end_date_end_year":
                     $data = $objSql->selectTermRange("", "", "", $y, $m, $d, "auto_display_end_date");
                     break;
                 case "search_spass_provide_start_date_start_year":
                     $data = $objSql->selectTermRange($y, $m, $d, "", "", "", "spass_provide_start_date");
                     break;
                 case "search_search_spass_provide_start_date_end_year":
                     $data = $objSql->selectTermRange("", "", "", $y, $m, $d, "spass_provide_start_date");
                     break;
                 case "search_search_spass_provide_end_date_start_year":
                     $data = $objSql->selectTermRange($y, $m, $d, "", "", "", "spass_provide_end_date");
                     break;
                 case "search_search_spass_provide_end_date_end_year":
                     $data = $objSql->selectTermRange("", "", "", $y, $m, $d, "spass_provide_end_date");
                     break;
             }
             break;
         default:
             $extends = false;
             parent::buildQuery($key, $where, $arrValues, $objFormParam, $objDb);
     }
     if ($extends) {
         foreach ($data as $d) {
             $arrValues[] = $d;
         }
         $where = $objSql->getWhere();
     }
 }