new()
initialize()
datastore()
attribute()
attributes()
add_attribute()
value()
clear()
update()
save()
restore()
restore_all()
restore_next()
data()
insert()
delete()
delete_where()
restore_where()
add_where()
where()
validate()
ePortal::ThePersistent::Base - Base class for storage objects
This package is used for handy work with database objects: SELECT, UPDATE, INSERT, DELETE.
new()
Object constructor. Parameters:
Returns new blessed and initialized object.
initialize()
Object initialization block, called from new()
constructor. initialize()
is used for attributes initialization. It is the place to override in
inherited modules to add its own attributes.
initialize()
calls datastore()
with all passed parameters.
Parameters are the same as for object constructor. Only Attributes parameter is used internally.
Returns none.
datastore()
It is the place to initialize database related things like DBH connection. Called from new() constructor.
Should not be called directly.
Parameters are the same as for object constructor. See Storage related variables for more details.
Returns newly created database handle.
attribute()
Returns named attribute parameters as hash. In scalar context returns hash ref.
If attribute does not exists then undef is returned. This method is used to check attribute existance.
attributes()
Returns names of ALL attributes of the object as array.
add_attribute()
Add an attribute to the object. Attribute information is used when SQL statement is constructed or when attribute datatype is needed to know.
Returns none.
value()
Get or set the value of attribute.
Returns new or current value of attribute.
clear()
Clears (undefs) the fields of the object. This method calls
value() directly. No overloaded value()
methods will be
triggered.
Returns none.
update()
Updates existing object in the datastore.
Returns True if UPDATE was successful.
save()
Saves the object to the data store (insert or update).
Returns:
1 if the object did previously exist in the datastore
0 if the object did not previously exist
undef on error
restore()
Restores the object from the data store.
Returns True if the object was successfully restored and False if the object is not found.
restore_all()
Restores all the objects from the data store and optionally sorted.
Returns none.
restore_next()
Restores the next object from the data store that matches the query expression in the previous restore_where or restore_all method calls.
Returns True if an object was restored and False if an object was not restored - no more objects to restore
data()
Gets/Sets all data fields of an object.
Returns $href - a reference to a hash of object data
insert()
Inserts new object into datastore. If ID attribute is auto_increment
then newly generated number for ID is stored in object via _id().
Returns True if INSERT was successful.
delete()
Delete the object.
Returns True if DELETE was successful.
delete_where()
Conditionaly deletes objects.
Note: Obligatory WHERE clause will be added
Returns True if DELETE was successful. May be return a number of deleted rows?
restore_where()
Execute conditional SELECT statement.
WHERE
clause for SQL statement. It may be arrayref, than every array
element will be ANDed.
ID attributes always included in SELECT.
Do not use both skip_attributes and only_attributes!
ID attributes always included in SELECT.
Do not use both skip_attributes and only_attributes!
count(*)
with supplied WHERE clause and return it.
ORDER BY
clause.
group_by
clause
WHERE
clause if an
attribute exists with this name. Undefined parameters are WHEREd to NULL
but empty values that eq to '' are omitted.
add_where()
Helper function. Adds another WHERE condition possible ANDed with existing one.
Returns none.
where()
Get/Set obligatory WHERE clause for the object.
Returns ņurrent where clause
validate()
Validates internal data before insert of update. This method does nothing and is subject to override in inherited modules.
Returns undef on success or human readable error message if the object is not valid.
_check_dbi_error()
Checks for errors in DBI and croaks if an error has occurred.
dbh()
Returns the handle of the database.
_id()
Gets/Sets the ID of the object. ID may be an array.
check_id()
Checks that the ID of the object is valid. That is every ID attribute is defined.
If ready to use DBH is passed to constructor then {CreatedDBH} is False.
commit()
is needed after every update statement.
restore_where()
restore_where()
count(*)
field and consctucted WHERE clause is added. This feature is used in
restore_where()
A lot of attribute parameters are used for description, detalization and visualization.
Transient(Temporary)
]
This is field persistent state. Only first 1 character is significant. Default is Persistent.
Type of dialog item used for this field. Default is textfield.
Coderef used to fill up popup_menu parameters.