yep.
i had a function like this myself once, but i was just wondering whether
there's a way to tell the DBI to insert a row from a given hash,
interpreting the keys as column-names, and preferably ignoring keys that
don't appear in the DB as column....something like an inversed
fetchrow_hashref, i guess ("insertrow_hashref" ?).

shouldn't be too hard to code, but if it's already out there, that'd be
cool....

anybody?

M.

> -----Original Message-----
> From: Michael A Chase [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, January 18, 2002 5:33 PM
> To: Moritz von Schweinitz; [EMAIL PROTECTED]
> Subject: Re: inserting CGI-data into mysql-DB style question
> 
> 
> Something very similar came up a couple days ago.  See the 
> attached email.
> -- 
> Mac :})
> ** I normally forward private questions to the appropriate 
> mail list. **
> Give a hobbit a fish and he eats fish for a day.
> Give a hobbit a ring and he eats fish for an age.
> ----- Original Message ----- 
> From: "Moritz von Schweinitz" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, January 18, 2002 14:35
> Subject: inserting CGI-data into mysql-DB style question
> 
> 
> > sorry if this is a banal question, but my brain just got 
> sick and tired
> > of
> > 
> > $dbh->do("INSERT INTO tablename
> > (
> > firstname,
> > surname,
> > bla3,
> > bla4,
> > bla5,
> > bla6
> > )
> > VALUES
> > (
> > ?,
> > ?,
> > ?,
> > ?,
> > ?,
> > ?
> > )
> > ", undef, $in{firstname}, $in{surname}, $in{bla3}, [and
> > so on]);
> > 
> > is there a nice way to qoute the contents of my %in, and insert them
> > without always having to count question-marks, and watching 
> out that the
> > right hash-element maps to the right question-mark, which 
> in turn maps
> > to the correct column?
> > 
> > all the nice bind-functions don't seem to make life easier in this
> > aspect.
> > 
> > am i missing some basic (my)SQL/DBI-command or something?
> > 
> > *confused*
> > 
> > M.
> > 
> > 
> > 
> > 
> > 
> 

Reply via email to