In php codeigniter FW, I can do it easily by using get_compiled_select() method.
Is there any method that I can convert the query build by active record to raw sql. Ex:
User.find_by_name("abc")
should return raw query script something like
select * from user where name = "abc"
You can use to_sql
(it gives you a sql query string, and can be called on any ActiveRecord association):
User.find_by_name("abc").to_sql
http://apidock.com/rails/ActiveRecord/Relation/to_sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With