top-think / top-think/think-orm

mongodb的dbName没有被用到,登录验证失败

Open
#141 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

MongoDb
Dominant language
PHP
Stars
437
Forks
188
PR merge metrics
No merged PRs in 30d

Description

public function connect(array $config = [], $linkNum = 0)
    {
        if (!isset($this->links[$linkNum])) {
            if (empty($config)) {
                $config = $this->config;
            } else {
                $config = array_merge($this->config, $config);
            }

            $this->dbName  = $config['database'];
            $this->typeMap = $config['type_map'];

            if ($config['pk_convert_id'] && '_id' == $config['pk']) {
                $this->config['pk'] = 'id';
            }

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

            $startTime = microtime(true);

            $this->links[$linkNum] = new Manager($config['dsn'], $config['params']);

            if (!empty($config['trigger_sql'])) {
                // 记录数据库连接信息
                $this->trigger('CONNECT:[ UseTime:' . number_format(microtime(true) - $startTime, 6) . 's ] ' . $config['dsn']);
            }

        }

        return $this->links[$linkNum];
    }

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.

Research direction

Start at the PHP connect(array $config...) entry point shown in the issue, then trace how database and dsn are passed to MongoDB Manager. Confirm how the configured database should participate in authentication; the issue is resolved when MongoDB login succeeds with the configured dbName.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, php
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.