I'm getting increasing amounts of work which involve allowing a database to be manipulated, searched, edited, etc via a web-page. The back-end DB is MySQL, and I have no problem with the DBI module which provides a very complete set of DB access routines. I also make extensive use of HTML::Template, which makes data presentation a bit much easier.

However, it is a pita to write routines which create an SQL query based on user input (eg when searching); to check for errors in data entry and notify the user of those errors; to format the records for viewing by the user. If I could do it just once in a generic fashion, that would save me hours per project, but it seems like each application needs numerous tweaks and adjustments which take a long time to code and maintain.

I realise that for some of this, "them's the breaks" and it's what a programmer is for. But if you have any techniques, modules or tricks that you use to make such programming easier, please share your insight so I can become better at this sort of thing. I'm particularly interested in genericising the code I write so I can reuse it, in CPAN-type modules, and web resources or books which might help.

TIA.


In reply to Perl/CGI Database Techniques by yojimbo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.