Created
December 25, 2021 16:20
-
-
Save banguyenht/7040a7a63ee769814ee4a65b862da67d to your computer and use it in GitHub Desktop.
mysql adapter rails
This file contains 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
``` | |
SQL_STRING = <<~"SQL_STRING" | |
SELECT COUNT(*) as total_aritcle, users.name | |
FROM | |
INNER JOIN articles ON users.id = articles.user_id | |
GROUP BY | |
users.id | |
SQL_STRING | |
``` | |
`ActiveRecord::Base.connection.exec_query SQL_STRING` | |
`ActiveRecord::Base.connection.select_all SQL_STRING` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ActiveRecord::Base.sanitize_sql_array([INDEX_SQL, @from, to])