-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-153: Add Database::command() helper #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@tuyakhov: Thanks for the PR. I'm on holiday this week, but I'll look into this when I get a chance and hopefully get it merged in the coming week (by Nov 24). I did intend to add a method to execute generic commands on a Database before 1.0.0 but forgot to make a ticket for it. I'll do so now just to ensure we're tracking it in the changelog :) |
@jmikola Thank you for quick reply. I'm waiting for your review. |
Just pinging this to poke @jmikola :-) |
00d2548
to
c9091f8
Compare
@jmikola Please let know if it could be merged in near future. Looks like CI failure is not related to my PR. |
@@ -7,3 +7,4 @@ php.ini | |||
phpunit.xml | |||
apigen.phar | |||
site | |||
.idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove this. IDE-specific ignores are best left in users' own .gitignore
files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I agree, it was unnecessary.
public function executeCommand(Command $command, ReadPreference $readPreference = null) | ||
{ | ||
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); | ||
return $server->executeCommand($this->databaseName, $command, $readPreference); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll discuss this with @derickr this week, but I think we may want to change two things here:
- The command document can be an array or object (i.e. a document), which we'll use to construct a Command instance internally. In the library, I don't think we need to require the driver value object to be used (for the convenience of users).
- This appears to be hard-coded to select the primary server. I think we'll want to take an optional read preference and then use that to select the server, as we do in
Collection::count()
.
Feel free to hold off on any changes until I follow up, though. I don't want to waste your time on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmikola Please check updates
I don't have any confirmation of it being deprecated, but there were internal discussions about not adding it to a new API. @alcaeus is actually working on a project that implements the legacy driver's API atop the new |
https://jira.mongodb.org/browse/PHPLIB-153
Add method to issue database commands. According to legacy PHP driver. http://php.net/manual/ru/mongodb.command.php
I did not find any contribution conditions. Please let me know if I need to create seperate branches for this.