Class::DBI::Extension - Some extension for Class::DBI
package Film; use base qw(Class::DBI::Extension); # same as Class::DBI, but we have some useful methods. package main; @film = Film->retrieve_all; @better = Film->retrieve_from_sql('WHERE rating >= ?', 5); $mine = Film->get_count_from_sql('WHERE director = ?', $me);
THIS RELEASE IS FOR TEMPORARY DEVELOPMENT. Hope this will eventually be merged into Class::DBI and/or Class::DBI::mysql.
Patches, requests, suggestions are welcome in POOP Mailing List, <poop-group@lists.sourceforge.net>
returns hash-reference of instance attributes.
returns hash of instance attributes.
returns array of instances via SQL WHERE clause. Following example returns Movies which have higher rating than 5.
@better_ones = Film->retrieve_from_sql(q{ WHERE rating >= ? }, 5);
returns array of all instances in the class. Caveat for memory consumption.
returns array of instance by offset and limit. In this example, No.10-30 are returned. This method might be useful for paging.
NOTE: Implemented SQL syntax would be specific for MySQL.
CAVEAT: Sort key is hard-coded with PRIMARY KEY of the table.
returns the number of instances that matches SQL WHERE clause.
$num_of_goods = Film->get_count_from_sql(q{ WHERE rating >= ? }, 5);
returns the number of all instances of the class.
Without transaction support (like MyISAM), we need to lock tables in some cases.
Class->lock_table(); Class->unlock_table();
NOTE: Implemented SQL syntax is specific for MySQL.
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Class::DBI, Class::DBI::mysql
To install Class::DBI::Extension, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::DBI::Extension
CPAN shell
perl -MCPAN -e shell install Class::DBI::Extension
For more information on module installation, please visit the detailed CPAN module installation guide.