4 ms·
Yes, if you already know SQL and by using bind-parameters, then I [personally] can't see a tangible benefit for using an ORM. They can certainly make for clean
by acutesoftware 8y ago
Yes, if you already know SQL and by using bind-parameters, then I [personally] can't see a tangible benefit for using an ORM.
They can certainly make for cleaner looking code, and are useful for people who don't really understand the database schema, but not worth the added complexity.
- timrichard 8y agoJust to mention another alternative, I've been using a QueryBuilder library on the last two projects. The code's prettier than it would be with raw SQL, plus there aren't ORM downsides.
- pserwylo 8y agoGood point. We had great success doing this with our PHP code base. For us it wasn't about pretty or not-pretty code, but rather about type safety. The idea that you can have a method which accepts "WhereClause $constraints" instead of "string $constraints" means you can be much more confident that the code is correct. We actually wrote a custom query builder because none of the available ones (e.g. Doctrine) had the type safety that we desired. A direct parallel to what we used is the Java library JOOQ, in terms of its querybuilder API [0]. [0] https://www.jooq.org/doc/3.10/manual/sql-building/sql-statements/dsl-and-non-dsl/ https://www.jooq.org/doc/3.10/manual/sql-building/sql-statem...
- Allstar 8y agoSame here, we use Knex.js Querybuilder to build queries and fallback to `knex.raw()` for very specific SQL queries.
- timrichard 8y agoAh, coincidence... Knex is the one I've been using too :-)