Hacker News new | ask | show | jobs
by jamongkad 5711 days ago
Nice but is there any mention in the article about support for just writing plain old SQL? I love the ideas of ORMs (my app now currently uses SQLAlchemy) but I find myself dropping back to SQL when things get a little complex. I think new age ORMs should leave support for dropping back to SQL. Cool project nonetheless.
2 comments

I don't think they need to provide SQL support so long as they provide something that's equivalent. For example in C#, nHibernate has the Restriction classes (and Linq). They can be a little clunky compared to SQL but it can be fully type checked.
it's always possible to bypass whatever ORM you use by using plain PDO/SQL, but then all the features an ORM provides are lost.

but mixing ORMs with custom SQL would be a challenge, because the results couldn't be mapped to relational tables anymore.

by the way, you can reuse dumbledORMs PDO-instance - $conn = Db::pdo() - and even the query method (preparing, executing and fetching) is public too.

i didn't look into the hydrate method, but it seems it is possible to map results from custom queries to ORM objects.