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
11634993
Commit
11634993
authored
Apr 28, 2013
by
Jens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allowed query chaining
parent
a6d0537e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
8 deletions
+22
-8
Query.php
src/Jenssegers/Mongodb/Query.php
+22
-8
No files found.
src/Jenssegers/Mongodb/Query.php
View file @
11634993
...
...
@@ -24,7 +24,8 @@ class Query extends \Illuminate\Database\Query\Builder {
'>'
=>
'$gt'
,
'>='
=>
'$gte'
,
'in'
=>
'$in'
,
'exists'
=>
'$exists'
'exists'
=>
'$exists'
,
'or'
=>
'$or'
,
);
/**
...
...
@@ -213,7 +214,7 @@ class Query extends \Illuminate\Database\Query\Builder {
$wheres
=
array
();
foreach
(
$this
->
wheres
as
$where
)
foreach
(
$this
->
wheres
as
$
i
=>
$
where
)
{
// Convert id's
if
(
$where
[
'column'
]
==
'_id'
)
...
...
@@ -221,12 +222,19 @@ class Query extends \Illuminate\Database\Query\Builder {
$where
[
'value'
]
=
(
$where
[
'value'
]
instanceof
MongoID
)
?
$where
[
'value'
]
:
new
MongoID
(
$where
[
'value'
]);
}
// First item of chain
if
(
$i
==
0
&&
count
(
$this
->
wheres
)
>
1
)
{
// Copy over boolean value of next item in chain
$where
[
'boolean'
]
=
$this
->
wheres
[
$i
+
1
][
'boolean'
];
}
// Delegate
$method
=
"compileWhere
{
$where
[
'type'
]
}
"
;
$compiled
=
$this
->
{
$method
}(
$where
);
foreach
(
$compiled
as
$key
=>
$value
)
$wheres
[
$key
]
=
$value
;
// Merge compiled where
$wheres
=
array_merge_recursive
(
$wheres
,
$compiled
)
;
}
return
$wheres
;
...
...
@@ -236,21 +244,27 @@ class Query extends \Illuminate\Database\Query\Builder {
{
extract
(
$where
);
// Convert operators
if
(
!
isset
(
$operator
)
||
$operator
==
'='
)
{
return
array
(
$column
=>
$value
);
$query
=
array
(
$column
=>
$value
);
}
else
{
return
array
(
$column
=>
array
(
$this
->
conversion
[
$operator
]
=>
$value
));
$query
=
array
(
$column
=>
array
(
$this
->
conversion
[
$operator
]
=>
$value
));
}
if
(
$boolean
==
'or'
)
{
return
array
(
$this
->
conversion
[
$boolean
]
=>
array
(
$query
));
}
return
$query
;
}
public
function
compileWhereIn
(
$where
)
{
extract
(
$where
);
return
array
(
$column
=>
array
(
$this
->
conversion
[
'in'
]
=>
$values
));
}
...
...
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