Exemplo n.º 1
0
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);
}
Exemplo n.º 2
0
 public function initialize()
 {
     $metaRelation = new HasMany($this, model_definition('postmeta'));
     $metaRelation->setForeignKey('post_id');
     $this->addRelationship($metaRelation);
 }