function model_find_one($name, array $where) { if (!($definition = model_definition($name))) { return null; } $class = $definition->getClassName(); $results = $definition->getStorage()->findOne($where); return empty($results) ? null : $class::forgeObject($results); }
public function initialize() { $metaRelation = new HasMany($this, model_definition('postmeta')); $metaRelation->setForeignKey('post_id'); $this->addRelationship($metaRelation); }