The char/item/bag/skill/reputation classes in 1x are what I mean with data holder classes. They bundle the data with functions that use it. However, these classes should then also implement a generic interface that ties into the DB engine so it can load the data with only a couple of php statements, preferably with as few statements as possible.
- Code: Select all
$guild = new roster_data_guild($guild_name, $realm);
$guild->select();
$guild->members->select('%bank');
$guild->members->bags->select();
$guild->members->bank->select();
$guild->loadRecursive();
$items = new roster_data_items();
foreach( $guild->members as $member_id => $member )
{
foreach( $member->bags as $item )
{
$items->add($item);
}
foreach( $member->bank as $item )
{
$items->add($item);
}
}
Etcetera. Here roster_data_guild, roster_data_member, roster_data_item are objects containing (usually) a single item from a single table. roster_data_members, roster_data_items (bad name, needs improvement) would be a descendant implementing (at least) ArrayAccess, and would contain a list of single-row objects. The array itself would act a s a template for containing rows, so if the template is set to load bag and bank contents, then rows added later are also set to load those.