News for hackers. Stuff that matters.
Re:DumbledORM a novelty PHP ORM in < 200 lines by zemaj on Thursday October 28, 2010 @10:33PM (#1845820)
That'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.

Re:DumbledORM a novelty PHP ORM in < 200 lines by 8ren on Thursday October 28, 2010 @11:05PM (#1845922)
Indent with double space, to get this:

  hello
  world
http://news.ycombinator.com/formatdoc (this used to be in a help link next to the reply box, but seems to be gone now).
Re:DumbledORM a novelty PHP ORM in < 200 lines by zemaj on Saturday October 30, 2010 @05:24AM (#1850509)
Ah, thanks! I actually spent a bit of time trying to find how to format code without any luck.
Re:DumbledORM a novelty PHP ORM in < 200 lines by rtuck on Friday October 29, 2010 @03:33AM (#1846499)
If you're going to upgrade to 5.3 (which you should!), I would highly recommend Doctrine 2 (not 1, very different project). It's a loose port of Hibernate from Java and takes a very different tack then most PHP ORMs. The models have no mandatory base class, the pattern is more Data Mapper then Active Record, it allows batch flushing to the database, has associations, and has some really great features like inheritance mapping and an event hook system.

There are pieces to dislike (arguably DQL, soft deletes are almost impossible, etc) but so far, it's a huge step forward from the likes of Zend_Db_Table or Doctrine 1.

http://www.doctrine-project.org/projects/orm/2.0/docs/refere...

Re:DumbledORM a novelty PHP ORM in < 200 lines by terryjsmith on Thursday October 28, 2010 @11:10PM (#1845941)
I'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#9...

Re:DumbledORM a novelty PHP ORM in < 200 lines by ErrantX on Friday October 29, 2010 @08:17AM (#1847003)
It's Kohana (framework) specific but Jelly [1] is pretty solid.

1. http://jelly.jonathan-geiger.com/

Re:DumbledORM a novelty PHP ORM in < 200 lines by adatta02 on Friday October 29, 2010 @12:30AM (#1846122)
check out Doctrine - 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.

Re:DumbledORM a novelty PHP ORM in < 200 lines by jasonmoo on Friday October 29, 2010 @12:34AM (#1846136)
Yeah I've had a lot of experience with Doctrine. Had to roll my own orm on a previous project due to certain requirements and have been playing with orms since. Doctrine has a lot of nice standards and a good community around it.
Re:DumbledORM a novelty PHP ORM in < 200 lines by jasonlotito on Friday October 29, 2010 @08:39AM (#1847064)
I love Doctrine at work. I hate it at home. It's a great standardised system that that has a lot of great features we use, but for simple projects at home, it's far too cumbersome to set up.