perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Winters <ch...@cwinters.com>
Subject Re: Object Oriented Databases with MySQL
Date Sun, 17 Jun 2001 21:31:27 GMT
* Philip Mak (pmak@aaanime.net) [010613 18:21]:
> Hello all,
> 
> I've been experimenting with a programming technique idea I had that I
> call "Object Oriented Databases". The goal of the technique is to make
> programming database driven websites easier by allowing the website code
> (I use Apache::ASP, which is built on mod_perl) to access the database
> contents as objects rather than having to write SQL statements. (The SQL
> statements are in the .pm files that define the objects' methods.)

Hi Philip,

You might also be interested in SPOPS (Simple Perl Object Persistence
with Security). Nothing illustrates the point like code, so here's
some sample code. The file 'object_info.perl' contains configuration
information for the objects 'author' and 'fanfics'.

 use strict;
 use SPOPS::Initialize;

 SPOPS::Initialize->process({ filename => 'object_info.perl' });

 my $author_list = Fanfics->fetch_group({ order => 'name' });
 foreach my $author ( @{ $author_list }) {
   my $fanfics_list = $author->fanfics;
   foreach my $fanfic ( @{ $fanfic_list } ) {
    print <<<LINK;
<a href="$fanfic->{handle}.html">$fanfic->{title}</a> by
         <a href="mailto:$author->{email}">
         $author->{name}</a><br>
LINK
   }
 }

You could just as easily reverse the list and fill $fanfics_list
first, then for each fanfics find its author.

One of the best points is that you don't even need to modify your
database schema -- just create configuration information for the
object, run SPOPS::Initialize on it and the necessary classes are
created for you behind the scenes.

SPOPS also makes this trivial to move this data from one datastore
(MySQL) to another (PostgreSQL, or any other supported database) just
by modifying a line in the configuration.

The next version of SPOPS (0.41) will also support iterators which
will make the above code much more efficient memory-wise. (I just
finished writing the code while at YAPC North America -- a very
fertile environment!)

If you're interested, SPOPS is on CPAN, and you can join the
openinteract-help or -dev mailing lists (which provide support and
discussion for SPOPS) at:

  http://sourceforge.net/mail/?group_id=16810

Hope this helps!

Chris

-- 
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988.

--ajiepgnhgdnmjpbfdbhb--
ReSent-Date: Fri, 29 Jun 2001 14:51:04 -0700 (PDT)
ReSent-From: Ask Bjoern Hansen <ask@valueclick.com>
ReSent-To:  <asp@perl.apache.org>
ReSent-Subject: Re: Object Oriented Databases with MySQL
ReSent-Message-ID: <Pine.LNX.4.33.0106291451040.18561@impatience.valueclick.com>

* Philip Mak (pmak@aaanime.net) [010613 18:21]:
> Hello all,
> 
> I've been experimenting with a programming technique idea I had that I
> call "Object Oriented Databases". The goal of the technique is to make
> programming database driven websites easier by allowing the website code
> (I use Apache::ASP, which is built on mod_perl) to access the database
> contents as objects rather than having to write SQL statements. (The SQL
> statements are in the .pm files that define the objects' methods.)

Hi Philip,

You might also be interested in SPOPS (Simple Perl Object Persistence
with Security). Nothing illustrates the point like code, so here's
some sample code. The file 'object_info.perl' contains configuration
information for the objects 'author' and 'fanfics'.

 use strict;
 use SPOPS::Initialize;

 SPOPS::Initialize->process({ filename => 'object_info.perl' });

 my $author_list = Fanfics->fetch_group({ order => 'name' });
 foreach my $author ( @{ $author_list }) {
   my $fanfics_list = $author->fanfics;
   foreach my $fanfic ( @{ $fanfic_list } ) {
    print <<<LINK;
<a href="$fanfic->{handle}.html">$fanfic->{title}</a> by
         <a href="mailto:$author->{email}">
         $author->{name}</a><br>
LINK
   }
 }

You could just as easily reverse the list and fill $fanfics_list
first, then for each fanfics find its author.

One of the best points is that you don't even need to modify your
database schema -- just create configuration information for the
object, run SPOPS::Initialize on it and the necessary classes are
created for you behind the scenes.

SPOPS also makes this trivial to move this data from one datastore
(MySQL) to another (PostgreSQL, or any other supported database) just
by modifying a line in the configuration.

The next version of SPOPS (0.41) will also support iterators which
will make the above code much more efficient memory-wise. (I just
finished writing the code while at YAPC North America -- a very
fertile environment!)

If you're interested, SPOPS is on CPAN, and you can join the
openinteract-help or -dev mailing lists (which provide support and
discussion for SPOPS) at:

  http://sourceforge.net/mail/?group_id=16810

Hope this helps!

Chris

-- 
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988.

--ajiepgnhgdnmjpbfdbhb--


---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org


Mime
View raw message