in reply to DB Update w/ Hash
Update:
I played around with mysql a bit, and it appears that it doesn't like it when you quote the column name in the SET part of an UPDATE. Quoting fields works in WHEREs and maybe other places, so this may be a bug (I don't see it documented anywhere). Since placeholders automatically quote their values, I suppose you can't use placeholders here. Which will leave you with a performance hit, sadly, as you'll need to reinterpolate a new statement handle each time. But beware! If %keys comes from an untrusted source, you'll need to very carefully taint-check the fields. The following code should at least function.
foreach $key(keys %user_info) { next if $key eq "UserId"; $sth = $dbh->prepare(" Update tUser Set $key = ? Where UserId = ? "); $sth->execute($user_info{$key}, $user_info{'UserId'}); } $sth->finish();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: DB Update w/ Hash
by Anonymous Monk on Sep 06, 2000 at 14:54 UTC | |
by davorg (Chancellor) on Sep 06, 2000 at 15:13 UTC | |
|
RE: Re: DB Update w/ Hash
by Jonas (Beadle) on Sep 05, 2000 at 06:04 UTC |