25 Nov 2009 13:46:15 UTC
- Distribution: Coat-Persistent
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (6)
- Testers (147 / 26 / 0)
- KwaliteeBus factor: 2
- 43.06% Coverage
- License: unknown
- Activity24 month
- Download (30.02KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Coat::Persistent::Types::MySQL -- Attribute types and coercions for MySQL data types
The types defined in this module are here to provide simple and transparent storage of MySQL data types. This is done for atttributes you want to store with a different value than the one the object has.
For instance, if you have a datetime field, you may want to store it as a MySQL "datetime" format (YYYY-MM-DD HH:MM:SS) and handle it in your code as a timestamp, which is much more convinient for updates.
This is possible by using the types defined in this module.
We have a 'created_at' attribute, we want to handle it as a timestamp and store it as a MySQL datetime field.
use Coat::Persistent::Types::MySQL; has_p 'created_at' => ( is => 'rw', isa => 'Int', store_as => 'MySQL:DateTime, );
Then, whenever a value that validates the MySQL:DateTime format is assigned to that field, it will be coerced to an Int. On the other hand, whenever an entry has to be saved, the value used for storage will be the result of a coercion from Int to MySQL:DateTime.
The following types are provided by this module
Alexis Sukrieh <firstname.lastname@example.org>
Module Install Instructions
To install Coat::Persistent, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Coat::Persistent
For more information on module installation, please visit the detailed CPAN module installation guide.