class Model < ActiveRecord::Base
def raw_sql_query
connection.execute("select name from #{table_name}")
end
end
The above example will return something like this:
[{:name => "A"}, {:name => "B"}]
On Oct 29, 8:09 am, xxmithila <[EMAIL PROTECTED]> wrote:
> Hi all......
>
> please give me an example that use SQL in models to handel data in
> the data base. with "sql.execute" or any other possible way..
>
> thankx
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---