Small performance improvements, use str_replace() instead of strtr(),
do not parse query if there are no params to replace,
keep one instance of (potentially long) query less in memory