[Solar-talk] The new model class discussion, some questions
Antti Holvikari
anttih at gmail.com
Wed Feb 21 01:52:58 PST 2007
On 2/20/07, Paul M Jones <pmjones at ciaweb.net> wrote:
> On Feb 20, 2007, at 3:55 AM, Rodrigo Moraes wrote:
>
> >> Again, I am willing to revisit my design decisions so far and
> >> converting to a record-based (not table based) model system based on
> >> examples and discussion. Solar_Sql_Model is not set in stone just
> >> yet. :-)
> >
> > Thanks, Paul. You're very kind to hear us, even when it makes no
> > sense. It's not the case, of course (I'm kidding, maybe it is). :)
>
> Rodrigo, Andreas ... I haaate it when you're right.
>
> I have been looking at how I *actually use* the Model class, and most
> of the time it's as an interface to a single record, or a collection
> of records, not as a table interface. The only time it's table-like
> is when I'm going a fetch or count.
>
> So I am going to attempt a new underlying design that takes into
> account the context-switching that Antti and I dislike so much and
> see if I can come up with something that has the best of both worlds.
Ok, so I had to brainstorm a little on how it could work. What if you
still kept one record and a table object separate but made it so that
a record is in the central. I'm thinking something along the lines of
(a bag with items):
$record = Solar::factory('Vendor_Model_Bag');
// get the underlying table object
$table = $record->getTable()->fetchAll(...);
// perform actions on "items"
$items = $table->fetchAll(....);
// this is normal Solar_Sql_Table stuff
$table->update(...);
$table->insert(...);
// now the record stuff with business logic underneath
$record->property = 'value';
$record->save();
You would setup the table schema in the record object which would
actually get an instance of our beloved Solar_Sql_Table and use it to
perform the "table" operations. You could also put the business logic
in the record, which would make sense since the table class wouldn't
know anything about the relations.
Anyhow, my $0.02. Hope I didn't miss anything obvious :-)
--
Antti Holvikari <http://phphalo.com>
More information about the solar-talk
mailing list