Idea for NotORM named queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My; | |
class NotORM extends \NotORM | |
{ | |
public static function getReflection() | |
{ | |
return new Nette\Reflection\ClassType(get_called_class()); | |
} | |
public function __call($name, $args) | |
{ | |
// extension methods | |
if ($cb = $this->getReflection()->getExtensionMethod($name)) { | |
array_unshift($args, $this); | |
return $cb->invokeArgs($args); | |
} | |
return parent::__call($name, $args); | |
} | |
public function setNamedQuery($name, $query) | |
{ | |
$this->getReflection()->setExtensionMethod($name, $query); | |
} | |
} | |
$notOrm = new NotORM(...); | |
$notOrm->setNamedQuery('someQuery', function ($NotORM, $param1, $param2, ...) { | |
return $NotORM->page('id', $NotORM->page()->select('MAX(id) id')->group('parent, url'); | |
}); | |
$notOrm->someQuery($param1, $param2)->... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reakce na: http://php.vrana.cz/notorm-2.php#d-13092