This part of your code does not "pull all the customerIDs into an array". Rather, the fetchrow_array()-method, "Fetches the next row of data and returns it as a list containing the field values" (as state the docs).my $sth = $dbh->prepare("select servproID from fran"); $sth->execute; while(@row = $sth->fetchrow_array()) { foreach $row(@row) { ... } }
So, @row = $sth->fetchrow_array() would be clearer if you renamed it to @fields = $sth->fetchrow_array() and then foreach my $field (@fields) { ...}. And even that is partly misleading since your SQL-statement only pulls 1 field from the database and therefore the whole foreach-loop is just expensive decoration.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to Re: Database Error? DBD:MySQL:DB DO failed: Duplicate entry '0' for key '1' at
by CountZero
in thread Database Error? DBD:MySQL:DB DO failed: Duplicate entry '0' for key '1' at
by jdlev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |