Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
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
laravel-mongodb
Commits
f8054f1c
Commit
f8054f1c
authored
Apr 28, 2013
by
Jens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow basic nested queries
parent
11634993
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
Query.php
src/Jenssegers/Mongodb/Query.php
+23
-2
No files found.
src/Jenssegers/Mongodb/Query.php
View file @
f8054f1c
...
...
@@ -198,7 +198,8 @@ class Query extends \Illuminate\Database\Query\Builder {
*/
public
function
from
(
$collection
)
{
$this
->
collection
=
$this
->
connection
->
getCollection
(
$collection
);
if
(
$collection
)
$this
->
collection
=
$this
->
connection
->
getCollection
(
$collection
);
return
$this
;
}
...
...
@@ -216,6 +217,15 @@ class Query extends \Illuminate\Database\Query\Builder {
foreach
(
$this
->
wheres
as
$i
=>
$where
)
{
// Nested query
if
(
$where
[
'type'
]
==
'Nested'
)
{
// Compile nested query and add it to current query
$compiled
=
$where
[
'query'
]
->
compileWheres
();
$wheres
=
array_merge_recursive
(
$wheres
,
$compiled
);
continue
;
}
// Convert id's
if
(
$where
[
'column'
]
==
'_id'
)
{
...
...
@@ -223,7 +233,7 @@ class Query extends \Illuminate\Database\Query\Builder {
}
// First item of chain
if
(
$i
==
0
&&
count
(
$this
->
wheres
)
>
1
)
if
(
$i
==
0
&&
count
(
$this
->
wheres
)
>
1
&&
$where
[
'boolean'
]
==
'and'
)
{
// Copy over boolean value of next item in chain
$where
[
'boolean'
]
=
$this
->
wheres
[
$i
+
1
][
'boolean'
];
...
...
@@ -282,4 +292,15 @@ class Query extends \Illuminate\Database\Query\Builder {
return
array
(
$column
=>
array
(
$this
->
conversion
[
'exists'
]
=>
true
));
}
/**
* Get a new instance of the query builder.
*
* @return Builder
*/
public
function
newQuery
()
{
$connection
=
$this
->
getConnection
();
return
new
Query
(
$connection
);
}
}
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