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
9d26ccb9
Commit
9d26ccb9
authored
Mar 31, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding some features
parent
d151beff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
0 deletions
+99
-0
Query.php
src/Jenssegers/Mongodb/Query.php
+99
-0
No files found.
src/Jenssegers/Mongodb/Query.php
View file @
9d26ccb9
...
@@ -53,6 +53,13 @@ class Query {
...
@@ -53,6 +53,13 @@ class Query {
*/
*/
public
$limit
;
public
$limit
;
/**
* The number of records to skip.
*
* @var int
*/
public
$offset
;
/**
/**
* All of the available operators.
* All of the available operators.
*
*
...
@@ -93,6 +100,19 @@ class Query {
...
@@ -93,6 +100,19 @@ class Query {
return
$this
;
return
$this
;
}
}
/**
* Set the "offset" value of the query.
*
* @param int $value
* @return \Illuminate\Database\Query\Builder
*/
public
function
skip
(
$value
)
{
$this
->
offset
=
$value
;
return
$this
;
}
/**
/**
* Add an "order by" clause to the query.
* Add an "order by" clause to the query.
*
*
...
@@ -186,6 +206,12 @@ class Query {
...
@@ -186,6 +206,12 @@ class Query {
$cursor
->
sort
(
$this
->
orders
);
$cursor
->
sort
(
$this
->
orders
);
}
}
// Apply offset
if
(
$this
->
offset
)
{
$cursor
->
skip
(
$this
->
offset
);
}
// Apply limit
// Apply limit
if
(
$this
->
limit
)
if
(
$this
->
limit
)
{
{
...
@@ -196,6 +222,79 @@ class Query {
...
@@ -196,6 +222,79 @@ class Query {
return
$this
->
toCollection
(
$cursor
);
return
$this
->
toCollection
(
$cursor
);
}
}
/**
* Insert a new document into the database.
*
* @param array $data
* @return mixed
*/
public
function
insert
(
$data
)
{
$result
=
$this
->
collection
->
insert
(
$data
);
if
(
1
==
(
int
)
$result
[
'ok'
])
{
return
$data
[
'_id'
];
}
return
false
;
}
/**
* Save the document. Insert into the database if its not exists.
*
* @param array $data
* @return mixed
*/
public
function
save
(
$data
)
{
$this
->
collection
->
save
(
$data
);
if
(
isset
(
$data
[
'_id'
]))
{
return
$data
[
'_id'
];
}
return
false
;
}
/**
* Update a document in the database.
*
* @param array $data
* @return int
*/
public
function
update
(
array
$data
)
{
$update
=
array
(
'$set'
=>
$data
);
$result
=
$this
->
collection
->
update
(
$this
->
wheres
,
$update
,
array
(
'multiple'
=>
true
));
if
(
1
==
(
int
)
$result
[
'ok'
])
{
return
$result
[
'n'
];
}
return
0
;
}
/**
* Delete a document from the database.
*
* @return int
*/
public
function
delete
()
{
$result
=
$this
->
collection
->
remove
(
$this
->
wheres
);
if
(
1
==
(
int
)
$result
[
'ok'
])
{
return
$result
[
'n'
];
}
return
0
;
}
/**
/**
* Transform to model collection.
* Transform to model collection.
*
*
...
...
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