Skip to content

PHPLIB-70: Resource CRUD prototypes #5

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

Merged
merged 8 commits into from
Mar 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

namespace MongoDB;

use MongoDB\Driver\Manager;
use MongoDB\Database;
use MongoDB\Collection;
use MongoDB\Database;
use MongoDB\Driver\Manager;
use MongoDB\Driver\Result;

class Client
{
Expand All @@ -29,6 +30,17 @@ public function __construct($uri, $options, $driverOptions)
$this->manager = new Manager($uri, $options, $driverOptions);
}

/**
* Drop a database.
*
* @param string $databaseName
* @return Result
*/
public function dropDatabase($databaseName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the Database object have __toString() method and this code explicitly do (string)$databaseName ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we did that and allowed the argument to be either a string or a Database instance, would we get into trouble with dropCollection()? I would expect a Collection's __toString() method to return its full namespace, as we do in the 1.x driver. I'd rather not invite the inconsistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proto should definetly not be string|Database, it should be string - but if it does (string) casting inside the method it implicitly allows the Database object to work seamlessly.

as for dropCollection() returning fully qualified namespace...... mmmmh.....

{
// TODO
}

/**
* Select a database
*
Expand Down
Loading