Hi,
I have a complex SQL request to perform. I don''t want to manually do
the
whole query (find_by_sql) because of the complex joins, but I want to
use MySQL functions, such as:
Model.find(:all,
:include => [../..],
:conditions => ["(../..) AND
YEAR(STR_TO_DATE(my_table.my_row,''%Y-%m-%d %H:%i:%s'')) =
#{year})"],
:select => [../..])
or
Model.find(:all,
:include => [../..],
:conditions => ["(../..) AND
YEAR(STR_TO_DATE(my_table.my_row,GET_FORMAT(DATETIME,''ISO'')))
= #{year})"],
:select => [../..])
Is there a way to combine the power of AR and SQL functions?
In the example above, I could use Ruby Time Class but what can I do if I
want to use more specific SQL syntax (UNION, ...). I guess I have to
make the joins by hand with find_by_sql?
--
,========================.
| Pierre-Alexandre Meyer |
| email : pam-1sEOgp2Wo8Qdnm+yROfE0A@public.gmane.org |
`========================''
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---