If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > perl-mysql

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-03, 07:42
pearl2 pearl2 is offline
Registered User
 
Join Date: Nov 2003
Location: Sinapore
Posts: 187
perl-mysql

Hi,

I'm using perl to interact with MySQL. I hope someone can help me with the two questions below:

1) How do I obtain the time it takes for the query to complete? I see sites that use databases have something like "Results returned in 0.52 secs" at the bottom of the page. Is that a MySQL thing or is that from the application program (perl, php or java)?

2) I use the code below to check whether a username has been taken:

Code:
sub check_exist {
  # $username is passed from another subroutine
  my $username = shift; # line 1
  do_connect(); # line 2
  $sql = qq{ SELECT * FROM $table{'profiles'} WHERE  nick="$username"}; # line 3
  $sth = $dbh->prepare($sql); # line 4
  my $result = $sth->execute()
    or bail_out("Cannot execute query."); # line 5
  do_disconnect(); # line 6
  do_warn("$username has already been taken. Please choose another one...") if ($result ne '0E0'); # line 7
}
I'm concerned with line 7. If the username is not found in the database, the result returned is '0E0', so do_warn is called. Is that the right way to verify if a username has been taken?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On