Gdn_SQLDriver::mapAliases PHP Method

mapAliases() public method

Takes a provided table specification and parses out any table aliases provided, placing them in an alias mapping array. Returns the table specification with any table prefix prepended.
public mapAliases ( string $TableString ) : string
$TableString string The string specification of the table. ie. "tbl_User as u" or "user u".
return string
    public function mapAliases($TableString)
    {
        // Make sure all tables have an alias.
        if (strpos($TableString, ' ') === false) {
            $TableString .= " `{$TableString}`";
        }
        // Map the alias to the alias mapping array
        $TableString = trim(preg_replace('/\\s+as\\s+/i', ' ', $TableString));
        $Alias = strrchr($TableString, " ");
        $TableName = substr($TableString, 0, strlen($TableString) - strlen($Alias));
        // If no alias was specified then it will be set to the tablename.
        $Alias = trim($Alias);
        if (strlen($Alias) == 0) {
            $Alias = $TableName;
            $TableString .= " `{$Alias}`";
        }
        //$this->_AliasMap[$Alias] = $TableName;
        // Return the string with the database table prefix prepended
        return $this->Database->DatabasePrefix . $TableString;
    }