NAME
Class::PObject::Driver::csv - CSV Pobject Driver
SYNOPSIS
use Class::PObject;
pobject Person => {
columns => ['id', 'name', 'email'],
driver => 'csv',
datasource => {
Dir => 'data/',
Table => 'person'
}
};
DESCRIPTION
Class::PObject::Driver::csv is a direct subclass of Class::PObjecet::Driver::DBI. It inherits all the base functionality needed for all the DBI-related classes. For details of these methods and their specifications refer to Class::PObject::Driver and Class::PObject::Driver::DBI.
DATASOURCE
datasource attribute should be in the form of a hashref. The following keys are supported
Dir
- points to the directory where the CSV files are stored. If this is missing will default to your system's temporary folder.Table
- defines the name of the table that objects will be stored in. If this is missing will default to the name of the object, non-alphanumeric characters replaced with underscore (_
).
METHODS
Class::PObject::Driver::csv (re-)defines following methods of its own
dbh()
base DBI method is overridden with the version that creates a DBI handle through DBD::CSV.save()
either builds a SELECT SQL statement by calling base_prepare_select()
if the object id is missing, or builds an UPDATE SQL statement by calling base_prepare_update()
.If the ID is missing, calls
generate_id()
method, which returns a unique ID for the object.generate_id($self, $pobject_name, \%properties)
returns a unique ID for new objects. This determines the new ID by performing a SELECT id FROM $table ORDER BY id DESC LIMIT 1 SQL statement to determine the latest inserted ID._tablename($self, $pobject_name, \%properties)
Redefines base method
_tablename()
. If the table is missing, it will also create the table for you.
SEE ALSO
Class::PObject, Class::PObject::Driver::mysql, Class::PObject::Driver::file
AUTHOR
Sherzod Ruzmetov <sherzodr@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2003 by Sherzod B. Ruzmetov.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.