- Timestamp:
- 09/17/08 13:55:47 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/php/misc/Hermit/src/Hermit/command/HermitSqlCommandFactory.php
r19344 r19426 12 12 $this->reflector = $reflector; 13 13 } 14 public function has Command($methodName){14 public function has($methodName){ 15 15 return $this->annote->hasMethod($methodName); 16 16 } 17 public function getCommand($methodName){17 public function create(PDO $pdo, $methodName){ 18 18 $method = $this->annote->getMethod($methodName); 19 19 $methodId = spl_object_hash($method); … … 25 25 } 26 26 protected function createCommand(ReflectionMethod $method){ 27 $methodName = $method->getName(); 28 if($this->annote->isProcedureMethod($methodName)){ 29 return $this->createProcedureCommand($method); 30 } 27 31 if($this->annote->isInsertMethod($methodName)){ 28 32 return $this->createInsertCommand($method); … … 36 40 return $this->createSelectCommand($method); 37 41 } 42 protected function createProcedureCommand(ReflectionMethod $method){ 43 $creator = $this->createProcedureSqlCreator($method); 44 return new HermitProcedureCommand($method, $creator); 45 } 46 protected function createProcedureSqlCreator(ReflectionMethod $method){ 47 $sql = $this->annote->getProcedure($method); 48 if(null !== $sql){ 49 return new HermitStaticSqlCreator($sql); 50 } 51 $sql = $this->annote->getSql($method); 52 if(null !== $sql){ 53 return new HermitStaticSqlCreator($sql); 54 } 55 $sql = $this->annote->getFile($method); 56 if(null !== $sql){ 57 return new HermitStaticSqlCreator($sql); 58 } 59 throw new BadMethodCallException('method: "' . $method->getName() . '" was not apply to Procedure command'); 60 } 38 61 protected function createInsertCommand(ReflectionMethod $method){ 62 throw new RuntimeException('T.B.D'); 39 63 } 40 64 protected function createUpdateCommand(ReflectionMethod $method){ 65 throw new RuntimeException('T.B.D'); 66 } 67 protected function createDeleteCommand(ReflectionMethod $method){ 68 throw new RuntimeException('T.B.D'); 41 69 } 42 70 protected function createSelectCommand(ReflectionMethod $method){ 43 $creator = $this->createSelectSqlCreator($method->getName()); 71 $creator = $this->createSelectSqlCreator($method); 72 $query = $this->annote->getQuery($method); 73 if(null !== $query){ 74 $creator->addQuery($query); 75 } 44 76 return new HermitSelectCommand($method, $creator); 45 77 } 46 protected function createSelectSqlCreator($name){ 47 switch(true){ 48 case $this->annote->hasSql($name): 49 return new HermitStaticSqlCreator($this->annote->getSql($name)); 50 case $this->annote->hasFile($name): 51 return new HermitStaticSqlCreator($this->annote->getFile($name)); 52 case $this->annote->hasPath($name): 53 return new HermitStaticSqlCreator($this->annote->getPath($name)); 54 case $this->annote->hasQuery($name): 55 $creator = new HermitAutoSelectCreator; 56 $creator->addQuery($this->annote->getQuery()); 57 return $creator; 78 protected function createSelectSqlCreator(ReflectionMethod $method){ 79 $sql = $this->annote->getSql($method); 80 if(null !== $sql){ 81 return new HermitStaticSqlCreator($sql); 58 82 } 59 throw new BadMethodCallException('invalid method:' . $name); 83 $sql = $this->annote->getFile($method); 84 if(null !== $sql){ 85 return new HermitStaticSqlCreator($sql); 86 } 87 return new HermitAutoSelectCreator; 60 88 } 61 89 } 90
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)