예제 #1
0
function _db_admin_empty_filename($tbl, $image_filename, $column = 'image_filename', $pkey = null)
{
    $data = array(db_escapeIdentifier($column) => '');
    if ($pkey) {
        $where[$tbl . '_id'] = (int) $pkey;
    }
    $where[db_escapeIdentifier($column)] = $image_filename;
    db_update(db_escapeIdentifier($tbl), $data, $where);
}
예제 #2
0
function kanshi_db_admin_empty_image_filename($tbl, $image_filename, $column = 'image_filename')
{
    $data = array(db_escapeIdentifier($column) => '');
    $where = array(db_escapeIdentifier($column) => $image_filename);
    db_update(db_escapeIdentifier($tbl), $data, $where);
}
예제 #3
0
function db_member_search($cond, $cond_like, $page_size, $page, $c_member_id, $profiles)
{
    $page = intval($page);
    $page_size = intval($page_size);
    $wheres = array();
    $params = array();
    foreach ($cond as $key => $value) {
        if ($value) {
            if ($key === 'image') {
                $wheres[] = "image_filename <> '' AND image_filename <> '0'";
            } else {
                $wheres[] = db_escapeIdentifier($key) . ' = ?';
                $params[] = $value;
                if ($key === 'birth_year') {
                    $wheres[] = "public_flag_birth_year = 'public'";
                } elseif ($key === 'birth_month' || $key === 'birth_day') {
                    $wheres[] = "public_flag_birth_month_day = 'public'";
                }
            }
        }
    }
    foreach ($cond_like as $key => $value) {
        if ($value) {
            $wheres[] = db_escapeIdentifier($key) . ' LIKE ?';
            $params[] = '%' . $value . '%';
        }
    }
    if ($wheres) {
        $where = ' WHERE ' . implode(' AND ', $wheres);
    } else {
        $where = '';
    }
    $from = " FROM c_member" . $hint;
    $order = " ORDER BY c_member_id DESC";
    $sql = "SELECT c_member_id" . $from . $where . $order;
    $result_ids = db_get_col($sql, $params);
    // 検索設定を公開にしていないメンバーを除外
    $sql = "SELECT c_member_id FROM c_member_config WHERE name = 'IS_SEARCH_RESULT' AND value = '0'";
    $ids = db_get_col($sql);
    $result_ids = array_diff($result_ids, $ids);
    foreach ($profiles as $key => $value) {
        $sql = "SELECT c_member_id FROM c_member_profile";
        $sql .= " WHERE c_profile_id = ? AND public_flag = 'public'";
        $params = array(intval($value['c_profile_id']));
        if ($value['form_type'] == "text" || $value['form_type'] == "textlong" || $value['form_type'] == 'textarea') {
            $sql .= " AND value LIKE ?";
            $params[] = '%' . $value['value'] . '%';
        } elseif (is_array($value['c_profile_option_id'])) {
            $values = implode(',', array_map('intval', $value['c_profile_option_id']));
            $sql .= " AND c_profile_option_id IN (" . $values . ")";
        } else {
            $sql .= " AND c_profile_option_id = ?";
            $params[] = intval($value['c_profile_option_id']);
        }
        $ids = db_get_col($sql, $params);
        $result_ids = array_intersect($result_ids, $ids);
    }
    $result_ids = array_values($result_ids);
    $start = ($page - 1) * $page_size;
    $list = array();
    for ($i = $start; $i < $start + $page_size && $result_ids[$i]; $i++) {
        $c_member = db_member_c_member_with_profile($result_ids[$i], 'public');
        $c_member['last_login'] = p_f_home_last_login4access_date($c_member['access_date']);
        $list[] = $c_member;
    }
    $total_num = count($result_ids);
    if ($total_num != 0) {
        $total_page_num = ceil($total_num / $page_size);
        if ($page >= $total_page_num) {
            $next = false;
        } else {
            $next = $page + 1;
        }
        if ($page <= 1) {
            $prev = false;
        } else {
            $prev = $page - 1;
        }
    }
    return array($list, $prev, $next, $total_num);
}