Changeset 38 for trunk/DNSDB.pm
- Timestamp:
- 11/20/09 17:32:04 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r37 r38 175 175 return ('FAIL',"Need domain status") if !defined($state); 176 176 177 my $sth = $dbh->prepare("SELECT domain_id FROM domains WHERE domain=?"); 177 178 my $dom_id; 179 180 # quick check to start to see if we've already got one 181 $sth->execute($domain); 182 ($dom_id) = $sth->fetchrow_array; 183 184 return ('FAIL', "Domain already exists") if $dom_id; 178 185 179 186 # Allow transactions, and raise an exception on errors so we can catch it later. … … 292 299 local $dbh->{RaiseError} = 1; 293 300 301 my $sth = $dbh->prepare("SELECT group_id FROM groups WHERE group_name=?"); 302 my $group_id; 303 304 # quick check to start to see if we've already got one 305 $sth->execute($groupname); 306 ($group_id) = $sth->fetchrow_array; 307 308 return ('FAIL', "Group already exists") if $group_id; 309 294 310 # Wrap all the SQL in a transaction 295 311 eval { 296 my$sth = $dbh->prepare("INSERT INTO groups (parent_group_id,group_name) VALUES (?,?)");312 $sth = $dbh->prepare("INSERT INTO groups (parent_group_id,group_name) VALUES (?,?)"); 297 313 $sth->execute($pargroup,$groupname); 298 314 … … 454 470 my $phone = shift || ''; # not going format-check 455 471 472 my $sth = $dbh->prepare("SELECT user_id FROM users WHERE username=?"); 456 473 my $user_id; 474 475 # quick check to start to see if we've already got one 476 $sth->execute($username); 477 ($user_id) = $sth->fetchrow_array; 478 479 return ('FAIL', "User already exists") if $user_id; 457 480 458 481 # Allow transactions, and raise an exception on errors so we can catch it later.
Note:
See TracChangeset
for help on using the changeset viewer.