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
459dd836
Commit
459dd836
authored
Apr 01, 2013
by
Jens Segers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More features
parent
904654dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
34 deletions
+12
-34
Model.php
src/Jenssegers/Mongodb/Model.php
+0
-34
Query.php
src/Jenssegers/Mongodb/Query.php
+12
-0
No files found.
src/Jenssegers/Mongodb/Model.php
View file @
459dd836
...
...
@@ -20,40 +20,6 @@ abstract class Model extends \Illuminate\Database\Eloquent\Model {
*/
protected
$primaryKey
=
'_id'
;
/**
* Perform a model insert operation.
*
* @param \Illuminate\Database\Eloquent\Builder
* @return bool
*/
protected
function
performInsert
(
$query
)
{
if
(
$this
->
fireModelEvent
(
'creating'
)
===
false
)
return
false
;
$attributes
=
$this
->
attributes
;
// If the model has an incrementing key, we can use the "insertGetId" method on
// the query builder, which will give us back the final inserted ID for this
// table from the database. Not all tables have to be incrementing though.
if
(
$this
->
incrementing
)
{
$keyName
=
$this
->
getKeyName
();
$this
->
setAttribute
(
$keyName
,
$query
->
insert
(
$attributes
));
}
// If the table is not incrementing we'll simply insert this attributes as they
// are, as this attributes arrays must contain an "id" column already placed
// there by the developer as the manually determined key for these models.
else
{
$query
->
insert
(
$attributes
);
}
$this
->
fireModelEvent
(
'created'
,
false
);
return
true
;
}
/**
* Get a new query builder instance for the connection.
*
...
...
src/Jenssegers/Mongodb/Query.php
View file @
459dd836
...
...
@@ -123,6 +123,18 @@ class Query extends \Illuminate\Database\Query\Builder {
}
}
/**
* Insert a new record and get the value of the primary key.
*
* @param array $values
* @param string $sequence
* @return int
*/
public
function
insertGetId
(
array
$values
,
$sequence
=
null
)
{
return
$this
->
insert
(
$values
);
}
/**
* Update a record in the database.
*
...
...
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