[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cgiapp] Class::DBI


See my comments interleaved below ...


-----Original Message-----
From: jo / ak [mailto:suppressed
Sent: Monday, November 17, 2003 2:35 PM
To: suppressed
Subject: RE: [cgiapp] Class::DBI


> What I want to build is a somewhat generic DbEdit module, with
> simple standard functions to search/list/display and
> insert/update/delete arbitrary records stored in a database. I
> wonder if it is possible to maintain all record-specific
> information in the class-dbi subclasses.

It is quite hard to do, if you factor in the need to provide perl "validations" of
each of the inputs.  Each of the input fields needs to have a different kind of validation ( just words allowed, just numbers, etc.)  It would be fairly easy to grab the input obj ($q) compare it to the known fields in the Class::DBI instance and insert those that match.  I do this in my code, after I do field validation.  

One interesting idea is to have a field naming scheme whereby the validation is determined by the passed in field name, thus a field called Address_text_25 would be limited to 25 chars of alpha text, a field called zip_int_5 would be int length 5, etc.  This would be insecure if not for the fact that only field names matching those expected by your Class::DBI instance would be allowed.  Another approach might be to store information about how to validate fields in the DB itself.  Thus you could configure a new app just by the db design and implementation.



> I started in adding a "param" method to my class-dbi subclass, so
> I can associate the class-dbi object with a template object. This
> worked fine for one object (= record), but I didn't find a
> solution as simple for a list of objects (from a class-dbi search
> or retrieve_all).

Yeah, at some point you need to use the modules to code a specific solution for your needs.  In my example, In a loop, I load a couple of records into the one-to-many table for each main record.  And yes, I had to do most of that coding.

Cheers

--Fred


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.