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
a6d0537e
Commit
a6d0537e
authored
Apr 27, 2013
by
Jens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed operator bug
parent
ffa1875a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
33 deletions
+12
-33
Query.php
src/Jenssegers/Mongodb/Query.php
+12
-33
No files found.
src/Jenssegers/Mongodb/Query.php
View file @
a6d0537e
...
...
@@ -16,7 +16,7 @@ class Query extends \Illuminate\Database\Query\Builder {
*
* @var array
*/
protected
$
operators
=
array
(
protected
$
conversion
=
array
(
'='
=>
'='
,
'!='
=>
'$ne'
,
'<'
=>
'$lt'
,
...
...
@@ -215,6 +215,12 @@ class Query extends \Illuminate\Database\Query\Builder {
foreach
(
$this
->
wheres
as
$where
)
{
// Convert id's
if
(
$where
[
'column'
]
==
'_id'
)
{
$where
[
'value'
]
=
(
$where
[
'value'
]
instanceof
MongoID
)
?
$where
[
'value'
]
:
new
MongoID
(
$where
[
'value'
]);
}
// Delegate
$method
=
"compileWhere
{
$where
[
'type'
]
}
"
;
$compiled
=
$this
->
{
$method
}(
$where
);
...
...
@@ -230,12 +236,6 @@ class Query extends \Illuminate\Database\Query\Builder {
{
extract
(
$where
);
// Convert id's
if
(
$column
==
'_id'
)
{
$value
=
(
$value
instanceof
MongoID
)
?
$value
:
new
MongoID
(
$value
);
}
// Convert operators
if
(
!
isset
(
$operator
)
||
$operator
==
'='
)
{
...
...
@@ -243,50 +243,29 @@ class Query extends \Illuminate\Database\Query\Builder {
}
else
{
return
array
(
$column
=>
array
(
$this
->
operators
[
$operator
]
=>
$value
));
return
array
(
$column
=>
array
(
$this
->
conversion
[
$operator
]
=>
$value
));
}
}
public
function
compileWhereIn
(
$where
)
{
extract
(
$where
);
// Convert id's
if
(
$column
==
'_id'
)
{
foreach
(
$values
as
&
$value
)
$value
=
(
$value
instanceof
MongoID
)
?
$value
:
new
MongoID
(
$value
);
}
return
array
(
$column
=>
array
(
$this
->
operators
[
'in'
]
=>
$values
));
return
array
(
$column
=>
array
(
$this
->
conversion
[
'in'
]
=>
$values
));
}
public
function
compileWhereNull
(
$where
)
{
extract
(
$where
);
// Convert id's
if
(
$column
==
'_id'
)
{
foreach
(
$values
as
&
$value
)
$value
=
(
$value
instanceof
MongoID
)
?
$value
:
new
MongoID
(
$value
);
}
return
array
(
$column
=>
array
(
$this
->
operators
[
'exists'
]
=>
false
));
return
array
(
$column
=>
array
(
$this
->
conversion
[
'exists'
]
=>
false
));
}
public
function
compileWhereNotNull
(
$where
)
{
extract
(
$where
);
// Convert id's
if
(
$column
==
'_id'
)
{
foreach
(
$values
as
&
$value
)
$value
=
(
$value
instanceof
MongoID
)
?
$value
:
new
MongoID
(
$value
);
}
return
array
(
$column
=>
array
(
$this
->
operators
[
'exists'
]
=>
true
));
return
array
(
$column
=>
array
(
$this
->
conversion
[
'exists'
]
=>
true
));
}
}
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