Feb
20
define("CRITERIA_TOTAL_TYPE_ARRAY", "OVER_18, FEMALE_28");
根据此条件取出所有年龄超过18,并且如果性别是FEMALE>28的数据。
$criteria_sql = "";
if ($criteria_flg) {
$user_sql = "";
// OVER_18, FEMALE_28
$param_list = explode(",", CRITERIA_TOTAL_TYPE_ARRAY);
$over_age = explode("_", $param_list[0]);
if (isset($over_age[1])) {
$user_sql .= " and date_trunc('day', birthday) < '" . date("Y-m-d", strtotime("-" . $over_age[1] . " year")) . "'";
}
if (isset($param_list[1])) {
$sex_age = explode("_", $param_list[1]);
$sex = trim($sex_age[0]);
$user_sql .= " and (sex !='" . $sex . "' or (sex='" . $sex . "' and date_trunc('day', birthday) < '" . date("Y-m-d", strtotime("-" . $sex_age[1] . " year")) . "'))";
}
if (!empty($user_sql)) {
$criteria_sql = " inner join (select * from user_mst where delete_flg=false " . $user_sql . ") as u on (u.id=pad.user_id)";
}
}
根据此条件取出所有年龄超过18,并且如果性别是FEMALE>28的数据。
$criteria_sql = "";
if ($criteria_flg) {
$user_sql = "";
// OVER_18, FEMALE_28
$param_list = explode(",", CRITERIA_TOTAL_TYPE_ARRAY);
$over_age = explode("_", $param_list[0]);
if (isset($over_age[1])) {
$user_sql .= " and date_trunc('day', birthday) < '" . date("Y-m-d", strtotime("-" . $over_age[1] . " year")) . "'";
}
if (isset($param_list[1])) {
$sex_age = explode("_", $param_list[1]);
$sex = trim($sex_age[0]);
$user_sql .= " and (sex !='" . $sex . "' or (sex='" . $sex . "' and date_trunc('day', birthday) < '" . date("Y-m-d", strtotime("-" . $sex_age[1] . " year")) . "'))";
}
if (!empty($user_sql)) {
$criteria_sql = " inner join (select * from user_mst where delete_flg=false " . $user_sql . ") as u on (u.id=pad.user_id)";
}
}




