Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-03, 08:42
pearl2 pearl2 is offline
Registered User
 
Join Date: Nov 2003
Location: Sinapore
Posts: 140
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

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