Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Return query time taken...

Author  Topic 

giro
Starting Member

8 Posts

Posted - 2003-12-07 : 05:17:27
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:

sub check_exist {
# $username is obtained from an online form
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?

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2003-12-07 : 06:43:21
quote:

I'm using perl to interact with MySQL



I'm sorry

Sorry, we are an SQL Server site here. You might be better off asking somewhere that deals with Perl or MySQL.



Damian
Go to Top of Page

giro
Starting Member

8 Posts

Posted - 2003-12-07 : 19:16:32
Thanks for pointing out :) I'll restrict my questions to just myslq and database related in future.
Go to Top of Page
   

- Advertisement -