On Thu, Nov 15, 2001 at 01:49:31AM -0800, Bennett Haselton wrote:
>
> After converting the data in my project from text files to MySQL
> tables, things are certainly working more smoothly than they were
> before,
Good to hear.
> but since I use objects (in Perl, which barely supports objects, but
> that's another story)
What does that mean, exactly? I do a lot of OO in Perl.
> I have to write a lot of annoyingly repetitive code to create the
> object, run a query on the database to get the data that I need, set
> the object's member variables equal to the results returned from the
> query, and then do all those steps in reverse if the object's member
> values have changed later.
Well, it *is* Perl. If you find yourself doing something repetitive,
the little programmer in your head should wake up and think "how can I
write a program to do all this repetitive work so that I can sit on a
tropical beach?" :-)
> Are there any database systems that integrate so smoothly with an
> object-oriented programming language that I would be able to write
> code like:
>
> my $user = user.CreateFromTableRow("bennett");
> $user.sendReminderEmails();
> $user.emailaddress = '[EMAIL PROTECTED]';
>
> and the appropriate values would get read and written to the
> underlying database table. There's no reason why a language/IDE
> designed to integrate databases and objects would require more than
> three lines of code for that.
I was in a discussion about this a week or so ago with a co-worker.
We could decide if it ought to be Ruby, Python, or C++. But we had
some interesting ideas that would be fun to try and implement someday.
I don't know of one yet, but I've heard good things about Zope's
object database (ZODB?)
> An ideal database and language integration system could have the following
> features:
> (a) there is an automatic one-to-one correspondence between fields in a
> database table and member variables of the object
In Perl, you can used a tied hash to do that already.
> (b) any field that is a unique key
What's that mean?
> (c) modifications of the object member variable values get written through
> directly to the database
Tied hashes do that, too.
> (d) queries can be done in-place, in code, with a function that takes a
> reference to another function and returns all elements in the table for
> which that function returns true, i.e. this example in pseudocode would
> return an array of all objects corresponding to rows in the table
> "automobile" where the price is less than 10000:
> my @user_array = GetMatches('automobile_table',
> function myfunc($automobile)
> {
> if ($automobile.price < 10000)
> {
> return true;
> }
> }
> );
That doesn't look to hard to do, either. Have you looked at all the
database related modules on the CPAN?
Jeremy
--
Jeremy D. Zawodny, <[EMAIL PROTECTED]>
Technical Yahoo - Yahoo Finance
Desk: (408) 349-7878 Fax: (408) 349-5454 Cell: (408) 685-5936
MySQL 3.23.41-max: up 71 days, processed 1,555,776,471 queries (253/sec. avg)
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php