Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
6a17ac90
Commit
6a17ac90
authored
Apr 21, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-69: Index drop methods
parent
7b6b8e0a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
Collection.php
src/Collection.php
+17
-3
No files found.
src/Collection.php
View file @
6a17ac90
...
@@ -9,6 +9,7 @@ use MongoDB\Driver\Query;
...
@@ -9,6 +9,7 @@ use MongoDB\Driver\Query;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\BulkWrite
;
use
MongoDB\Driver\BulkWrite
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
use
InvalidArgumentException
;
class
Collection
class
Collection
{
{
...
@@ -354,11 +355,21 @@ class Collection
...
@@ -354,11 +355,21 @@ class Collection
* @see http://docs.mongodb.org/manual/reference/method/db.collection.dropIndex/
* @see http://docs.mongodb.org/manual/reference/method/db.collection.dropIndex/
* @param string $indexName
* @param string $indexName
* @return Cursor
* @return Cursor
* @throws InvalidArgumentException if "*" is specified
* @throws InvalidArgumentException if "*" is specified, since dropIndexes()
* should be used to drop multiple indexes
*/
*/
public
function
dropIndex
(
$indexName
)
public
function
dropIndex
(
$indexName
)
{
{
// TODO
$indexName
=
(
string
)
$indexName
;
if
(
$indexName
===
'*'
)
{
throw
new
InvalidArgumentException
(
'dropIndexes() must be used to drop multiple indexes'
);
}
$command
=
new
Command
(
array
(
'dropIndexes'
=>
$this
->
collname
,
'index'
=>
$indexName
));
$readPreference
=
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
);
return
$this
->
manager
->
executeCommand
(
$this
->
dbname
,
$command
,
$readPreference
);
}
}
/**
/**
...
@@ -370,7 +381,10 @@ class Collection
...
@@ -370,7 +381,10 @@ class Collection
*/
*/
public
function
dropIndexes
()
public
function
dropIndexes
()
{
{
// TODO
$command
=
new
Command
(
array
(
'dropIndexes'
=>
$this
->
collname
,
'index'
=>
'*'
));
$readPreference
=
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
);
return
$this
->
manager
->
executeCommand
(
$this
->
dbname
,
$command
,
$readPreference
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment