ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 11604


Ignore:
Timestamp:
May 8, 2009, 11:00:02 PM (13 years ago)
Author:
nagasawa
Message:

#3853:プロフィール追加項目の文字列検索の速度が遅かった問題を改善

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE/branches/work/nagasawa/3853/member.php

    r11409 r11604  
    303303    foreach ($profiles as $key => $value) {
    304304        if (!$first) $sql .= ' AND';
    305         $sql .= " c_member_id IN (SELECT c_member_id FROM c_member_profile";
    306         $sql .= " WHERE c_profile_id = ? AND public_flag = 'public'";
    307         $params[] = intval($value['c_profile_id']);
     305        $sql .= " c_member_id IN (";
    308306
    309307        if ($value['form_type'] == "text" || $value['form_type'] == "textlong" || $value['form_type'] == 'textarea') {
    310             $sql .= " AND value LIKE ?";
    311             $params[] = '%'.$value['value'].'%';
    312         } elseif (is_array($value['c_profile_option_id'])) {
    313             $values = implode(',', array_map('intval', $value['c_profile_option_id']));
    314             $sql .= " AND c_profile_option_id IN (". $values .")";
    315         } else {
    316             $sql .= " AND c_profile_option_id = ?";
    317             $params[] = intval($value['c_profile_option_id']);
     308            $sub_sql = "SELECT c_member_id FROM c_member_profile";
     309            $sub_sql .= " WHERE c_profile_id = ? AND public_flag = 'public'";
     310            $sub_sql .= " AND value LIKE ?";
     311            $sub_params = array(intval($value['c_profile_id']), '%'.$value['value'].'%');
     312            $result_ids = db_get_col($sub_sql, $sub_params);
     313            $sql .= implode(',', array_map('intval', $result_ids));
     314        } else{
     315            $sql .= "SELECT c_member_id FROM c_member_profile";
     316            $sql .= " WHERE c_profile_id = ? AND public_flag = 'public'";
     317            $params[] = intval($value['c_profile_id']);
     318            if (is_array($value['c_profile_option_id'])) {
     319                $values = implode(',', array_map('intval', $value['c_profile_option_id']));
     320                $sql .= " AND c_profile_option_id IN (". $values .")";
     321            } else {
     322                $sql .= " AND c_profile_option_id = ?";
     323                $params[] = intval($value['c_profile_option_id']);
     324            }
    318325        }
    319326        $sql .= ")";
Note: See TracChangeset for help on using the changeset viewer.