Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
81a05023
Commit
81a05023
authored
May 18, 2016
by
Francesc Guasch
Browse files
mysql and sqlite driver last insert id
parent
b28d4c5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/Ravada/Request.pm
View file @
81a05023
...
...
@@ -130,6 +130,28 @@ sub _new_request {
}
sub
last_insert_id
{
my
$driver
=
$CONNECTOR
->
dbh
->
{
Driver
}
->
{
Name
};
if
(
$driver
=~
/sqlite/i
)
{
return
_last_insert_id_sqlite
(
@
_
);
}
elsif
(
$driver
=~
/mysql/i
)
{
return
_last_insert_id_mysql
(
@
_
);
}
else
{
confess
"
I don't know how to get last_insert_id for
$driver
";
}
}
sub
_last_insert_id_mysql
{
my
$self
=
shift
;
my
$sth
=
$CONNECTOR
->
dbh
->
prepare
("
SELECT last_insert_id()
");
$sth
->
execute
;
my
(
$id
)
=
$sth
->
fetchrow
;
$sth
->
finish
;
return
$id
;
}
sub
_last_insert_id_sqlite
{
my
$self
=
shift
;
my
$sth
=
$CONNECTOR
->
dbh
->
prepare
("
SELECT last_insert_rowid()
");
...
...
Write
Preview
Supports
Markdown
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