public function execute(array $parameters) { $targetClass = $this->context->getTargetClass(); $pdo = $this->getConnection(HermitEvent::EVT_PROCEDURE); self::setupProcedureConnection($pdo); if ($this->sqlCreator instanceof HermiSetupSqlCreator) { if ($this->sqlCreator->hasSetupSql()) { $setupBuilder = new HermitSetupStatementBuilder($targetClass, $this->method, $this->annote, $this->sqlCreator); $setupStatement = $setupBuilder->build($pdo, $parameters); $setupStatement->execute($parameters); $setupStatement->closeCursor(); } } $builder = new HermitProcedureStatementBuilder($targetClass, $this->method, $this->annote, $this->sqlCreator); $stmt = $builder->build($pdo, $parameters); $stmt->execute($parameters); $rs = HermitProcedureResultSetFactory::create($pdo, $this->method, $this->annote, $stmt->getSqlParameter()); // // to pdo_mysql cause: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. // if($rs instanceof HermitParameterBind){ // $rs->bindParameter($pdo, $parameters); // } // return $rs->execute($stmt, $this->type); // $returnValue = $rs->execute($stmt, $this->type); if ($rs instanceof HermitParameterBind) { $rs->bindParameter($pdo, $parameters); } return $returnValue; }
public function build(PDO $pdo, array $inputParameters) { parent::checkProcedureParameter($this->method); $procedureName = $this->annote->getProcedure($this->method); $meta = HermitDatabaseMetaFactory::get($pdo); $info = $meta->getProcedureInfo($procedureName); $dbms = HermitDatabaseMetaFactory::getDbms($pdo); $parameter = new HermitProcedureParameter($info, $dbms); $parameter->setInputParameters($inputParameters); $parameter->setTargetClass($this->targetClass); $parameter->setTargetMethod($this->method); $setupSql = self::preparedSql($parameter, $this->sqlCreator->createSetupSql()); $logger = HermitLoggerManager::getLogger(); if ($logger->isDebugEnabled()) { $logger->debug('{%s} preparedSql: "%s"', __CLASS__, $setupSql); } $statement = $pdo->prepare($setupSql); return new HermitDefaultStatement($parameter, $statement); }