Пример #1
0
 public function executeJob(StatementJob $statement, array $parameters = array())
 {
     /* @var $statement ShowStatement */
     switch ($statement->getType()) {
         case ShowType::DATABASES():
             return $this->executeShowDatabases($statement, $parameters);
         case ShowType::TABLES():
             return $this->executeShowTables($statement, $parameters);
         case ShowType::VIEWS():
             return $this->executeShowViews($statement, $parameters);
         case ShowType::COLUMNS():
             return $this->executeShowColumns($statement, $parameters);
     }
 }
Пример #2
0
 public function convertSqlToJob(SQLTokenIterator $tokens)
 {
     /* @var $valueParser ValueParser */
     $valueParser = $this->valueParser;
     $tokens->seekTokenNum(SqlToken::T_SHOW());
     if ($tokens->getCurrentTokenNumber() !== SqlToken::T_SHOW()) {
         throw new ErrorException("Tried to convert sql-show to job-entity when tokeniterator does not point to T_SHOW!");
     }
     $showJob = new ShowStatement();
     if ($tokens->seekTokenNum(SqlToken::T_FULL())) {
         $showJob->setIsFull(true);
     }
     switch (true) {
         case $tokens->seekTokenNum(SqlToken::T_DATABASES()):
             $showJob->setType(ShowType::DATABASES());
             break;
         case $tokens->seekTokenNum(SqlToken::T_TABLES()):
             $showJob->setType(ShowType::TABLES());
             break;
         case $tokens->seekTokenNum(SqlToken::T_VIEWS()):
             $showJob->setType(ShowType::VIEWS());
             break;
         default:
             throw new MalformedSqlException("Invalid parameter for show-statement!", $tokens);
     }
     if ($tokens->seekTokenNum(SqlToken::T_FROM())) {
         if (!$tokens->seekTokenNum(T_STRING)) {
             throw new MalformedSqlException("Missing database name after FROM in SHOW statement!");
         }
         $showJob->setDatabase($tokens->getCurrentTokenString());
     }
     if ($tokens->seekTokenNum(SqlToken::T_WHERE())) {
         if (!$valueParser->canParseTokens($tokens)) {
             throw new MalformedSqlException("Missing valid condition-value after WHERE in SHOW statement!");
         }
         /* @var $conditionValue ValuePart */
         $conditionValue = $valueParser->convertSqlToJob($tokens);
         $showJob->setConditionValue($conditionValue);
     }
     return $showJob;
 }