Ejemplo n.º 1
0
 public function initialize(PDO $pdo, ReflectionMethod $method, HermitAnnote $annote)
 {
     $meta = HermitDatabaseMetaFactory::get($pdo);
     $table = $annote->getTable();
     $info = $meta->getTableInfo($table);
     $columns = $info->getColumns();
     $insert = 'INSERT INTO';
     $insert .= ' ';
     $insert .= $table;
     $insert .= ' (';
     $insert .= join(', ', $columns);
     $insert .= ') VALUES (';
     $begin = false;
     foreach ($columns as $column) {
         $begin = true;
         $insert .= '/*' . $column . '*/';
         $insert .= '"' . $column . '"';
         $insert .= ',';
     }
     if ($begin) {
         $insert = substr($insert, 0, -1);
     }
     $insert .= ')';
     $this->insert = $insert;
 }
Ejemplo n.º 2
0
 public function initialize(PDO $pdo, ReflectionMethod $method, HermitAnnote $annote)
 {
     $meta = HermitDatabaseMetaFactory::get($pdo);
     $table = $annote->getTable();
     $info = $meta->getTableInfo($table);
     $primaryKeys = $info->getPrimaryKeys();
     $sql = 'DELETE';
     $sql .= ' ';
     $sql .= 'FROM';
     $sql .= ' ';
     $sql .= $table;
     $sql .= ' ';
     $sql .= 'WHERE';
     $sql .= ' ';
     $begin = false;
     foreach ($primaryKeys as $pk) {
         $begin = true;
         $sql .= ' ';
         $sql .= $pk . '=';
         $sql .= ' ';
         $sql .= '/*' . $pk . '*/';
         $sql .= '"' . $pk . '"';
         $sql .= ' ';
         $sql .= 'AND';
     }
     if ($begin) {
         $sql = substr($sql, 0, -3);
     }
     $this->sql = $sql;
 }
 public function build(PDO $pdo, array $inputParameters)
 {
     self::checkProcedureParameter($this->method);
     $procedureName = $this->annote->getProcedure($this->method);
     $meta = HermitDatabaseMetaFactory::get($pdo);
     $info = $meta->getProcedureInfo($procedureName);
     $dbms = HermitDatabaseMetaFactory::getDbms($pdo);
     $parameter = null;
     if (isset(self::$procedureParameters[$dbms])) {
         $className = self::$procedureParameters[$dbms];
         $parameter = new $className($info, $dbms);
     } else {
         $parameter = new HermitProcedureParameter($info, $dbms);
     }
     $parameter->setInputParameters($inputParameters);
     $parameter->setTargetClass($this->targetClass);
     $parameter->setTargetMethod($this->method);
     $sql = self::preparedSql($parameter, $this->sqlCreator->createSql());
     $logger = HermitLoggerManager::getLogger();
     if ($logger->isDebugEnabled()) {
         $logger->debug('{%s} preparedSql: "%s"', __CLASS__, $sql);
     }
     $statement = $pdo->prepare($sql);
     return new HermitDefaultStatement($parameter, $statement);
 }
 public function initialize(PDO $pdo, ReflectionMethod $method, HermitAnnote $annote)
 {
     $procedureName = $annote->getProcedure($method);
     $dbMeta = HermitDatabaseMetaFactory::get($pdo);
     $info = $dbMeta->getProcedureInfo($procedureName);
     $this->setupSql = self::generateSetupSql($info);
     $this->sql = self::generateCallSql($info);
 }
Ejemplo n.º 5
0
 public function initialize(PDO $pdo, ReflectionMethod $method, HermitAnnote $annote)
 {
     $meta = HermitDatabaseMetaFactory::get($pdo);
     $table = $annote->getTable();
     $info = $meta->getTableInfo($table);
     $columns = $info->getColumns();
     $select = 'SELECT';
     $select .= ' ';
     $select .= join(', ', $columns);
     $select .= ' ';
     $select .= 'FROM';
     $select .= ' ';
     $select .= $table;
     $this->select = $select;
 }