public function canParseTokens(SQLTokenIterator $tokens, &$checkFlags = 0) { $previousIndex = $tokens->getIndex(); $operator = $this->parseCondition($tokens); $tokens->seekIndex($previousIndex); return !is_null($operator); }
public function canParseTokens(SQLTokenIterator $tokens, &$skipChecks = 0) { $previousIndex = $tokens->getIndex(); $result = is_int($tokens->isTokenNum(SqlToken::T_LIKE(), TokenIterator::NEXT, [SqlToken::T_NOT()])) || is_int($tokens->isTokenNum(SqlToken::T_LIKE(), TokenIterator::CURRENT, [SqlToken::T_NOT()])); $tokens->seekIndex($previousIndex); return $result; }
public function canParseTokens(SQLTokenIterator $tokens, &$checkFlags = 0) { $previousIndex = $tokens->getIndex(); if (!$tokens->seekTokenNum(SqlToken::T_IN(), TokenIterator::NEXT, [SqlToken::T_NOT()])) { $tokens->seekIndex($previousIndex); return false; } $result = is_int($tokens->isTokenText('(')); $tokens->seekIndex($previousIndex); return $result; }
public function canParseTokens(SQLTokenIterator $tokens) { $previousIndex = $tokens->getIndex(); if ($tokens->seekTokenText('(')) { $return = $this->selectParser->canParseTokens($tokens); } else { $return = $this->tableParser->canParseTokens($tokens); } $tokens->seekIndex($previousIndex); return $return; }
public function canParseTokens(SQLTokenIterator $tokens) { $indexBefore = $tokens->getIndex(); $tokens->seekIndex($tokens->getExclusiveTokenIndex()); if (!in_array((int) (string) $tokens->getCurrentTokenNumber(), [T_STRING, SqlToken::T_DATABASE]) && !$tokens->getCurrentTokenNumber() instanceof Token) { $tokens->seekIndex($indexBefore); return false; } $paranthesisExist = is_int($tokens->isTokenText('(')); $tokens->seekIndex($indexBefore); return $paranthesisExist; }
public function canParseTokens(SQLTokenIterator $tokens) { $indexBefore = $tokens->getIndex(); $tokens->seekTokens([T_STRING, T_CONSTANT_ENCAPSED_STRING]); $result = false; // check if column-name is there if ($tokens->isTokens([T_STRING, T_CONSTANT_ENCAPSED_STRING], TokenIterator::CURRENT)) { try { // check if valid data-type is there $dataTypeString = strtoupper($tokens->getExclusiveTokenString()); $dataType = DataType::factory($dataTypeString); $result = true; } catch (\ErrorException $exception) { # skips $result=true } } $tokens->seekIndex($indexBefore); return $result; }
public function parsePlainValue(SQLTokenIterator $tokens, ValueJob $valueJob) { switch (true) { case $tokens->seekTokenNum(T_NUM_STRING): $valueJob->addChainValue((double) $tokens->getCurrentTokenString()); break; case $tokens->seekTokenNum(T_CONSTANT_ENCAPSED_STRING): $string = $tokens->getCurrentTokenString(); if (($string[0] === '"' || $string[0] === "'") && $string[0] === $string[strlen($string) - 1]) { // remove quotes if needed $string = substr($string, 1, strlen($string) - 2); } $valueJob->addChainValue($string); break; case $tokens->seekTokenNum(T_VARIABLE): $variableString = $tokens->getCurrentTokenString(); $variable = Variable::factory($variableString); if ($variableString === '?') { $variable->setIndex($tokens->countTokenOccourences(T_VARIABLE, 0, $tokens->getIndex() - 1)); } $valueJob->addChainValue($variable); break; case $this->parenthesisParser->canParseTokens($tokens): $valueJob->addChainValue($this->parenthesisParser->convertSqlToJob($tokens)); break; case $this->functionParser->canParseTokens($tokens): $valueJob->addChainValue($this->functionParser->convertSqlToJob($tokens)); break; case $this->columnParser->canParseTokens($tokens): $valueJob->addChainValue($this->columnParser->convertSqlToJob($tokens)); break; case $this->caseParser->canParseTokens($tokens): $valueJob->addChainValue($this->caseParser->convertSqlToJob($tokens)); break; case $tokens->seekTokenNum(SqlToken::T_DEFAULT()): case $tokens->seekTokenNum(SqlToken::T_NULL()): case $tokens->seekTokenNum(SqlToken::T_FALSE()): case $tokens->seekTokenNum(SqlToken::T_TRUE()): case $tokens->seekTokenNum(SqlToken::T_CURRENT_TIMESTAMP()): case $tokens->seekTokenNum(SqlToken::T_CURRENT_DATE()): case $tokens->seekTokenNum(SqlToken::T_CURRENT_TIME()): case $tokens->seekTokenNum(SqlToken::T_CURRENT_USER()): $valueJob->addChainValue($tokens->getCurrentTokenNumber()); break; default: return false; } return true; }