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
94ff4deb
Commit
94ff4deb
authored
Mar 12, 2015
by
Hannes Magnusson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add MongoClient and Database objects
parent
e15c2bd5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
0 deletions
+113
-0
Client.php
src/Client.php
+62
-0
Database.php
src/Database.php
+51
-0
No files found.
src/Client.php
0 → 100644
View file @
94ff4deb
<?php
namespace
MongoDB
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Database
;
use
MongoDB\Collection
;
class
Client
{
private
$manager
;
private
$wc
;
private
$rp
;
/**
* Constructs new Client instance
*
* This is the suggested main entry point using phongo.
* It acts as a bridge to access individual databases and collection tools
* which are provided in this namespace.
*
* @param Manager $uri The MongoDB URI to connect to
* @param WriteConcern $options URI Options
* @param ReadPreference $driverOptions Driver specific options
*/
public
function
__construct
(
$uri
,
$options
,
$driverOptions
)
{
$this
->
manager
=
new
Manager
(
$uri
,
$options
,
$driverOptions
);
}
/**
* Select a database
*
* It acts as a bridge to access specific database commands
*
* @param string $databaseName The database to select
* @param WriteConcern $writeConcern Default Write Concern to apply
* @param ReadPreference $readPreferences Default Read Preferences to apply
*/
public
function
selectDatabase
(
$databaseName
,
WriteConcern
$writeConcern
=
null
,
ReadPreference
$readPreferences
=
null
)
{
return
new
Database
(
$this
->
manager
,
$databaseName
,
$writeConcern
,
$readPreferences
);
}
/**
* Select a specific collection in a database
*
* It acts as a bridge to access specific collection commands
*
* @param string $databaseName The database where the $collectionName exists
* @param string $collectionName The collection to select
* @param WriteConcern $writeConcern Default Write Concern to apply
* @param ReadPreference $readPreferences Default Read Preferences to apply
*/
public
function
selectCollection
(
$databaseName
,
$collectionName
,
WriteConcern
$writeConcern
=
null
,
ReadPreference
$readPreferences
=
null
)
{
return
new
Collection
(
$this
->
manager
,
"
{
$databaseName
}
.
{
$collectionName
}
"
,
$writeConcern
,
$readPreferences
);
}
}
src/Database.php
0 → 100644
View file @
94ff4deb
<?php
namespace
MongoDB
;
use
MongoDB\Driver\Manager
;
use
MongoDB\Collection
;
class
Database
{
private
$manager
;
private
$ns
;
private
$wc
;
private
$rp
;
private
$dbname
;
/**
* Constructs new Database instance
*
* It acts as a bridge for database specific operations.
*
* @param Manager $manager The phongo Manager instance
* @param string $dbname Fully Qualified database name
* @param WriteConcern $wc The WriteConcern to apply to writes
* @param ReadPreference $rp The ReadPreferences to apply to reads
*/
public
function
__construct
(
Manager
$manager
,
$databaseName
,
WriteConcern
$wc
=
null
,
ReadPreference
$rp
=
null
)
{
$this
->
manager
=
$manager
;
$this
->
dbname
=
$dbname
;
$this
->
wc
=
$wc
;
$this
->
rp
=
$rp
;
}
/**
* Select a specific collection in this database
*
* It acts as a bridge to access specific collection commands
*
* @param string $collectionName The collection to select
* @param WriteConcern $writeConcern Default Write Concern to apply
* @param ReadPreference $readPreferences Default Read Preferences to apply
*/
public
function
selectCollection
(
$collectionName
,
WriteConcern
$writeConcern
=
null
,
ReadPreference
$readPreferences
=
null
)
{
return
new
Collection
(
$this
->
manager
,
"
{
$this
->
dbname
}
.
{
$collectionName
}
"
,
$writeConcern
,
$readPreferences
);
}
}
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