MongoDB如果加上用户认证的话不带数据库名字无法认证

Open
#353 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
mongodb, php
Domain
databases

Research direction

Start by locating the MongoDB configuration branch shown in the issue, where an empty config['dsn'] is assembled from the credentials, hostname, and port. Trace how dbName is available there and verify the resulting authenticated connection URI includes the database name; done means authentication works when a database name is configured.

Written by the indexing model from the issue text.

Description

MongoDb
if (empty($config['dsn'])) {
                $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '')
            }

需要改为:

if (empty($config['dsn'])) {
                $config['dsn'] = 'mongodb://' . ($config['username'] ? "{$config['username']}" : '') . ($config['password'] ? ":{$config['password']}@" : '') . $config['hostname'] . ($config['hostport'] ? ":{$config['hostport']}" : '').'/'.$this->dbName;
            }
Dominant language
PHP
Stars
437
Forks
188
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from top-think/think-orm

All issues in top-think/think-orm

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.