3 ms·
Two things sometimes irk me: How much code there is to write for simple DB interaction + coupling of two different languages (SQL + [programming lang]). In Rai
by preek 15y ago
Two things sometimes irk me: How much code there is to write for simple DB interaction + coupling of two different languages (SQL + [programming lang]).
In Rails I'd write:
Folk.create(:name => some_name, :addr => some_addr, :city => some_city)
One line, easily readable and only one language (Ruby).
This is not meant to be a flame post - I'm just asking: Is it the preferred way in PHP to prepare SQL statements yourself?
- duskwuff 15y agoActiveRecord is an abstraction. Which is good in general, but when you want to get your hands dirty with some SQL it's a pretty serious hindrance.
- wavesplash 15y agoActiveRecord lets you write raw sql any time you need to. AR's design goal was to just reduce the drudgery, not prevent you from using the full power of sql. No 'serious hindrance' involved.
- 1880 15y agoWell, if you use a PHP framework or library, of course there are easier and less verbose ways to prepare SQL statements. I don't think RoR vs PHP would be an apples to apples comparison.
- smackfu 15y agoIt's only "one language" because the Rails framework is hiding the SQL away from you. You can bolt a framework on top of PHP too.
- mh- 15y agothis reply isn't meant to be a flame, but- Do you not understand why you can't compare Rails (framework) to PHP (language)? PHP has frameworks with ORM, too.