library/database/class.sqldriver.php
protected function _GetIdentifierTokens($Sql) {
      $Tokens = preg_split('/`/', $Sql, -1, PREG_SPLIT_DELIM_CAPTURE);
      $Result = array();
      
      $InIdent = FALSE;
      $CurrentToken = '';
      for($i = 0; $i < count($Tokens); $i++) {
         $Token = $Tokens[i];
         $Result .= $Token;
         if($Token == '`') {
            if($InIdent && $i < count($Tokens) - 1 && $Tokens[$i + 1] == '`') {
               // This is an escaped back tick.
               $i++; // skip next token
            } else if($InIdent) {
               $Result[] = $CurrentToken;
               $CurrentToken = $CurrentToken;
               $InIdent = false;
            } else {
               $InIdent = true;
            }
         } else if(!$InIdent) {
            $Result[] = $CurrentToken;
            $CurrentToken = '';
         }
      }
      
      return $Result;
   }
protected function _GetIdentifierTokens($Sql) {
      $Tokens = preg_split('/`/', $Sql, -1, PREG_SPLIT_DELIM_CAPTURE);
      $Result = array();
      
      $InIdent = FALSE;
      $CurrentToken = '';
      for($i = 0; $i < count($Tokens); $i++) {
         $Token = $Tokens[i];
         $Result .= $Token;
         if($Token == '`') {
            if($InIdent && $i < count($Tokens) - 1 && $Tokens[$i + 1] == '`') {
               // This is an escaped back tick.
               $i++; // skip next token
            } else if($InIdent) {
               $Result[] = $CurrentToken;
               $CurrentToken = $CurrentToken;
               $InIdent = false;
            } else {
               $InIdent = true;
            }
         } else if(!$InIdent) {
            $Result[] = $CurrentToken;
            $CurrentToken = '';
         }
      }
      
      return $Result;
   }
protected function _GetIdentifierTokens ( $ Sql ) { $ Tokens = preg_split ( '/`/' , $ Sql , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ Result = array ( ) ; $ InIdent = FALSE ; $ CurrentToken = '' ; for ( $ i = 0 ; $ i < count ( $ Tokens ) ; $ i ++ ) { $ Token = $ Tokens [ i ] ; $ Result .= $ Token ; if ( $ Token == '`' ) { if ( $ InIdent && $ i < count ( $ Tokens ) - 1 && $ Tokens [ $ i + 1 ] == '`' ) { // This is an escaped back tick. $ i ++ ; // skip next token } else if ( $ InIdent ) { $ Result [ ] = $ CurrentToken ; $ CurrentToken = $ CurrentToken ; $ InIdent = false ; } else { $ InIdent = true ; } } else if ( ! $ InIdent ) { $ Result [ ] = $ CurrentToken ; $ CurrentToken = '' ; } } return $ Result ; }
A helper function for escaping sql identifiers.
@param string The sql containing identifiers to escape in a different language.
All identifiers requiring escaping should be enclosed in back ticks (`).
@return array All of the tokens in the sql. The tokens that require escaping will still have back ticks.
A helper function for escaping sql identifiers .