TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

DumbledORM a novelty PHP ORM in < 200 lines

43 pointsby jasonmooover 14 years ago

7 comments

zemajover 14 years ago
That's pretty cool. I like the method chaining.<p>There's definitely a need for a 'great' PHP ORM. I've been rolling my own for a couple of years since I've never been satisfied with what's out there. Here's the kind of syntax/style I use on mine (that class definition is the entire code I need to write to get working abstraction).<p>class Person extends Model {<p>const TABLE_NAME = 'people';<p>const TABLE_KEY = 'id';<p>}<p>$person = Model::find("Person", 1234);<p>$person-&#62;name = "James";<p>$person-&#62;save();<p>$persons_named_james = Model::find("Person", array("name" =&#62; "James"));<p>foreach($persons_named_james as $person) {<p>print $person-&#62;age;<p>}<p>$person = new Person();<p>$person-&#62;age = 26;<p>$person-&#62;save();<p>I should really upgrade to 5.3 so I could write Person::find(1234); instead.
评论 #1845922 未加载
评论 #1846499 未加载
评论 #1845941 未加载
评论 #1847003 未加载
评论 #1846122 未加载
nreeceover 14 years ago
Looks alright. I'll try it out sometime.<p>I've been using Idiorm - <a href="http://github.com/j4mie/idiorm" rel="nofollow">http://github.com/j4mie/idiorm</a> (used it on Weekis - <a href="http://weekis.com" rel="nofollow">http://weekis.com</a>). It works really well for small-medium scale apps.<p>I can't be bothered with the bloat of some of the PHP Frameworks out there.
评论 #1846504 未加载
评论 #1846273 未加载
stefsover 14 years ago
it looks very nice, really!<p>* do you write all your code without comments, or do you strip them out afterwards to get to save locs? imho you should forget the 200 loc constraint and make your code pretty instead - it looks anorectic. seesh, yes i know the 200 loc promise is your main selling point to make the project stand out ;)<p>* a namespace would be a good idea here. "Builder", "Db" and "ResultSet" aren't that uncommon.<p>* defining the connection credentials as a class with consts smells <i>funny</i>.
评论 #1847303 未加载
jamongkadover 14 years 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.
评论 #1846741 未加载
评论 #1846668 未加载
aw3c2over 14 years ago
I checked the site, I checked Github, but I still have no idea what "ORM" means.<p>Wikipedia suggests several different meanings which seem to fit: Object-relational mapping, Object role modeling, Online Reputation Management, Online research methods, Outsourcing Relationship Management
评论 #1846915 未加载
评论 #1847341 未加载
armandososaover 14 years ago
I like it very much. Now I want to build something just to play with it.<p>It's awesome how much cool stuff can be accomplished when not supporting PHP4. I'd like to see more libraries taking advantage of 5.3<p>Have you thought of using pearhub.org for distribution?
评论 #1846126 未加载
beagledudeover 14 years ago
awesome work, I've always avoided the php orm's because of the bloat factor. Gonna check it out now.
评论 #1846143 未加载