NAME
DbFramework::Persistent - Persistent Perl object base class
SYNOPSIS
package Foo;
use base qw(DbFramework::Persistent);
package main;
$foo = new Foo($table,$dbh);
$foo->attributes_h(\%foo};
$foo->insert;
$foo->attributes_h(\%new_foo);
$foo->update;
$foo->delete;
@foo = $foo->select($condition);
DESCRIPTION
Base class for persistent objects which use a Mysql database for storage. To create your own persistent object classes subclass DbFramework::Persistent e.g.
package Foo;
use base qw(DbFramework::Persistent);
package main;
... # make a dbh
$foo = new Foo($table,$dbh);
$foo->attributes_h(\%foo};
$fill = $foo->fill_template;
$foo->insert;
$foo->attributes_h(\%new_foo);
$foo->update;
$foo->delete;
@foo = $foo->select($condition);
$html = $foo->as_html_form;
SUPERCLASSES
DbFramework::Util
CLASS METHODS
new($table,$dbh)
Create a new persistent object. $table is a DbFramework::Table object or the name of a database table. $dbh is a DBI database handle which refers to a database containing a table associated with $table.
make_class($name)
Make a new persistent object class called $name.
OBJECT METHODS
Attributes in a persistent object which relate to columns in the associated table are made available through the attribute ATTRIBUTES_H. See "AUTOLOAD()" in DbFramework::Util for the accessor methods for these attributes.
delete()
Delete this object from the associated table based on the values of it's primary key attributes. Returns the number of rows deleted.
insert()
Insert this object in the associated table. Returns the primary key of the inserted row if it is a Mysql 'AUTO_INCREMENT' column.
update()
Update this object in the associated table. Returns the number of rows updated.
select($conditions)
Returns a list of objects of the same class as the object which invokes it. Each object in the list has its attributes initialised from the values returned by selecting all columns from the associated table matching $conditions.
fill_template($name)
Returns the template named $name in the table associated with this object filled with the object's attribute values. See "fill_template()" in DbFramework::Table.
as_html_form()
Returns an HTML form representing the object, filled with the object's attribute values.
SEE ALSO
DbFramework::Util and DbFramework::Table.
AUTHOR
Paul Sharpe <paul@miraclefish.com>
COPYRIGHT
Copyright (c) 1997,1998 Paul Sharpe. England. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.