I have a list that is sortable via drag drop. Currently if there are X items in the list, I have to call X sql statements. It is valid to pass multiple sql statements to mysql, but when I concatenate the statements together and then try to call them all at once with AR it throws an error. Is this possible with AR? _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
David Heinemeier Hansson
2005-Sep-17 12:40 UTC
Re: Muliple SQL Statements using ActiveRecord
> I have a list that is sortable via drag drop. Currently if there are X > items in the list, I have to call X sql statements. It is valid to pass > multiple sql statements to mysql, but when I concatenate the statements > together and then try to call them all at once with AR it throws an error. > Is this possible with AR?What would be the benefit of doing so? MySQL still has to execute all the statements separately. The overhead of sending MySQL a query is extremely unlikely to be a bottleneck in your application (unlike the time it takes MySQL to process that query). But if you must, ActiveRecord::Base.connection.execute("STATEMENT1; STATEMENT2") should work. -- David Heinemeier Hansson http://www.loudthinking.com -- Broadcasting Brain http://www.basecamphq.com -- Online project management http://www.backpackit.com -- Personal information manager http://www.rubyonrails.com -- Web-application framework