summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Auth/Login/WWW/CGI.pm2
-rw-r--r--Bugzilla/Auth/Login/WWW/Env.pm4
-rwxr-xr-xattachment.cgi6
-rwxr-xr-xchecksetup.pl17
-rwxr-xr-xcontrib/bug_email.pl5
-rwxr-xr-xeditgroups.cgi3
-rwxr-xr-xeditproducts.cgi6
-rwxr-xr-xeditusers.cgi3
-rwxr-xr-ximportxml.pl4
-rwxr-xr-xpost_bug.cgi5
10 files changed, 21 insertions, 34 deletions
diff --git a/Bugzilla/Auth/Login/WWW/CGI.pm b/Bugzilla/Auth/Login/WWW/CGI.pm
index 10eb85f60..98999a368 100644
--- a/Bugzilla/Auth/Login/WWW/CGI.pm
+++ b/Bugzilla/Auth/Login/WWW/CGI.pm
@@ -72,7 +72,7 @@ sub login {
VALUES (?, ?, NOW())",
undef,
$userid, $ipaddr);
- my $logincookie = $dbh->selectrow_array("SELECT LAST_INSERT_ID()");
+ my $logincookie = $dbh->bz_last_key('logincookies', 'cookie');
# Remember cookie only if admin has told so
# or admin didn't forbid it and user told to remember.
diff --git a/Bugzilla/Auth/Login/WWW/Env.pm b/Bugzilla/Auth/Login/WWW/Env.pm
index abd176315..54e202bbf 100644
--- a/Bugzilla/Auth/Login/WWW/Env.pm
+++ b/Bugzilla/Auth/Login/WWW/Env.pm
@@ -116,9 +116,7 @@ sub login {
"realname, disabledtext " .
") VALUES ( ?, ?, ?, '' )");
$sth->execute($env_email, '*', $env_realname);
- $sth = $dbh->prepare("SELECT last_insert_id()");
- $sth->execute();
- $matched_userid = $sth->fetch->[0];
+ $matched_userid = $dbh->bz_last_key('profiles', 'userid');
}
}
}
diff --git a/attachment.cgi b/attachment.cgi
index 5e10d8fee..3522f9e26 100755
--- a/attachment.cgi
+++ b/attachment.cgi
@@ -869,7 +869,8 @@ sub insert
my ($data) = @_;
# Insert a new attachment into the database.
-
+ my $dbh = Bugzilla->dbh;
+
# Escape characters in strings that will be used in SQL statements.
$filename = SqlQuote($filename);
my $description = SqlQuote($::FORM{'description'});
@@ -886,8 +887,7 @@ sub insert
VALUES ($::FORM{'bugid'}, $sql_timestamp, $filename, $description, $contenttype, $::FORM{'ispatch'}, $isprivate, $::userid, $thedata)");
# Retrieve the ID of the newly created attachment record.
- SendSQL("SELECT LAST_INSERT_ID()");
- my $attachid = FetchOneColumn();
+ my $attachid = $dbh->bz_last_key('attachments', 'attach_id');
# Insert a comment about the new attachment into the database.
my $comment = "Created an attachment (id=$attachid)\n$::FORM{'description'}\n";
diff --git a/checksetup.pl b/checksetup.pl
index 79095ee3a..388703ab1 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -2232,9 +2232,7 @@ sub AddGroup {
VALUES (?, ?, ?, ?)');
$sth->execute($name, $desc, $userregexp, 0);
- $sth = $dbh->prepare("select last_insert_id()");
- $sth->execute();
- my ($last) = $sth->fetchrow_array();
+ my $last = $dbh->bz_last_key('groups', 'id');
return $last;
}
@@ -2459,9 +2457,8 @@ unless ($sth->rows) {
'bugzilla.", "", 0, 0, 0)');
# We could probably just assume that this is "1", but better
# safe than sorry...
- $sth = $dbh->prepare("SELECT LAST_INSERT_ID()");
- $sth->execute;
- my ($product_id) = $sth->fetchrow_array;
+ my $product_id = $dbh->bz_last_key('products', 'id');
+
$dbh->do(qq{INSERT INTO versions (value, product_id) VALUES ("other", $product_id)});
# note: since admin user is not yet known, components gets a 0 for
# initialowner and this is fixed during final checks.
@@ -2801,9 +2798,7 @@ if (GetFieldDef('bugs', 'long_desc')) {
$dbh->quote($name) .
", " . $dbh->quote(bz_crypt('okthen')) . ", " .
"'Account created only to maintain database integrity')");
- $s2 = $dbh->prepare("SELECT LAST_INSERT_ID()");
- $s2->execute();
- ($who) = ($s2->fetchrow_array());
+ $who = $dbh->bz_last_key('profiles', 'userid');
}
next;
} else {
@@ -2850,9 +2845,7 @@ if (GetFieldDef('bugs_activity', 'field')) {
if (!$id) {
$dbh->do("INSERT INTO fielddefs (name, description) VALUES " .
"($q, $q)");
- $s2 = $dbh->prepare("SELECT LAST_INSERT_ID()");
- $s2->execute();
- ($id) = ($s2->fetchrow_array());
+ $id = $dbh->bz_last_key('fielddefs', 'fieldid');
}
$dbh->do("UPDATE bugs_activity SET fieldid = $id WHERE field = $q");
}
diff --git a/contrib/bug_email.pl b/contrib/bug_email.pl
index 1f2f28421..7fb6b533c 100755
--- a/contrib/bug_email.pl
+++ b/contrib/bug_email.pl
@@ -38,7 +38,7 @@
#
# You need to work with bug_email.pl the MIME::Parser installed.
#
-# $Id: bug_email.pl,v 1.23 2005/02/08 16:51:03 travis%sedsystems.ca Exp $
+# $Id: bug_email.pl,v 1.24 2005/02/18 16:01:48 mkanat%kerio.com Exp $
###############################################################
# 02/12/2000 (SML)
@@ -1151,8 +1151,7 @@ END
if( ! $test ) {
SendSQL($query);
- SendSQL("select LAST_INSERT_ID()");
- $id = FetchOneColumn();
+ $id = Bugzilla->dbh->bz_last_key('bugs', 'bug_id');
my $long_desc_query = "INSERT INTO longdescs SET bug_id=$id, who=$userid, bug_when=\'$bug_when\', thetext=" . SqlQuote($comment);
SendSQL($long_desc_query);
diff --git a/editgroups.cgi b/editgroups.cgi
index c3be719c7..02f24b1e4 100755
--- a/editgroups.cgi
+++ b/editgroups.cgi
@@ -274,8 +274,7 @@ if ($action eq 'new') {
"1," .
SqlQuote($regexp) . ", " .
$isactive . ", NOW())" );
- SendSQL("SELECT last_insert_id()");
- my $gid = FetchOneColumn();
+ my $gid = $dbh->bz_last_key('groups', 'id');
my $admin = GroupNameToId('admin');
# Since we created a new group, give the "admin" group all privileges
# initially.
diff --git a/editproducts.cgi b/editproducts.cgi
index f066f7029..11658c29a 100755
--- a/editproducts.cgi
+++ b/editproducts.cgi
@@ -506,8 +506,7 @@ if ($action eq 'new') {
SqlQuote($votestoconfirm) . "," .
SqlQuote($defaultmilestone) . "," .
SqlQuote($classification_id) . ")");
- SendSQL("SELECT LAST_INSERT_ID()");
- my $product_id = FetchOneColumn();
+ my $product_id = $dbh->bz_last_key('products', 'id');
SendSQL("INSERT INTO versions ( " .
"value, product_id" .
@@ -531,8 +530,7 @@ if ($action eq 'new') {
"VALUES (" .
SqlQuote($productgroup) . ", " .
SqlQuote("Access to bugs in the $product product") . ", 1, NOW())");
- SendSQL("SELECT last_insert_id()");
- my $gid = FetchOneColumn();
+ my $gid = $dbh->bz_last_key('groups', 'id');
my $admin = GroupNameToId('admin');
# If we created a new group, give the "admin" group priviledges
# initially.
diff --git a/editusers.cgi b/editusers.cgi
index 9c8de6164..9a6de0d17 100755
--- a/editusers.cgi
+++ b/editusers.cgi
@@ -461,8 +461,7 @@ if ($action eq 'new') {
#+++ send e-mail away
print "OK, done.<br>\n";
- SendSQL("SELECT last_insert_id()");
- my ($newuserid) = FetchSQLData();
+ my $newuserid = $dbh->bz_last_key('profiles', 'userid');
my $changeduser = new Bugzilla::User($newuserid);
$changeduser->derive_groups();
diff --git a/importxml.pl b/importxml.pl
index 21d962d41..3b3b24a17 100755
--- a/importxml.pl
+++ b/importxml.pl
@@ -162,6 +162,7 @@ $xml =~ s/^.+(<\?xml version.+)$/$1/s;
my $parser = new XML::Parser(Style => 'Tree');
my $tree = $parser->parse($xml);
+my $dbh = Bugzilla->dbh;
my $maintainer;
if (defined $tree->[1][0]->{'maintainer'}) {
@@ -609,8 +610,7 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
. join (",\n", @values)
. "\n)\n";
SendSQL($query);
- SendSQL("select LAST_INSERT_ID()");
- my $id = FetchOneColumn();
+ my $id = $dbh->bz_last_key('bugs', 'bug_id');
if (defined $bug_fields{'cc'}) {
foreach my $person (split(/[ ,]/, $bug_fields{'cc'})) {
diff --git a/post_bug.cgi b/post_bug.cgi
index 0f5abddb2..3e5b289a8 100755
--- a/post_bug.cgi
+++ b/post_bug.cgi
@@ -56,6 +56,8 @@ my $user = Bugzilla->login(LOGIN_REQUIRED);
my $cgi = Bugzilla->cgi;
+my $dbh = Bugzilla->dbh;
+
# do a match on the fields if applicable
&Bugzilla::User::match_field ({
@@ -420,8 +422,7 @@ while (MoreSQLData()) {
SendSQL($sql);
# Get the bug ID back.
-SendSQL("select LAST_INSERT_ID()");
-my $id = FetchOneColumn();
+my $id = $dbh->bz_last_key('bugs', 'bug_id');
# Add the group restrictions
foreach my $grouptoadd (@groupstoadd) {