protected function escapeIdentifier($word, $escapeChar = '`')
    {
        if (is_array($word) || is_object($word) || is_numeric($word)) {
            return '';
        }

        $spaces = explode(' ', $word);
        foreach ($spaces as &$space) {
            if (strtolower($space) == 'as') {
                $space = 'AS';
            } else {
                $periods = explode('.', $space);
                foreach ($periods as &$period) {
                    // escape identifiers that are: [0-9,a-z,A-Z$_]
                    if (preg_match('/^[A-Za-z0-9_$]*$/', $period)) {
                        $period = $escapeChar.$period.$escapeChar;
                    // do not use an identifier that contains something other than:
                    //      alpha-numeric, _, $, *, /, +, -, (, )
                    } elseif (!preg_match('/^[A-Za-z0-9_$\*\/\+\-\(\)]*$/', $period)) {
                        $period = '';
                    }
                }

                $space = implode('.', $periods);
            }
        }

        return implode(' ', $spaces);
    }