MongoDB驱动增加支持配置builder和query参数,便于开发者自定义Builder和Query类实现 #494
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
起因
官方文档数据库驱动中写到: 一旦自定义了数据库驱动,例如你自定义实现了think\mongo\Connection你需要在数据库配置文件中配置:
而官方MongoDB驱动却不能通过配置
query
参数实现自定义Query
类,必须通过重写Connector::getQueryClass()方法才能实现自定义Query
类,当然要自定义Builder
类也是如此。结果
于是参照官方
PDOConnection
增加query
和builder
参数,同时修改对应获得两个类的方法实现修改参数即可自定义驱动,保持与官方文档一致。