Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2bootstrap
Project
Project
Details
Activity
Releases
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
夏彬
yii2bootstrap
Commits
37664fff
Commit
37664fff
authored
Nov 28, 2013
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mongo Active Record created as draft.
parent
dc3ada65
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1225 additions
and
6 deletions
+1225
-6
ActiveQuery.php
extensions/mongo/ActiveQuery.php
+22
-0
ActiveRecord.php
extensions/mongo/ActiveRecord.php
+1165
-0
ActiveRelation.php
extensions/mongo/ActiveRelation.php
+22
-0
Collection.php
extensions/mongo/Collection.php
+16
-6
No files found.
extensions/mongo/
QueryBuilder
.php
→
extensions/mongo/
ActiveQuery
.php
View file @
37664fff
...
@@ -7,31 +7,16 @@
...
@@ -7,31 +7,16 @@
namespace
yii\mongo
;
namespace
yii\mongo
;
use
yii\base\Object
;
use
yii\db\ActiveQueryInterface
;
use
yii\db\ActiveQueryTrait
;
/**
/**
* Class
QueryBuilder
* Class
ActiveQuery
*
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
* @since 2.0
*/
*/
class
QueryBuilder
extends
Object
class
ActiveQuery
extends
Query
implements
ActiveQueryInterface
{
{
/**
use
ActiveQueryTrait
;
* @var Connection the Mongo connection.
*/
public
$db
;
/**
* Constructor.
* @param Connection $connection the Mongo connection.
* @param array $config name-value pairs that will be used to initialize the object properties
*/
public
function
__construct
(
$connection
,
$config
=
[])
{
$this
->
db
=
$connection
;
parent
::
__construct
(
$config
);
}
// TODO
}
}
\ No newline at end of file
extensions/mongo/ActiveRecord.php
0 → 100644
View file @
37664fff
This diff is collapsed.
Click to expand it.
extensions/mongo/ActiveRelation.php
0 → 100644
View file @
37664fff
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\mongo
;
use
yii\db\ActiveRelationInterface
;
use
yii\db\ActiveRelationTrait
;
/**
* ActiveRelation represents a relation to Mongo Active Record class.
*
* @author Paul Klimov <klimov.paul@gmail.com>
* @since 2.0
*/
class
ActiveRelation
extends
ActiveQuery
implements
ActiveRelationInterface
{
use
ActiveRelationTrait
;
}
\ No newline at end of file
extensions/mongo/Collection.php
View file @
37664fff
...
@@ -106,7 +106,7 @@ class Collection extends Object
...
@@ -106,7 +106,7 @@ class Collection extends Object
* @param array $condition description of the objects to update.
* @param array $condition description of the objects to update.
* @param array $newData the object with which to update the matching records.
* @param array $newData the object with which to update the matching records.
* @param array $options list of options in format: optionName => optionValue.
* @param array $options list of options in format: optionName => optionValue.
* @return
boolean
whether operation was successful.
* @return
integer|boolean number of updated documents or
whether operation was successful.
* @throws Exception on failure.
* @throws Exception on failure.
*/
*/
public
function
update
(
$condition
,
$newData
,
$options
=
[])
public
function
update
(
$condition
,
$newData
,
$options
=
[])
...
@@ -115,9 +115,14 @@ class Collection extends Object
...
@@ -115,9 +115,14 @@ class Collection extends Object
Yii
::
info
(
$token
,
__METHOD__
);
Yii
::
info
(
$token
,
__METHOD__
);
try
{
try
{
Yii
::
beginProfile
(
$token
,
__METHOD__
);
Yii
::
beginProfile
(
$token
,
__METHOD__
);
$this
->
mongoCollection
->
update
(
$this
->
buildCondition
(
$condition
),
$newData
,
$options
);
$result
=
$this
->
mongoCollection
->
update
(
$this
->
buildCondition
(
$condition
),
$newData
,
$options
);
$this
->
tryResultError
(
$result
);
Yii
::
endProfile
(
$token
,
__METHOD__
);
Yii
::
endProfile
(
$token
,
__METHOD__
);
if
(
is_array
(
$result
)
&&
array_key_exists
(
'n'
,
$result
))
{
return
$result
[
'n'
];
}
else
{
return
true
;
return
true
;
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Yii
::
endProfile
(
$token
,
__METHOD__
);
Yii
::
endProfile
(
$token
,
__METHOD__
);
throw
new
Exception
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
(),
$e
);
throw
new
Exception
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
(),
$e
);
...
@@ -150,7 +155,7 @@ class Collection extends Object
...
@@ -150,7 +155,7 @@ class Collection extends Object
* Removes data from the collection.
* Removes data from the collection.
* @param array $condition description of records to remove.
* @param array $condition description of records to remove.
* @param array $options list of options in format: optionName => optionValue.
* @param array $options list of options in format: optionName => optionValue.
* @return
boolean
whether operation was successful.
* @return
integer|boolean number of updated documents or
whether operation was successful.
* @throws Exception on failure.
* @throws Exception on failure.
*/
*/
public
function
remove
(
$condition
=
[],
$options
=
[])
public
function
remove
(
$condition
=
[],
$options
=
[])
...
@@ -159,9 +164,14 @@ class Collection extends Object
...
@@ -159,9 +164,14 @@ class Collection extends Object
Yii
::
info
(
$token
,
__METHOD__
);
Yii
::
info
(
$token
,
__METHOD__
);
try
{
try
{
Yii
::
beginProfile
(
$token
,
__METHOD__
);
Yii
::
beginProfile
(
$token
,
__METHOD__
);
$this
->
tryResultError
(
$this
->
mongoCollection
->
remove
(
$this
->
buildCondition
(
$condition
),
$options
));
$result
=
$this
->
mongoCollection
->
remove
(
$this
->
buildCondition
(
$condition
),
$options
);
$this
->
tryResultError
(
$result
);
Yii
::
endProfile
(
$token
,
__METHOD__
);
Yii
::
endProfile
(
$token
,
__METHOD__
);
if
(
is_array
(
$result
)
&&
array_key_exists
(
'n'
,
$result
))
{
return
$result
[
'n'
];
}
else
{
return
true
;
return
true
;
}
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
Yii
::
endProfile
(
$token
,
__METHOD__
);
Yii
::
endProfile
(
$token
,
__METHOD__
);
throw
new
Exception
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
(),
$e
);
throw
new
Exception
(
$e
->
getMessage
(),
(
int
)
$e
->
getCode
(),
$e
);
...
...
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