Skip to content

Instantly share code, notes, and snippets.

@banguyenht
Created December 25, 2021 16:20
Show Gist options
  • Save banguyenht/7040a7a63ee769814ee4a65b862da67d to your computer and use it in GitHub Desktop.
Save banguyenht/7040a7a63ee769814ee4a65b862da67d to your computer and use it in GitHub Desktop.
mysql adapter rails
```
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`
@banguyenht
Copy link
Author

ActiveRecord::Base.sanitize_sql_array([INDEX_SQL, @from, to])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment