5 ms·
DumbledORM a novelty PHP ORM in < 200 lines
- nreece 16y agoLooks alright. I'll try it out sometime. I've been using Idiorm - http://github.com/j4mie/idiorm http://github.com/j4mie/idiorm (used it on Weekis - http://weekis.com http://weekis.com). It works really well for small-medium scale apps. I can't be bothered with the bloat of some of the PHP Frameworks out there.
- bryanh 16y agoI'll second Idiorm, we use it on http://rothira.com/ http://rothira.com/ for all the simple stuff like saving leads. It's perfectly lightweight for something like that.
- j4mie 16y agoThanks for the Idiorm mention :) I like the look of DumbledORM, although it takes a bit of a different approach to Idiorm (and its "child" project, Paris - http://github.com/j4mie/paris http://github.com/j4mie/paris - which is an Active Record implementation with support for associations built on top of Idiorm in ~130 lines of code). I'm not really a fan of code generation at the best of times, and for a tiny ORM it seems a bit out of place. I do like the idea of being able to save multiple rows, jQuery-style. I might just steal that..
- beagledude 16y agoawesome work, I've always avoided the php orm's because of the bloat factor. Gonna check it out now.
- jasonmoo 16y agothanks! is this regal beagle dude?
- beagledude 16y agoindeed! :) played with it last night and it worked right out of the box. Definitely going to be trying this out for all my CRUD stuff. nice work moo.
- zemaj 16y agoThat's pretty cool. I like the method chaining. 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). class Person extends Model { const TABLE_NAME = 'people'; const TABLE_KEY = 'id'; } $person = Model::find("Person", 1234); $person->name = "James"; $person->save(); $persons_named_james = Model::find("Person", array("name" => "James")); foreach($persons_named_james as $person) { print $person->age; } $person = new Person(); $person->age = 26; $person->save(); I should really upgrade to 5.3 so I could write Person::find(1234); instead.
- 8ren 16y agoIndent with double space, to get this: hello world http://news.ycombinator.com/formatdoc http://news.ycombinator.com/formatdoc (this used to be in a help link next to the reply box, but seems to be gone now).
- zemaj 16y agoAh, thanks! I actually spent a bit of time trying to find how to format code without any luck.
- terryjsmith 16y agoI've actually used tom's code from the PHP.net site to replicate the get_called_class function when it's not there in my own framework: http://www.php.net/manual/en/function.get-called-class.php#92845 http://www.php.net/manual/en/function.get-called-class.php#9...
- adatta02 16y agocheck out Doctrine - http://www.doctrine-project.org/ http://www.doctrine-project.org/ syntas like $peopleNamedJames = Doctrine::getTAble("Person")->findByName("James"); foreach( $peopleNamedJames as $person ){ echo $person->getAge(); } It's very Hibernate'esqe in some regards also.
- armandososa 16y agoI like it very much. Now I want to build something just to play with it. 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 Have you thought of using pearhub.org for distribution?
- jasonmoo 16y agoThanks. Interesting idea. I hadn't considered distribution. Looks pretty sweet. I'll check it out.
- jamongkad 16y agoNice 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.
- stefs 16y agoit'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.
- loewenskind 16y agoI 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.
- stefs 16y agoit looks very nice, really! * 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 ;) * a namespace would be a good idea here. "Builder", "Db" and "ResultSet" aren't that uncommon. * defining the connection credentials as a class with consts smells funny.
- deleted 16y ago[deleted]
- aw3c2 16y agoI checked the site, I checked Github, but I still have no idea what "ORM" means. Wikipedia suggests several different meanings which seem to fit: Object-relational mapping, Object role modeling, Online Reputation Management, Online research methods, Outsourcing Relationship Management
- monos 16y agoin this context 'Object-relational mapping' is the most likely meaning.
- bmelton 16y agoORM = Object Relational Mapping Put as simply as I can put it, it's an abstraction layer in front of SQL. The general logic (which I object to, though I still prefer ORM-based development) is that most of your class Objects relate to how you would store them in a database. Your 'User' object has a first name, a last name, a password, etc., which all map neatly to database records. So, instead of doing "INSERT INTO users firstname, lastname, password) VALUES ('foo', 'bar', 'baz');", you create a user object: User.firstname = 'foo' User.lastname = 'bar' User.password = 'baz' User.save()
- aw3c2 16y agoThank you!