本文整理汇总了PHP中SC_Query_Ex::getSql方法的典型用法代码示例。如果您正苦于以下问题:PHP SC_Query_Ex::getSql方法的具体用法?PHP SC_Query_Ex::getSql怎么用?PHP SC_Query_Ex::getSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SC_Query_Ex
的用法示例。
在下文中一共展示了SC_Query_Ex::getSql方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectSubquery
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;
}
}
示例2: buildQuery
/**
* クエリを構築する.
*
* 検索条件のキーに応じた 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();
}
}