koloa
2006-Aug-13 17:06 UTC
[Rails] ruby and mysql syntax? tried single quotes, double, none, ...
Hi, how do i use passed in arguments and convert those to something sql can understand? do the aliases have to be double qouted? single qouted? i think i tried all but no avail...thanks! def get_count(doctype, towne) @profiles = Profile.count_by_sql("SELECT COUNT(*) from Profiles where Profiles.doctype_id = 1 and town_id = towne") end -- Posted via http://www.ruby-forum.com/.
Stephan Wehner
2006-Aug-13 17:15 UTC
[Rails] Re: ruby and mysql syntax? tried single quotes, double, none
koloa wrote:> > > > Hi, how do i use passed in arguments and convert those to something sql > can understand? do the aliases have to be double qouted? single qouted? > i think i tried all but no avail...thanks! > > > def get_count(doctype, towne) > > @profiles = Profile.count_by_sql("SELECT COUNT(*) from Profiles where > Profiles.doctype_id = 1 and town_id = towne") > > endTry Profile.count_by_sql(["SELECT COUNT(*) from Profiles where Profiles.doctype_id = ? and town_id = ?", doctype, towne]) or look for examples at http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870 Stephan -- Posted via http://www.ruby-forum.com/.
koloa
2006-Aug-13 18:34 UTC
[Rails] Re: ruby and mysql syntax? tried single quotes, double, none
Hello Stephan, Thanks! -- Posted via http://www.ruby-forum.com/.
Salil Gaikwad
2009-Apr-10 10:43 UTC
Re: ruby and mysql syntax? tried single quotes, double, none
> > or look for examples at > > http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870 > > StephanHi Stephan, i have the same issue as discuss here. i try above given link but it is not working. could you give me the other link or some direction to avoid the Double Quotes problem. Thanks Salil -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---