Class::PObject is a simple framework for programming persistent objects.
SYNOPSIS
After loading Class::PObject with use, we can declare a class:
pobject Person => {
columns => ['id', 'name', 'email'],
datasource => './data'
};
We can also declare the class in its own .pm file:
package Person;
use Class::PObject;
pobject {
columns => ['id', 'name', 'email'],
datasource => './data'
};
We can now create an instance of above Person, fill it with data, and save it:
$person = new Person();
$person->name('Sherzod');
$person->email('sherzodr[AT]cpan.org');
$new_id = $person->save()
We can access the saved Person later, make necessary changes and save back:
$person = Person->load($new_id);
$person->name('Sherzod Ruzmetov (The Geek)');
$person->save()
We can load multiple objects as well:
@people = Person->load();
for $person ( @people ) {
printf("[d] %s < %s >n", $person->id, $person->name, $person->email)
}
or we can load all the objects based on some criteria and sort the list by column name in descending order, and limit the results to only the first 3 objects:
@people = Person->load(
{name => "Sherzod"},
{sort => "name", direction => "desc", limit=>3});
We can also seek into a specific point of the result set:
@people = Person->load(undef, {offset=>10, limit=>10});
Product's homepage
Requirements:
· Perl