Fixed PHP-1149: Fix database and collection name validation.
Merged pull request #727