My thinking is that this would work a lot like PGModel, but with Perl (and its much nicer handling of, well, everything) standing in for PHP. The main problem with Perl is handling lvalue subs so that, instead of $someobject->set_column_name($value)
and $someobject->column_name()
, we could have $someobject->column_name = $value
and $someobject->column_name
. I'm hoping what I've written here with scalar tying would work.*
From here, it's a function of porting over a lot of the changes from PLModel, so that our eventual code could look something like this:
### Account.pm, for a accounts table in the DB
package Account;
use warnings;
use strict;
use PLModel::Base;
@ISA = qw(PLModel::Base);
1;
### get_birthday_money.pl
use warnings;
use strict;
use Account;
my ($id) = 15; # my checking account ID!
my ($account) = Account->load($id);
$account->balance += 20; # birthday check from grandma;
$account->save();
1;
- Update: IT WORKS zOMG~