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
266b7e9a
Commit
266b7e9a
authored
Mar 12, 2015
by
Hannes Magnusson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-62: Its called BulkWrite now
parent
bb7452f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
Collection.php
src/Collection.php
+19
-19
No files found.
src/Collection.php
View file @
266b7e9a
...
@@ -7,7 +7,7 @@ use MongoDB\Driver\Manager;
...
@@ -7,7 +7,7 @@ use MongoDB\Driver\Manager;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\Query
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\ReadPreference
;
use
MongoDB\Driver\Result
;
use
MongoDB\Driver\Result
;
use
MongoDB\Driver\
WriteBatch
;
use
MongoDB\Driver\
BulkWrite
;
use
MongoDB\Driver\WriteConcern
;
use
MongoDB\Driver\WriteConcern
;
class
Collection
class
Collection
...
@@ -287,7 +287,7 @@ class Collection
...
@@ -287,7 +287,7 @@ class Collection
}
}
/**
/**
* Adds a full set of write operations into a b
atch
and executes it
* Adds a full set of write operations into a b
ulk
and executes it
*
*
* The syntax of the $bulk array is:
* The syntax of the $bulk array is:
* $bulk = [
* $bulk = [
...
@@ -337,7 +337,7 @@ class Collection
...
@@ -337,7 +337,7 @@ class Collection
{
{
$options
=
array_merge
(
$this
->
getBulkOptions
(),
$options
);
$options
=
array_merge
(
$this
->
getBulkOptions
(),
$options
);
$b
atch
=
new
WriteBatch
(
$options
[
"ordered"
]);
$b
ulk
=
new
BulkWrite
(
$options
[
"ordered"
]);
foreach
(
$bulk
as
$n
=>
$op
)
{
foreach
(
$bulk
as
$n
=>
$op
)
{
foreach
(
$op
as
$opname
=>
$args
)
{
foreach
(
$op
as
$opname
=>
$args
)
{
...
@@ -347,7 +347,7 @@ class Collection
...
@@ -347,7 +347,7 @@ class Collection
switch
(
$opname
)
{
switch
(
$opname
)
{
case
"insertOne"
:
case
"insertOne"
:
$b
atch
->
insert
(
$args
[
0
]);
$b
ulk
->
insert
(
$args
[
0
]);
break
;
break
;
case
"updateMany"
:
case
"updateMany"
:
...
@@ -356,7 +356,7 @@ class Collection
...
@@ -356,7 +356,7 @@ class Collection
}
}
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
0
));
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
2
])
?
$args
[
2
]
:
array
(),
array
(
"limit"
=>
0
));
$b
atch
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
$b
ulk
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
break
;
break
;
case
"updateOne"
:
case
"updateOne"
:
...
@@ -368,7 +368,7 @@ class Collection
...
@@ -368,7 +368,7 @@ class Collection
throw
new
\InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
throw
new
\InvalidArgumentException
(
"First key in
\$
update must be a
\$
operator"
);
}
}
$b
atch
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
$b
ulk
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
break
;
break
;
case
"replaceOne"
:
case
"replaceOne"
:
...
@@ -380,17 +380,17 @@ class Collection
...
@@ -380,17 +380,17 @@ class Collection
throw
new
\InvalidArgumentException
(
"First key in
\$
update must NOT be a
\$
operator"
);
throw
new
\InvalidArgumentException
(
"First key in
\$
update must NOT be a
\$
operator"
);
}
}
$b
atch
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
$b
ulk
->
update
(
$args
[
0
],
$args
[
1
],
$options
);
break
;
break
;
case
"deleteOne"
:
case
"deleteOne"
:
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
1
])
?
$args
[
1
]
:
array
(),
array
(
"limit"
=>
1
));
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
1
])
?
$args
[
1
]
:
array
(),
array
(
"limit"
=>
1
));
$b
atch
->
delete
(
$args
[
0
],
$options
);
$b
ulk
->
delete
(
$args
[
0
],
$options
);
break
;
break
;
case
"deleteMany"
:
case
"deleteMany"
:
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
1
])
?
$args
[
1
]
:
array
(),
array
(
"limit"
=>
0
));
$options
=
array_merge
(
$this
->
getWriteOptions
(),
isset
(
$args
[
1
])
?
$args
[
1
]
:
array
(),
array
(
"limit"
=>
0
));
$b
atch
->
delete
(
$args
[
0
],
$options
);
$b
ulk
->
delete
(
$args
[
0
],
$options
);
break
;
break
;
default
:
default
:
...
@@ -398,7 +398,7 @@ class Collection
...
@@ -398,7 +398,7 @@ class Collection
}
}
}
}
}
}
return
$this
->
manager
->
execute
WriteBatch
(
$this
->
ns
,
$batch
,
$this
->
wc
);
return
$this
->
manager
->
execute
BulkWrite
(
$this
->
ns
,
$bulk
,
$this
->
wc
);
}
}
/**
/**
...
@@ -415,9 +415,9 @@ class Collection
...
@@ -415,9 +415,9 @@ class Collection
{
{
$options
=
array_merge
(
$this
->
getWriteOptions
());
$options
=
array_merge
(
$this
->
getWriteOptions
());
$b
atch
=
new
WriteBatch
(
$options
[
"ordered"
]);
$b
ulk
=
new
BulkWrite
(
$options
[
"ordered"
]);
$id
=
$b
atch
->
insert
(
$document
);
$id
=
$b
ulk
->
insert
(
$document
);
$wr
=
$this
->
manager
->
execute
WriteBatch
(
$this
->
ns
,
$batch
,
$this
->
wc
);
$wr
=
$this
->
manager
->
execute
BulkWrite
(
$this
->
ns
,
$bulk
,
$this
->
wc
);
return
new
InsertResult
(
$wr
,
$id
);
return
new
InsertResult
(
$wr
,
$id
);
}
}
...
@@ -430,9 +430,9 @@ class Collection
...
@@ -430,9 +430,9 @@ class Collection
{
{
$options
=
array_merge
(
$this
->
getWriteOptions
(),
array
(
"limit"
=>
$limit
));
$options
=
array_merge
(
$this
->
getWriteOptions
(),
array
(
"limit"
=>
$limit
));
$b
atch
=
new
WriteBatch
(
$options
[
"ordered"
]);
$b
ulk
=
new
BulkWrite
(
$options
[
"ordered"
]);
$b
atch
->
delete
(
$filter
,
$options
);
$b
ulk
->
delete
(
$filter
,
$options
);
return
$this
->
manager
->
execute
WriteBatch
(
$this
->
ns
,
$batch
,
$this
->
wc
);
return
$this
->
manager
->
execute
BulkWrite
(
$this
->
ns
,
$bulk
,
$this
->
wc
);
}
}
/**
/**
...
@@ -475,9 +475,9 @@ class Collection
...
@@ -475,9 +475,9 @@ class Collection
{
{
$options
=
array_merge
(
$this
->
getWriteOptions
(),
$options
);
$options
=
array_merge
(
$this
->
getWriteOptions
(),
$options
);
$b
atch
=
new
WriteBatch
(
$options
[
"ordered"
]);
$b
ulk
=
new
BulkWrite
(
$options
[
"ordered"
]);
$b
atch
->
update
(
$filter
,
$update
,
$options
);
$b
ulk
->
update
(
$filter
,
$update
,
$options
);
return
$this
->
manager
->
execute
WriteBatch
(
$this
->
ns
,
$batch
,
$this
->
wc
);
return
$this
->
manager
->
execute
BulkWrite
(
$this
->
ns
,
$bulk
,
$this
->
wc
);
}
}
/**
/**
...
...
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