Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
b5e54941
Commit
b5e54941
authored
Jan 05, 2013
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1410 from franzliedke/patch-56
Make insert_get_id() work with non-auto-incrementing columns.
parents
875cac6c
b88c9144
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
query.php
laravel/database/query.php
+8
-3
No files found.
laravel/database/query.php
View file @
b5e54941
...
...
@@ -810,11 +810,11 @@ class Query {
}
/**
* Insert an array of values into the database table and return the
ID
.
* Insert an array of values into the database table and return the
key
.
*
* @param array $values
* @param string $column
* @return
int
* @return
mixed
*/
public
function
insert_get_id
(
$values
,
$column
=
'id'
)
{
...
...
@@ -822,7 +822,12 @@ class Query {
$result
=
$this
->
connection
->
query
(
$sql
,
array_values
(
$values
));
if
(
$this
->
grammar
instanceof
Postgres
)
// If the key is not auto-incrementing, we will just return the inserted value
if
(
isset
(
$values
[
$column
]))
{
return
$values
[
$column
];
}
else
if
(
$this
->
grammar
instanceof
Postgres
)
{
return
(
int
)
$result
[
0
]
->
$column
;
}
...
...
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