root/Class-DBI-Extension/trunk/README

Revision 117 (checked in by miyagawa, 19 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 NAME
2     Class::DBI::Extension - Some extension for Class::DBI
3
4 SYNOPSIS
5       package Film;
6       use base qw(Class::DBI::Extension);
7
8       # same as Class::DBI, but we have some useful methods.
9       package main;
10
11       @film   = Film->retrieve_all;
12       @better = Film->retrieve_from_sql('WHERE rating >= ?', 5);
13       $mine   = Film->get_count_from_sql('WHERE director = ?', $me);
14
15 DESCRIPTION
16     THIS RELEASE IS FOR TEMPORARY DEVELOPMENT. Hope this will eventually be
17     merged into Class::DBI and/or Class::DBI::mysql.
18
19     Patches, requests, suggestions are welcome in POOP Mailing List,
20     <poop-group@lists.sourceforge.net>
21
22 METHODS
23     $hashref = $record->attributes_hashref;
24         returns hash-reference of instance attributes.
25
26     %hash = $record->attributes_hash;
27         returns hash of instance attributes.
28
29     @record = Class->retrieve_from_sql($sql, @bind_args);
30         returns array of instances via SQL WHERE clause. Following example
31         returns Movies which have higher rating than 5.
32
33           @better_ones = Film->retrieve_from_sql(q{
34               WHERE rating >= ?
35           }, 5);
36
37     @all = Class->retrieve_all;
38         returns array of all instances in the class. Caveat for memory
39         consumption.
40
41     @record = Class->retrieve_range($offset, $limit);
42         returns array of instance by offset and limit. In this example,
43         No.10-30 are returned. This method might be useful for paging.
44
45         NOTE: Implemented SQL syntax would be specific for MySQL.
46
47         CAVEAT: Sort key is hard-coded with PRIMARY KEY of the table.
48
49     $howmany = Class->get_count_from_sql($sql, $bar);
50         returns the number of instances that matches SQL WHERE clause.
51
52           $num_of_goods = Film->get_count_from_sql(q{
53               WHERE rating >= ?
54           }, 5);
55
56     $num_of_records = Class->get_count;
57         returns the number of all instances of the class.
58
59     Class->lock_table(); Class->unlock_table();
60         Without transaction support (like MyISAM), we need to lock tables in
61         some cases.
62
63           Class->lock_table();
64           Class->unlock_table();
65
66         NOTE: Implemented SQL syntax is specific for MySQL.
67
68 AUTHOR
69     Tatsuhiko Miyagawa <miyagawa@bulknews.net>
70
71     This library is free software; you can redistribute it and/or modify it
72     under the same terms as Perl itself.
73
74 SEE ALSO
75     the Class::DBI manpage, the Class::DBI::mysql manpage
76
Note: See TracBrowser for help on using the browser.