Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Php activerecord tableconstructor #501

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ public function __construct(array $attributes=array(), $guard_attributes=true, $

$this->invoke_callback('after_construct',false);
}

/**
* Factory method to facilitate subclassing of Table if desired.
*/
public static function make_table($model_class_name)
{
return new Table($model_class_name);
}

/**
* Magic method which delegates to read_attribute(). This handles firing off getter methods,
Expand Down
4 changes: 2 additions & 2 deletions lib/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static function load($model_class_name)
{
/* do not place set_assoc in constructor..it will lead to infinite loop due to
relationships requesting the model's table, but the cache hasn't been set yet */
self::$cache[$model_class_name] = new Table($model_class_name);
self::$cache[$model_class_name] = Model::make_table($model_class_name);
self::$cache[$model_class_name]->set_associations();
}

Expand Down Expand Up @@ -391,7 +391,7 @@ private function add_relationship($relationship)
$this->relationships[$relationship->attribute_name] = $relationship;
}

private function get_meta_data()
protected function get_meta_data()
{
// as more adapters are added probably want to do this a better way
// than using instanceof but gud enuff for now
Expand Down