Created
October 4, 2011 08:05
-
-
Save heijmerikx/1261118 to your computer and use it in GitHub Desktop.
MySQL FIND_IN_SET to Postgresql...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.order(ids) | |
# The postgresql way | |
update_all(["position = STRPOS(?, ','||id||',')", ",#{ids.join(',')},"], { :id => ids }) | |
# the mysql way | |
# update_all(['position = FIND_IN_SET(id, ?)', ids.join(',')],{ :id => ids }) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment