Skip to content

@stojg /ORM.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ORM scratch board
<?php
/*
Ideas on ORM interface and interactions / relationships
*/
class Dataobject {
function __construct(Data $mapper, array $data = null) {
$this->mapper = $mapper;
if($data) {
$this->record = $data;
}
}
function write() {
$this->mapper()->write($this);
}
}
class Controller {
function doSave() {
$obj = new DataObject();
MongoData::inst()->write($obj);
}
}
// name is WIP ;)
class Data implements DataMapper {
function getByID($id) {
return $this->dataQuery()->select()->where(...);
}
// special super duper fast
function getObjectVeryFast) {
$data = $this->getLatestFromMemcached();
return new DataObject($this, $data);
}
function write(DataObject $object) {
// Do data integrity validation here?
if($object->exists()) {
$this->dataQuery()->update($object);
} else {
$this->dataQuery()->insert($object);
}
$this->latestToMemcached($object);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.