我正面臨着數據中存在這樣的問題。搜索時不顯示數據。我想刪除SQL注入問題 代碼::MySql Query ::如何解決數據中的問題,當查詢被觸發時
@search_condition = ""
if !search_text.nil?
search_field = search_text.split("-")
@search_condition = "(address_books.organization_name like '#{search_text}%' or address_books.business_name like '#{search_text}%' or address_books.federal_tax_id like '#{search_text}%' or address_books.city like '#{search_text}%' or address_books.zip like '#{search_text}%') " if search_field.length == 1
if search_text.include? "-"
if search_field.length <= 1
@search_condition = " (address_books.organization_name like '%" + search_field[0] + "%' "
@search_condition += " or address_books.business_name like '%" + search_field[1] + "%' "
@search_condition += " or address_books.federal_tax_id like '%" + search_field[2] + "%' "
@search_condition += " or address_books.city like '%" + search_field[3] + "%' "
@search_condition += " or address_books.zip like '%" + search_field[4] + "%') "