top-think / top-think/think-orm

操作MongoDB使用execute ($collection, $bulk)报错,这个方法貌似连参数都没有定义对

Open
#819 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

官网定义原生执行操作MongoDB的文档如下

execute ($collection, $bulk)
collection:表示当前查询的集合
bulk:是一个\MongoDB\Driver\BulkWrite对象


以下是测试代码

$data = [
            'name' => 'Tome',
           'age' => 20
];

$bulk = new \MongoDB\Driver\BulkWrite();
$bulk->insert($data);

Db::execute('demo', $bulk);

返回错误信息:
message: think\db\connector\Mongo::execute(): Argument #1 ($bulk) must be of type MongoDB\Driver\BulkWrite, string given
file: vendor/topthink/think-orm/src/db/connector/Mongo.php
line: 316

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 vendor/topthink/think-orm/src/db/connector/Mongo.php around line 316 and compare the execute($collection, $bulk) documentation with the method signature. Reproduce the supplied MongoDB\Driver\BulkWrite example, then verify that the documented argument order works and that the bulk operation completes without the type error.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.