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
303a09ea
Commit
303a09ea
authored
Sep 03, 2015
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Collection class properties
parent
a46f2762
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
55 deletions
+49
-55
Collection.php
src/Collection.php
+49
-55
No files found.
src/Collection.php
View file @
303a09ea
...
...
@@ -36,16 +36,11 @@ use Traversable;
class
Collection
{
/* {{{ consts & vars */
protected
$manager
;
protected
$ns
;
protected
$wc
;
protected
$rp
;
protected
$dbname
;
protected
$collname
;
/* }}} */
private
$collectionName
;
private
$databaseName
;
private
$manager
;
private
$readPreference
;
private
$writeConcern
;
/**
* Constructs new Collection instance.
...
...
@@ -61,11 +56,10 @@ class Collection
public
function
__construct
(
Manager
$manager
,
$namespace
,
WriteConcern
$writeConcern
=
null
,
ReadPreference
$readPreference
=
null
)
{
$this
->
manager
=
$manager
;
$this
->
ns
=
(
string
)
$namespace
;
$this
->
wc
=
$writeConcern
;
$this
->
rp
=
$readPreference
;
$this
->
writeConcern
=
$writeConcern
;
$this
->
readPreference
=
$readPreference
;
list
(
$this
->
d
bname
,
$this
->
colln
ame
)
=
explode
(
"."
,
$namespace
,
2
);
list
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
)
=
explode
(
"."
,
$namespace
,
2
);
}
/**
...
...
@@ -75,7 +69,7 @@ class Collection
*/
public
function
__toString
()
{
return
$this
->
ns
;
return
$this
->
databaseName
.
'.'
.
$this
->
collectionName
;
}
/**
...
...
@@ -95,7 +89,7 @@ class Collection
{
$readPreference
=
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
);
$server
=
$this
->
manager
->
selectServer
(
$readPreference
);
$operation
=
new
Aggregate
(
$this
->
d
bname
,
$this
->
colln
ame
,
$pipeline
,
$options
);
$operation
=
new
Aggregate
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$pipeline
,
$options
);
return
$operation
->
execute
(
$server
);
}
...
...
@@ -110,11 +104,11 @@ class Collection
*/
public
function
bulkWrite
(
array
$operations
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
BulkWrite
(
$this
->
d
bname
,
$this
->
colln
ame
,
$operations
,
$options
);
$operation
=
new
BulkWrite
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$operations
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -130,7 +124,7 @@ class Collection
*/
public
function
count
(
$filter
=
array
(),
array
$options
=
array
())
{
$operation
=
new
Count
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$options
);
$operation
=
new
Count
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -175,7 +169,7 @@ class Collection
*/
public
function
createIndexes
(
array
$indexes
)
{
$operation
=
new
CreateIndexes
(
$this
->
d
bname
,
$this
->
colln
ame
,
$indexes
);
$operation
=
new
CreateIndexes
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$indexes
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -192,11 +186,11 @@ class Collection
*/
public
function
deleteMany
(
$filter
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
DeleteMany
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$options
);
$operation
=
new
DeleteMany
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -213,11 +207,11 @@ class Collection
*/
public
function
deleteOne
(
$filter
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
DeleteOne
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$options
);
$operation
=
new
DeleteOne
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -234,7 +228,7 @@ class Collection
*/
public
function
distinct
(
$fieldName
,
$filter
=
array
(),
array
$options
=
array
())
{
$operation
=
new
Distinct
(
$this
->
d
bname
,
$this
->
colln
ame
,
$fieldName
,
$filter
,
$options
);
$operation
=
new
Distinct
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$fieldName
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -247,7 +241,7 @@ class Collection
*/
public
function
drop
()
{
$operation
=
new
DropCollection
(
$this
->
d
bname
,
$this
->
colln
ame
);
$operation
=
new
DropCollection
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -268,7 +262,7 @@ class Collection
throw
new
InvalidArgumentException
(
'dropIndexes() must be used to drop multiple indexes'
);
}
$operation
=
new
DropIndexes
(
$this
->
d
bname
,
$this
->
colln
ame
,
$indexName
);
$operation
=
new
DropIndexes
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$indexName
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -281,7 +275,7 @@ class Collection
*/
public
function
dropIndexes
()
{
$operation
=
new
DropIndexes
(
$this
->
d
bname
,
$this
->
colln
ame
,
'*'
);
$operation
=
new
DropIndexes
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
'*'
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -298,7 +292,7 @@ class Collection
*/
public
function
find
(
$filter
=
array
(),
array
$options
=
array
())
{
$operation
=
new
Find
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$options
);
$operation
=
new
Find
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -315,7 +309,7 @@ class Collection
*/
public
function
findOne
(
$filter
=
array
(),
array
$options
=
array
())
{
$operation
=
new
FindOne
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$options
);
$operation
=
new
FindOne
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -334,7 +328,7 @@ class Collection
*/
public
function
findOneAndDelete
(
$filter
,
array
$options
=
array
())
{
$operation
=
new
FindOneAndDelete
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$options
);
$operation
=
new
FindOneAndDelete
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -357,7 +351,7 @@ class Collection
*/
public
function
findOneAndReplace
(
$filter
,
$replacement
,
array
$options
=
array
())
{
$operation
=
new
FindOneAndReplace
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$replacement
,
$options
);
$operation
=
new
FindOneAndReplace
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$replacement
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -380,7 +374,7 @@ class Collection
*/
public
function
findOneAndUpdate
(
$filter
,
$update
,
array
$options
=
array
())
{
$operation
=
new
FindOneAndUpdate
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$update
,
$options
);
$operation
=
new
FindOneAndUpdate
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$update
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -393,7 +387,7 @@ class Collection
*/
public
function
getCollectionName
()
{
return
$this
->
coll
n
ame
;
return
$this
->
coll
ectionN
ame
;
}
/**
...
...
@@ -403,7 +397,7 @@ class Collection
*/
public
function
getDatabaseName
()
{
return
$this
->
d
bn
ame
;
return
$this
->
d
atabaseN
ame
;
}
/**
...
...
@@ -414,7 +408,7 @@ class Collection
*/
public
function
getNamespace
()
{
return
$this
->
ns
;
return
$this
->
databaseName
.
'.'
.
$this
->
collectionName
;
}
/**
...
...
@@ -428,11 +422,11 @@ class Collection
*/
public
function
insertMany
(
array
$documents
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
InsertMany
(
$this
->
d
bname
,
$this
->
colln
ame
,
$documents
,
$options
);
$operation
=
new
InsertMany
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$documents
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -449,11 +443,11 @@ class Collection
*/
public
function
insertOne
(
$document
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
InsertOne
(
$this
->
d
bname
,
$this
->
colln
ame
,
$document
,
$options
);
$operation
=
new
InsertOne
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$document
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -467,7 +461,7 @@ class Collection
*/
public
function
listIndexes
(
array
$options
=
array
())
{
$operation
=
new
ListIndexes
(
$this
->
d
bname
,
$this
->
colln
ame
,
$options
);
$operation
=
new
ListIndexes
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -485,11 +479,11 @@ class Collection
*/
public
function
replaceOne
(
$filter
,
$replacement
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
ReplaceOne
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$replacement
,
$options
);
$operation
=
new
ReplaceOne
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$replacement
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -507,11 +501,11 @@ class Collection
*/
public
function
updateMany
(
$filter
,
$update
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
UpdateMany
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$update
,
$options
);
$operation
=
new
UpdateMany
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$update
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
@@ -529,11 +523,11 @@ class Collection
*/
public
function
updateOne
(
$filter
,
$update
,
array
$options
=
array
())
{
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
c
))
{
$options
[
'writeConcern'
]
=
$this
->
w
c
;
if
(
!
isset
(
$options
[
'writeConcern'
])
&&
isset
(
$this
->
w
riteConcern
))
{
$options
[
'writeConcern'
]
=
$this
->
w
riteConcern
;
}
$operation
=
new
UpdateOne
(
$this
->
d
bname
,
$this
->
colln
ame
,
$filter
,
$update
,
$options
);
$operation
=
new
UpdateOne
(
$this
->
d
atabaseName
,
$this
->
collectionN
ame
,
$filter
,
$update
,
$options
);
$server
=
$this
->
manager
->
selectServer
(
new
ReadPreference
(
ReadPreference
::
RP_PRIMARY
));
return
$operation
->
execute
(
$server
);
...
...
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