in reply to Perl Mysql Null Recordset
The DBI execute returns the number of rows affected. In the case of a select, it returns the number of rows found. Argh! My bad... jZed caught my mistake. So, something like:
$rs1->execute; if (@{$rs1->fetchrow_array}) { report_error("username_exists"); } else { report_error("username does not exist"); }
You could also have fun with the ternary operator:
$rs1->execute; report_error( (@{$rs1->fetchrow_array) ? "username_exists" : "username + does not exist" );
The ternary operator works by checking the truth of the first part (before the ?) and returning the second part if it is true, else returning the third part.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Mysql Null Recordset
by jZed (Prior) on Nov 17, 2004 at 22:08 UTC |