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

Re: [cgiapp] Re: CGI::App::DBH or Ima::DBI



---------- Original Message -----------
From: Michael Graham <suppressed>
To: <suppressed>
Sent: Fri, 23 Jan 2004 01:45:12 -0500
Subject: Re: [cgiapp] Re: CGI::App::DBH or Ima::DBI

> William McKee wrote:
> > Let me see if I can line item the specific benefits I get:
> >     - all database interface is in a single location
> >     - simple apps need no custom SQL
> >     - custom SQL resides in a single location
> >     - database abstraction done simply
> >     - automatic mutator/accessor methods for each field
> >     - easy to add temporary fields via a custom method (e.g., suppose I
> >       need a field that is the sum of two other fields; instead of doing
> >       this at the SQL level, I can do it with Perl in my CDBI object;
> >       the benefits of this approach are portability due to less complex
> >       SQL statements)
> >     - and all the other benefits of CDBI ;->;
> >
> 
> As a newbie to Class::Application, I'd be interested in learning what
> templating language you use with Class::DBI.  I'm still trying to decide
> on the best approach.  Because CDBI uses accessors for all data, it
> seems to me that HTML::Template would be a lot of extra work.  I imagine
> there would be much code like this:
> 
>     $template->param(
>         EMPLOYEE_NAME  => $employee->name,
>         EMPLOYEE_EMAIL => $employee->email,
>         EMPLOYEE_PHONE => $employee->phone,
>     );

It was just this sort of repetitive code that led us to create the
CheesePizza::DBI, CheesePizza::TemplateLoader. The TemplateLoader uses
HTML::Template. It looks at the tags in the template and as long as they are
formatted correctly it create the database queries for those TMPL_VARs and
TMPL_LOOPs and then loads those vars into the template.

So instead of doing the following in T::T

>         [% employee.name  %]
>         [% employee.email %]
>         [% employee.phone %]
> 

You would have something similar to this
    <tmpl_var Employee_Name>
    <tmpl_var Employee_Email>
    <tmpl_var Employee_Phone>

And all you would have to do is tell the TemplateLoader what is the 'id'
(primary key) of the Employee row in the db.

If you're still interested you can check out this link...
http://cheesepizza.venzia.com/docs/modules/Venzia/TemplateLoader-pm.html

But, I am working on getting a new release of all the CheesePizza stuff
(hopefully by the first of next week), so the API might change slightly and
the documentation will be much better.

Michael Peters
Venzia

---------------------------------------------------------------------
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.