Skip to content

Commit

Permalink
Tidy up in preparation for implementing model initialisation (via mod…
Browse files Browse the repository at this point in the history
…el schema)
  • Loading branch information
isofarro committed Apr 10, 2010
1 parent 8e96215 commit 9024b9c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
6 changes: 5 additions & 1 deletion IsotopeOrm.php
Expand Up @@ -24,6 +24,10 @@ public function __construct($config=false) {
}
}

public function __destruct() {
// TODO: Persist edited schemas
}

/**
setConfig - updates the current configuration with the provided hash
Throws an InvalidArgumentException if the passed config isn't an array
Expand Down Expand Up @@ -51,7 +55,7 @@ public function setConfig($config) {
public function createModelSchema($modelName, $schema=false) {
if (empty($this->_dbSchema[$modelName])) {
$modelSchema = new IsotopeOrmModelSchema($modelName);
// TODO: If the schema exists, process it
// TODO: If the schema parameter is passed in, process it

$this->_dbSchema[$modelName] = $modelSchema;
return $modelSchema;
Expand Down
3 changes: 2 additions & 1 deletion IsotopeOrmModelSchema.php
Expand Up @@ -5,10 +5,11 @@ class IsotopeOrmModelSchema {
var $schema = NULL;

public function __construct($name) {
// TODO: add in an changed flag - to help with persisting schemas
$this->schema = (object) array(
'model' => $name,
'fields' => array(
IsotopeOrmSchema::ID_FIELDNAME => IsotopeOrmSchema::PRIMARY_KEY
IsotopeOrmSchema::ID_FIELDNAME => IsotopeOrmSchema::PRIMARY_KEY
),
'indexes' => array(),
'subtables' => array()
Expand Down
24 changes: 14 additions & 10 deletions example.php
Expand Up @@ -19,30 +19,34 @@
$datasource = new IsotopeOrm($config);


##
## Partially implemented
##

/**
2.) Set up a model schema procedurally
**/

$schema = $datasource->createModelSchema('model_name');
$schema->addField('name');
$schema->addField('description', IsotopeOrmSchema::TEXTAREA);
$schema->createIndex('name');



##
## Not implemented yet
##

$schema->createIndex('name'); // TODO: Implement indexes


/**
XX.) Query an existing single-table model
3.) Query an existing single-table model
**/

$modelName = 'users';
$users = $datasource->getModel($modelName);
print_r($users->getUserById(1));
print_r($users->getUserById(1)); // TODO: Implement variable functions to query/filter



##
## Still to implement
##




Expand Down

0 comments on commit 9024b9c

Please sign in to comment.