All pastes #31252 Raw Edit

Mine

public text v1 · immutable
#31252 ·published 2005-11-25 23:16 UTC
rendered paste body
  # Fulltext searches the body of published articles   def self.search(query)     if !query.to_s.strip.empty?
      tokens = query.split.collect {|c| "%#{c.downcase}%"}
      find_by_sql(["SELECT * FROM #{Article.table_name} WHERE #{Article.table_name}.published != 0 AND #{ (["(LOWER(body) LIKE ? OR LOWER(extended) LIKE ? OR LOWER(title) LIKE ?)"] * tokens.size).join(" AND ") } AND published != 0 AND type = 'Article' ORDER by created_at DESC", *tokens.collect { |token| [token] * 3 }.flatten])
    else
      []
    end
  end