in reply to Explain SQL statement
It builds an SQL statement headed for a database. And does it in a dangerous way.
My suggested style would be:
$sql = qq/ SELECT * FROM tbl_admin WHERE day = '$d' AND month = '$m_num' AND year = '$y' AND expal IN (/ . join(',',keys %expal) . qq/ ) AND status = '2'/;
However, note that the above only addresses style issues--the other problems mentioned are not fixed. Further, each programmer is going to have their own style, so I'm sure someone else might format the above in a different way. I am sure, though, that everyone would agree that the above is signficantly better style than the orginal.
In short, do not take this bit of code as anything resembling good coding practice. Judging from the above, I wouldn't trust anything that particular programmer wrote.
For examples of good database practice, I recommend A Short Guide to DBI on perl.com.
----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Explain SQL statement
by Roy Johnson (Monsignor) on May 26, 2004 at 14:30 UTC | |
by Anonymous Monk on May 26, 2004 at 15:31 UTC | |
by Roy Johnson (Monsignor) on May 26, 2004 at 16:25 UTC |