Class::PObject::Driver::mysql - MySQL Pobject Driver
use Class::PObject; pobject Person => { columns => ['id', 'name', 'email'], driver => 'mysql', datasource => { DSN => 'dbi:mysql:db_name', User => 'sherzodr', Password => 'marley01' } };
Class::PObject::Driver::mysql 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 attribute should be in the form of a hashref. The following keys are supported
DSN - provides a DSN string suitable for the first argument of DBI->connect(...). Usually it should be dbi:mysql:$database_name.
DSN
User - username to connect to the database.
User
Password - password required by the User to connect to the database. If the user doesn't require any passwords, you can set it to undef.
Password
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 (_).
Table
_
Handle attribute is useful if you already have $dbh handy. If $dbh is used, DSN, User and Password attributes will be obsolete nor make sense.
Handle
$dbh
Class::PObject::Driver::mysql (re-)defines following methods of its own
dbh() base DBI method is overridden with the version that creates a DBI handle using DSN datasource attribute.
dbh()
save() - stores/updates the object
save()
_prepare_insert() redefines base method of the same name with the version that generates a REPLACE SQL statement instead of default INSERT SQL statement. This allows the driver to either leave "insert or update?" problem to MySQL.
_prepare_insert()
This implies that table's id column should be of AUTO_INCREMENT type. This will ensure that MySQL will take care of creating auto-incrementing unique object ids for you.
Class::PObject, Class::PObject::Driver::csv, Class::PObject::Driver::file
Sherzod Ruzmetov <sherzodr@cpan.org>
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.
To install Class::PObject, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::PObject
CPAN shell
perl -MCPAN -e shell install Class::PObject
For more information on module installation, please visit the detailed CPAN module installation guide.