- Timestamp:
- 09/16/08 01:32:33 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/php/misc/Hermit/src/Hermit/proxy/HermitInterfaceProxy.php
r19017 r19344 4 4 * @author nowelium 5 5 */ 6 class HermitInterfaceProxy implements HermitProxy { 7 protected $pdo; 6 class HermitInterfaceProxy implements HermitFutureProxy { 8 7 protected $reflector; 9 protected function __construct(ReflectionClass $reflector, $pdo){ 8 protected $commandFactory; 9 protected function __construct(ReflectionClass $reflector){ 10 10 $this->reflector = $reflector; 11 $this-> pdo = $pdo;11 $this->commandFactory = new HermitSqlCommandFactory($reflector); 12 12 } 13 public static function delegate( PDO $pdo,ReflectionClass $reflector, $instance = null){14 return new self($reflector , $pdo);13 public static function delegate(ReflectionClass $reflector, $instance = null){ 14 return new self($reflector); 15 15 } 16 public function __call($name, $params = array()){ 17 $annote = HermitAnnote::create($this->reflector); 18 if(!$annote->hasMethod($name)){ 16 public function request($name, array $params){ 17 if(!$this->commandFactory->hasCommand($name)){ 19 18 throw new BadMethodCallException($this->reflector->getName() . '::' . $name); 20 19 } 21 22 $method = $annote->getMethod($name); 23 switch(true){ 24 case $annote->hasSql($name): 25 return $this->execute($method, $params, $annote->getSql($name)); 26 case $annote->hasQuery($name): 27 $sql = 'SELECT * FROM ' . $annote->getTable() . ' WHERE ' . $annote->getQuery($name); 28 return $this->execute($method, $params, $sql); 29 case $annote->hasFile($name): 30 return $this->execute($method, $params, $annote->getFile($name)); 31 case $annote->hasPath($name): 32 return $this->execute($method, $params, $annote->getPath($name)); 33 case $annote->hasDelegate($name); 34 break; 35 } 36 throw new BadMethodCallException($this->reflector->getName() . '::' . $name); 37 } 38 protected function execute(ReflectionMethod $method, $params, $sql){ 39 $stmt = HermitStatementBuilder::prepare($this->pdo, $method, $sql); 40 $stmt->execute($params); 41 return HermitResultSet::create($stmt, $method); 20 $command = $this->commandFactory->getCommand($name); 21 return $command->execute($pdo, $params); 42 22 } 43 23 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)