Posts Tagged ‘dumbledorm’

DumbledORM version 0.1 released!

Monday, December 20th, 2010

I’m happy to announce the release of DumbledORM 0.1. It’s a major revamp from the initial release. It’s still the same ~200 loc, but now chocked full of comments and under the MIT license.

A few noteworthy changes.

  1. PDO now throws exceptions by default. The standard default in PDO is to fail silently. This was unintended and thanks to @jimplush for reporting it. Be sure to try/catch your code appropriately.
  2. Db::execute() method added. All of the Db methods are publicly accessible and this method is for executing sql that doesn’t require a fetch (inserts, updates, deletes, etc). The requirement for this method became clear after turning on exceptions in PDO.
  3. Better docs. The docs in the README have been updated and reformatted.

DumbledORM received a lot of great feedback and attention after it’s release. Thank you for all the positive response to this little ORM. I hope it continues to grow in use and remains small in size. :)

Download DumbledORM and get started here:
https://github.com/jasonmoo/DumbledORM

Introducing DumbledORM a novelty ORM

Thursday, October 28th, 2010

I’m proud to release DumbledORM today. It is the product of a late night hack sesh with an idea to build a PHP ORM in less than 100 lines. After it’s all said and done I arrived at 200 lines with lots of features. The decision to call it DumbledORM came after realizing there was more casting and magic in it than anything out there. :)

Some examples of what it can do:

// load record with id 13
$user = new User(13);  
$user->setName('Jason')->save();

// create new record
$user = new User(array(
  'name' => 'Jason', 
  'email' => 'jasonmoo@me.com', 
));
$user->save();

// find single record
User::one(array('name' => 'Jason'))->delete();

// apply object methods to entire set at once
PhoneNumber::select('`number` like "607%"')
  ->setLocation('Ithaca, NY')
  ->save();

// relations between objects
$user->create(new PhoneNumber(array(
  'type' => 'home', 
  'number' => '607-333-2840', 
)))->save();

// update all user phone numbers matching $type
$user->getPhoneNumber('`type` = ?',$type)
  ->setType($new_type)
  ->save();

Applying model object methods to entire sets of objects, jQuery style, is made possible by this incantation:

final class ResultSet extends ArrayIterator {
  public function __call($method,$params=array()) {
    foreach ($this as $obj) {
      call_user_func_array(array($obj,$method),$params);
    }
    return $this;
  }
}

So proud. I hope you find it fun and maybe even useful. Although at this point all I can say is that it’s passing it’s little tests.