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
c9333002
Commit
c9333002
authored
Oct 29, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preparing for laravel 4.1, fixes #60
parent
1089ee3b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
8 deletions
+38
-8
composer.json
composer.json
+1
-1
phpunit.xml
phpunit.xml
+4
-0
Builder.php
src/Jenssegers/Mongodb/Builder.php
+29
-7
QueryTest.php
tests/QueryTest.php
+4
-0
No files found.
composer.json
View file @
c9333002
...
@@ -25,4 +25,4 @@
...
@@ -25,4 +25,4 @@
}
}
},
},
"minimum-stability"
:
"dev"
"minimum-stability"
:
"dev"
}
}
\ No newline at end of file
phpunit.xml
View file @
c9333002
...
@@ -23,5 +23,9 @@
...
@@ -23,5 +23,9 @@
<testsuite
name=
"cache"
>
<testsuite
name=
"cache"
>
<directory>
tests/CacheTest.php
</directory>
<directory>
tests/CacheTest.php
</directory>
</testsuite>
</testsuite>
<testsuite
name=
"builder"
>
<directory>
tests/QueryBuilderTest.php
</directory>
<directory>
tests/QueryTest.php
</directory>
</testsuite>
</testsuites>
</testsuites>
</phpunit>
</phpunit>
src/Jenssegers/Mongodb/Builder.php
View file @
c9333002
...
@@ -277,13 +277,14 @@ class Builder extends \Illuminate\Database\Query\Builder {
...
@@ -277,13 +277,14 @@ class Builder extends \Illuminate\Database\Query\Builder {
* @param string $column
* @param string $column
* @param array $values
* @param array $values
* @param string $boolean
* @param string $boolean
* @return \Illuminate\Database\Query\Builder
* @param bool $not
* @return Builder
*/
*/
public
function
whereBetween
(
$column
,
array
$values
,
$boolean
=
'and'
)
public
function
whereBetween
(
$column
,
array
$values
,
$boolean
=
'and'
,
$not
=
false
)
{
{
$type
=
'between'
;
$type
=
'between'
;
$this
->
wheres
[]
=
compact
(
'column'
,
'type'
,
'boolean'
,
'values'
);
$this
->
wheres
[]
=
compact
(
'column'
,
'type'
,
'boolean'
,
'values'
,
'not'
);
return
$this
;
return
$this
;
}
}
...
@@ -739,11 +740,32 @@ class Builder extends \Illuminate\Database\Query\Builder {
...
@@ -739,11 +740,32 @@ class Builder extends \Illuminate\Database\Query\Builder {
{
{
extract
(
$where
);
extract
(
$where
);
return
array
(
if
(
$not
)
$column
=>
array
(
{
'$gte'
=>
$values
[
0
],
return
array
(
'$lte'
=>
$values
[
1
])
'$or'
=>
array
(
array
(
$column
=>
array
(
'$lte'
=>
$values
[
0
]
)
),
array
(
$column
=>
array
(
'$gte'
=>
$values
[
1
]
)
)
)
);
);
}
else
{
return
array
(
$column
=>
array
(
'$gte'
=>
$values
[
0
],
'$lte'
=>
$values
[
1
]
)
);
}
}
}
protected
function
compileWhereRaw
(
$where
)
protected
function
compileWhereRaw
(
$where
)
...
...
tests/QueryTest.php
View file @
c9333002
...
@@ -103,6 +103,10 @@ class QueryTest extends PHPUnit_Framework_TestCase {
...
@@ -103,6 +103,10 @@ class QueryTest extends PHPUnit_Framework_TestCase {
$users
=
User
::
whereBetween
(
'age'
,
array
(
13
,
23
))
->
get
();
$users
=
User
::
whereBetween
(
'age'
,
array
(
13
,
23
))
->
get
();
$this
->
assertEquals
(
2
,
count
(
$users
));
$this
->
assertEquals
(
2
,
count
(
$users
));
// testing whereNotBetween for version 4.1
$users
=
User
::
whereBetween
(
'age'
,
array
(
0
,
25
),
'and'
,
true
)
->
get
();
$this
->
assertEquals
(
6
,
count
(
$users
));
}
}
public
function
testIn
()
public
function
testIn
()
...
...
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