3 ms·
I don't like ORMs much, admittedly mostly because I did a fair amount of development with SQL before they existed. But, there was one that I played with that d
by tyingq 4y ago
I don't like ORMs much, admittedly mostly because I did a fair amount of development with SQL before they existed.
But, there was one that I played with that did have appeal to me, RedBeanPHP.
Forgetting that it's PHP for a minute...that's not the main point. It was cool because it had a fluid way of working. It automatically generates the database, tables and columns... on-the-fly, and infers table relations based on naming conventions and how you interact with code. No config files at all.
So, you would iterate in dev solely by writing code, and end up with a schema including foreign relationships. Then, you can "freeze" the schema for prod, turning off all the dynamic stuff.
Their quick tour explains it well: https://redbeanphp.com/index.php?p=/quick_tour https://redbeanphp.com/index.php?p=/quick_tour
Note: I'm sure it has notable downsides over time, but the approach was really nice starting from scratch.
- Aperocky 4y agoORM is a great way to scale yourself.
- runevault 4y agoORMs where you don't write sql make me nervous, though it doesn't help the main version of this I used was raw linq-to-sql (not Entity Framework), and it could be very hard to convince linq to generate the correct sql for what I was doing (I once had to write my relationships backwards else it kept generating sub queries). But .NET also has Dapper where it lets you write all the SQL and then it just handles the binding of data into objects, which having that handled for me is great.
- tyingq 4y agoIt does allow for query access also: https://redbeanphp.com/index.php?p=/querying https://redbeanphp.com/index.php?p=/querying But, yeah, that's not the normal path.
- somenameforme 4y agoI had a positive experience with Linq2db: https://github.com/linq2db/linq2db https://github.com/linq2db/linq2db I mention because I had something of the opposite experience with it. It not only ended up yielding the correct queries, but I saw a significant increase in performance. And the neat thing about it, beyond ORM and linq-to-sql, is a common interface amongst providers - so you can do things like swap from SQLite to Postgres with 1 line* of code, so long as you're not using provider specific extensions.
- runevault 4y agoHuh interesting. If I ever do any personal projects that need a DB I'll have to take a look at this. Appreciate the link.
- JodieBenitez 4y agoRedbean is really nice. Long ago I wrote a python/sqlite implementation as an exercise. Module here: https://gist.github.com/johndoe46/40c0f993a641fe7a3eb74bd6d67af7da https://gist.github.com/johndoe46/40c0f993a641fe7a3eb74bd6d6... Also tests: https://gist.github.com/johndoe46/17eacf0f12772dfb870732479b91dc72 https://gist.github.com/johndoe46/17eacf0f12772dfb870732479b... (This is proof of concept quality, don't use for real work)
- mgkimsal 4y agoI loved redbean for a while. Sort of a mix of 'nosql' up front, but it's being baked in to a relational DB. I did a number of small projects extremely quickly with redbeanphp. You're making me want to go explore it again :) EDIT:... well... I see it's still got an aim of being PHP5 compatible. Upgrades for PHP 8.1, but that seems off a bit. I seem to remember composer was an issue... and there still is. Impressive that the author is still evolving and supporting it :)