SqlParser\Context::isSymbol PHP Method

isSymbol() public static method

Checks if the given character is the beginning of a symbol. A symbol can be either a variable or a field name.
public static isSymbol ( string $str ) : integer
$str string String to be checked.
return integer The appropriate flag for the symbol type.
    public static function isSymbol($str)
    {
        if ($str[0] === '@') {
            return Token::FLAG_SYMBOL_VARIABLE;
        } elseif ($str[0] === '`') {
            return Token::FLAG_SYMBOL_BACKTICK;
        }
        return null;
    }

Usage Example

Example #1
0
 /**
  * Parses a symbol.
  *
  * @return Token
  */
 public function parseSymbol()
 {
     $token = $this->str[$this->last];
     if (!($flags = Context::isSymbol($token))) {
         return null;
     }
     if ($flags & Token::FLAG_SYMBOL_VARIABLE) {
         ++$this->last;
     } else {
         $token = '';
     }
     if (($str = $this->parseString('`')) === null) {
         if (($str = static::parseUnknown()) === null) {
             $this->error(__('Variable name was expected.'), $this->str[$this->last], $this->last);
         }
     }
     if ($str !== null) {
         $token .= $str->token;
     }
     return new Token($token, Token::TYPE_SYMBOL, $flags);
 }
All Usage Examples Of SqlParser\Context::isSymbol