Custom SQL handler based on PDO