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.
"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');
}
}
}
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'});
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";
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;
}
'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.
$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 {
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");
}
#
# 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)
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);
"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.
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" .
"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.
#+++ 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();
my $parser = new XML::Parser(Style => 'Tree');
my $tree = $parser->parse($xml);
+my $dbh = Bugzilla->dbh;
my $maintainer;
if (defined $tree->[1][0]->{'maintainer'}) {
. 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'})) {
my $cgi = Bugzilla->cgi;
+my $dbh = Bugzilla->dbh;
+
# do a match on the fields if applicable
&Bugzilla::User::match_field ({
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) {