in reply to Architecture of a Database system

I posted a snippet a while ago that shows one method of generating an SQL INSERT statement from an anonymous hash and a table name, which is about as simple as you can get. Plus it does clever things to produce placeholdered statements and batched commits.

It really is a funky piece of code that serves me well. OTOH it only works well in a limited domain, that is, it is not the ideal solution when you are inserting different columns sets at different points in the program (as it must generate a fresh prepared statement for each call and it's up to you to remember to tell it to do so).

So I think it would be hard to come up with something that satisfies the general case.

Plus, my main aim was to minimise characters. Not in a golf TM sense, but I didn't want to have to dick around with too many braces, parens or other syntactic fluff.

An example call looks like this:

insert 'aglrelvalue', { att_value => $id_mission, attribute_id => B0, client => DEFCLIENT, last_update => $mis_update, percentage => 100.00, rel_attr_id => YC, rel_value => $regvp, user_id => USER, };

--
g r i n d e r

Replies are listed 'Best First'.
Re: Re: Architecture of a Database system
by princepawn (Parson) on Apr 05, 2001 at 00:02 UTC
    what you have done is re-implement the DBIx::Recordset Insert() API function.
      Man I hate when that happens.

      --
      g r i n d e r