@ -126,21 +126,26 @@ class SchoolController < ApplicationController
chinese<<char
end
end
ifpinyin.size>0
search_str="name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'"
else
search_str="name like '%#{chinese.join("")}%'"
end
ifparams[:no_school_ids]
if(condition=='')
@school=School.where("id not in #{params[:no_school_ids]}").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.count
else
@school=School.where("id not in #{params[:no_school_ids]} and name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.where("id not in #{params[:no_school_ids]} and name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count
@school=School.where("id not in #{params[:no_school_ids]} and #{search_str}").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.where("id not in #{params[:no_school_ids]} and #{search_str}").count
end
else
if(condition=='')
@school=School.reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.count
else
@school=School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)
@school_count=School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").count
@school=School.where(search_str).reorder('CONVERT (name USING gbk) COLLATE gbk_chinese_ci asc').page((params[:page].to_i||1)).per(100)