Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. sql = 'SELECT ctr.id, ctr.code as country_code, ctr.name as country_name, c.id, c.country_id,
  2. c.code as city_code, c.name as city_name, a.code as airport_code, a.name as airport_name, a.city_id
  3. FROM countries AS ctr INNER JOIN cities AS c INNER JOIN airports AS a
  4. WHERE ctr.id = c.country_id AND a.city_id = c.id AND (ctr.name = ? OR ctr.code = ? OR c.name = ? OR c.code = ? OR a.code = ? OR a.name = ?)'
  5. sql = ActiveRecord::Base.send(:sanitize_sql_array, [sql, name.upcase, name, name.upcase, name, name.upcase, name])
  6. result_hash = ActiveRecord::Base.connection.execute(sql)
  7.  
  8. ## Old sql query (same error)
  9. sql = 'SELECT ctr.id, ctr.code as country_code, ctr.name as country_name, c.id, c.country_id,
  10. c.code as city_code, c.name as city_name, a.code as airport_code, a.name as airport_name, a.city_id
  11. FROM countries AS ctr INNER JOIN cities AS c INNER JOIN airports AS a
  12. ON ctr.id = c.country_id AND a.city_id = c.id
  13. WHERE ctr.name = ? OR ctr.code = ? OR c.name = ? OR c.code = ? OR a.code = ? OR a.name = ?'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement