my $old = $self->{"emailcache"}{"$type,$email"};
return undef if ($old && $old eq "---");
return $old if $old;
+
+ my $dbh = Bugzilla->dbh;
my @list = ();
my $list = "---";
if ($type eq 'anyexact') {
$list = join(',', @list);
} elsif ($type eq 'substring') {
&::SendSQL("SELECT userid FROM profiles WHERE INSTR(login_name, " .
- &::SqlQuote($email) . ") LIMIT 51");
+ &::SqlQuote($email) . ") " . $dbh->sql_limit(51));
while (&::MoreSQLData()) {
my ($id) = &::FetchSQLData();
push(@list, $id);
# Returns an email change token if the user has one.
my ($userid) = @_;
-
+
+ my $dbh = Bugzilla->dbh;
&::SendSQL("SELECT token FROM tokens WHERE userid = $userid " .
"AND (tokentype = 'emailnew' OR tokentype = 'emailold') " .
- "LIMIT 1");
+ $dbh->sql_limit(1));
my ($token) = &::FetchSQLData();
return $token;
my $wildstr = $str;
my $user = Bugzilla->user;
+ my $dbh = Bugzilla->dbh;
if ($wildstr =~ s/\*/\%/g && # don't do wildcards if no '*' in the string
Param('usermatchmode') ne 'off') { # or if we only want exact matches
}
$query .= " AND disabledtext = '' " if $exclude_disabled;
$query .= "ORDER BY length(login_name) ";
- $query .= "LIMIT $limit " if $limit;
+ $query .= $dbh->sql_limit($limit) if $limit;
# Execute the query, retrieve the results, and make them into
# User objects.
}
$query .= " AND disabledtext = '' " if $exclude_disabled;
$query .= "ORDER BY length(login_name) ";
- $query .= "LIMIT $limit " if $limit;
+ $query .= $dbh->sql_limit($limit) if $limit;
&::PushGlobalSQLState();
&::SendSQL($query);
push(@users, new Bugzilla::User(&::FetchSQLData())) while &::MoreSQLData();
. " FROM quips WHERE approved = 1");
my $random = int(rand($count));
my $quip =
- $dbh->selectrow_array("SELECT quip FROM quips"
- . " WHERE approved = 1 LIMIT $random,1");
+ $dbh->selectrow_array("SELECT quip FROM quips WHERE approved = 1 " .
+ $dbh->sql_limit(1, $random));
return $quip;
}
my $query = $search->getSQL();
if ($::FORM{'limit'} && detaint_natural($::FORM{'limit'})) {
- $query .= " LIMIT $::FORM{'limit'}";
+ $query .= " " . $dbh->sql_limit($::FORM{'limit'});
}
elsif ($fulltext) {
- $query .= " LIMIT 200";
+ $query .= " " . $dbh->sql_limit(200);
}
# Restrict this as much as possible in order to avoid false positives, and
# keep the db search time down
- my $sth2 = $dbh->prepare("SELECT bug_when FROM longdescs WHERE bug_id=? AND who=? AND thetext LIKE ? ORDER BY bug_when LIMIT 1");
+ my $sth2 = $dbh->prepare("SELECT bug_when FROM longdescs
+ WHERE bug_id=? AND who=? AND thetext LIKE ?
+ ORDER BY bug_when " . $dbh->sql_limit(1));
while (my ($bug_id, $attach_id, $submitter_id) = $sth->fetchrow_array()) {
$sth2->execute($bug_id, $submitter_id, "Created an attachment (id=$attach_id)%");
my ($when) = $sth2->fetchrow_array();
# 2003-06-26 Copy the old charting data into the database, and create the
# queries that will keep it all running. When the old charting system goes
# away, if this code ever runs, it'll just find no files and do nothing.
-my $series_exists = $dbh->selectrow_array("SELECT 1 FROM series LIMIT 1");
-
+my $series_exists = $dbh->selectrow_array("SELECT 1 FROM series " .
+ $dbh->sql_limit(1));
if (!$series_exists) {
print "Migrating old chart data into database ...\n" unless $silent;
sub regenerate_stats {
my $dir = shift;
my $product = shift;
- my $when = localtime(time());
+ my $dbh = Bugzilla->dbh;
+ my $when = localtime(time());
my $tstart = time();
# NB: Need to mangle the product for the filename, but use the real
"to_days('1970-01-01') " .
"FROM bugs $from_product WHERE to_days(creation_ts) != 'NULL' " .
$and_product .
- "ORDER BY start LIMIT 1");
+ "ORDER BY start " . $dbh->sql_limit(1));
my ($start, $end, $base) = FetchSQLData();
if (!defined $start) {
"AND fielddefs.name = 'bug_status' " .
"AND bugs_activity.bug_id = $bug " .
"AND bugs_activity.bug_when >= from_days($day) " .
- "ORDER BY bugs_activity.bug_when LIMIT 1");
+ "ORDER BY bugs_activity.bug_when " .
+ $dbh->sql_limit(1));
my $status;
if (@row = FetchSQLData()) {
"AND fielddefs.name = 'resolution' " .
"AND bugs_activity.bug_id = $bug " .
"AND bugs_activity.bug_when >= from_days($day) " .
- "ORDER BY bugs_activity.bug_when LIMIT 1");
+ "ORDER BY bugs_activity.bug_when " .
+ $dbh->sql_limit(1));
if (@row = FetchSQLData()) {
$status = $row[0];
$product_id = 0 unless ($product_id);
return $::CachedAnyEntryGroups{$product_id}
if defined($::CachedAnyEntryGroups{$product_id});
+ my $dbh = Bugzilla->dbh;
PushGlobalSQLState();
my $query = "SELECT 1 FROM group_control_map WHERE entry != 0";
$query .= " AND product_id = $product_id" if ($product_id);
- $query .= " LIMIT 1";
+ $query .= " " . $dbh->sql_limit(1);
SendSQL($query);
if (MoreSQLData()) {
$::CachedAnyEntryGroups{$product_id} = MoreSQLData();
# one bug to another.
sub AnyDefaultGroups {
return $::CachedAnyDefaultGroups if defined($::CachedAnyDefaultGroups);
+ my $dbh = Bugzilla->dbh;
PushGlobalSQLState();
SendSQL("SELECT 1 FROM group_control_map, groups WHERE " .
"groups.id = group_control_map.group_id " .
"AND isactive != 0 AND " .
"(membercontrol = " . CONTROLMAPDEFAULT .
" OR othercontrol = " . CONTROLMAPDEFAULT .
- ") LIMIT 1");
+ ") " . $dbh->sql_limit(1));
$::CachedAnyDefaultGroups = MoreSQLData();
FetchSQLData();
PopGlobalSQLState();
# bugs in this product at all.
sub CanEditProductId {
my ($productid) = @_;
+ my $dbh = Bugzilla->dbh;
my $query = "SELECT group_id FROM group_control_map " .
"WHERE product_id = $productid " .
"AND canedit != 0 ";
$query .= "AND group_id NOT IN(" .
join(',', values(%{Bugzilla->user->groups})) . ") ";
}
- $query .= "LIMIT 1";
+ $query .= $dbh->sql_limit(1);
PushGlobalSQLState();
SendSQL($query);
my ($result) = FetchSQLData();
# product.
sub CanEnterProduct {
my ($productname) = @_;
+ my $dbh = Bugzilla->dbh;
my $query = "SELECT group_id IS NULL " .
"FROM products " .
"LEFT JOIN group_control_map " .
$query .= "AND group_id NOT IN(" .
join(',', values(%{Bugzilla->user->groups})) . ") ";
}
- $query .= "WHERE products.name = " . SqlQuote($productname) . " LIMIT 1";
+ $query .= "WHERE products.name = " . SqlQuote($productname) . " " .
+ $dbh->sql_limit(1);
PushGlobalSQLState();
SendSQL($query);
my ($ret) = FetchSQLData();
$::query .= "product_id = $prod_id";
} else {
SendSQL("SELECT DISTINCT product_id FROM bugs WHERE bug_id IN (" .
- join(',', @idlist) . ") LIMIT 2");
+ join(',', @idlist) . ") " . $dbh->sql_limit(2));
$prod_id = FetchOneColumn();
$prod_id = undef if (FetchOneColumn());
}
if (defined $cgi->param('rederivegroups')) {
Status("OK, All users' inherited permissions will be rechecked when " .
"they next access Bugzilla.");
- SendSQL("UPDATE groups SET last_changed = NOW() LIMIT 1");
+ SendSQL("UPDATE groups SET last_changed = NOW() " . $dbh->sql_limit(1));
}
# rederivegroupsnow is REALLY only for testing.
$dbh->bz_lock_tables('user_group_map WRITE', 'profiles WRITE');
SendSQL("SELECT userid FROM profiles " .
"WHERE refreshed_when > 0 " .
- "AND refreshed_when < " . SqlQuote($cutoff) .
- " LIMIT 1000");
+ "AND refreshed_when < " . SqlQuote($cutoff) . " " .
+ $dbh->sql_limit(1000));
my $count = 0;
while ((my $id) = FetchSQLData()) {
$count++;
# SaveFoo may be called before DoFoo.
###############################################################################
sub DoAccount {
+ my $dbh = Bugzilla->dbh;
SendSQL("SELECT realname FROM profiles WHERE userid = $userid");
$vars->{'realname'} = FetchSQLData();
FROM tokens
WHERE userid = $userid
AND tokentype LIKE 'email%'
- ORDER BY tokentype ASC LIMIT 1");
+ ORDER BY tokentype ASC " . $dbh->sql_limit(1));
if(MoreSQLData()) {
my ($tokentype, $change_date, $eventdata) = &::FetchSQLData();
$vars->{'login_change_date'} = $change_date;
"LEFT JOIN whine_events " .
" ON whine_events.id = whine_schedules.eventid " .
"WHERE run_next <= NOW() " .
- "ORDER BY run_next LIMIT 1"
+ "ORDER BY run_next " .
+ $dbh->sql_limit(1)
);
# get all pending schedules matching an eventid