1Padre::DB::Plugin(3)  User Contributed Perl Documentation Padre::DB::Plugin(3)
2
3
4

NAME

6       Padre::DB::Plugin - Padre::DB class for the plugin table
7

DESCRIPTION

9       TO BE COMPLETED
10

METHODS

12   base
13         # Returns 'Padre::DB'
14         my $namespace = Padre::DB::Plugin->base;
15
16       Normally you will only need to work directly with a table class, and
17       only with one ORLite package.
18
19       However, if for some reason you need to work with multiple ORLite
20       packages at the same time without hardcoding the root namespace all the
21       time, you can determine the root namespace from an object or table
22       class with the "base" method.
23
24   table
25         # Returns 'plugin'
26         print Padre::DB::Plugin->table;
27
28       While you should not need the name of table for any simple operations,
29       from time to time you may need it programatically. If you do need it,
30       you can use the "table" method to get the table name.
31
32   load
33         my $object = Padre::DB::Plugin->load( $name );
34
35       If your table has single column primary key, a "load" method will be
36       generated in the class. If there is no primary key, the method is not
37       created.
38
39       The "load" method provides a shortcut mechanism for fetching a single
40       object based on the value of the primary key. However it should only be
41       used for cases where your code trusts the record to already exists.
42
43       It returns a "Padre::DB::Plugin" object, or throws an exception if the
44       object does not exist.
45
46   select
47         # Get all objects in list context
48         my @list = Padre::DB::Plugin->select;
49
50         # Get a subset of objects in scalar context
51         my $array_ref = Padre::DB::Plugin->select(
52             'where name > ? order by name',
53             1000,
54         );
55
56       The "select" method executes a typical SQL "SELECT" query on the plugin
57       table.
58
59       It takes an optional argument of a SQL phrase to be added after the
60       "FROM plugin" section of the query, followed by variables to be bound
61       to the placeholders in the SQL phrase. Any SQL that is compatible with
62       SQLite can be used in the parameter.
63
64       Returns a list of Padre::DB::Plugin objects when called in list
65       context, or a reference to an "ARRAY" of Padre::DB::Plugin objects when
66       called in scalar context.
67
68       Throws an exception on error, typically directly from the DBI layer.
69
70   iterate
71         Padre::DB::Plugin->iterate( sub {
72             print $_->name . "\n";
73         } );
74
75       The "iterate" method enables the processing of large tables one record
76       at a time without loading having to them all into memory in advance.
77
78       This plays well to the strength of SQLite, allowing it to do the work
79       of loading arbitrarily large stream of records from disk while
80       retaining the full power of Perl when processing the records.
81
82       The last argument to "iterate" must be a subroutine reference that will
83       be called for each element in the list, with the object provided in the
84       topic variable $_.
85
86       This makes the "iterate" code fragment above functionally equivalent to
87       the following, except with an O(1) memory cost instead of O(n).
88
89         foreach ( Padre::DB::Plugin->select ) {
90             print $_->name . "\n";
91         }
92
93       You can filter the list via SQL in the same way you can with "select".
94
95         Padre::DB::Plugin->iterate(
96             'order by ?', 'name',
97             sub {
98                 print $_->name . "\n";
99             }
100         );
101
102       You can also use it in raw form from the root namespace for better
103       control.  Using this form also allows for the use of arbitrarily
104       complex queries, including joins. Instead of being objects, rows are
105       provided as "ARRAY" references when used in this form.
106
107         Padre::DB->iterate(
108             'select name from plugin order by name',
109             sub {
110                 print $_->[0] . "\n";
111             }
112         );
113
114   count
115         # How many objects are in the table
116         my $rows = Padre::DB::Plugin->count;
117
118         # How many objects
119         my $small = Padre::DB::Plugin->count(
120             'where name > ?',
121             1000,
122         );
123
124       The "count" method executes a "SELECT COUNT(*)" query on the plugin
125       table.
126
127       It takes an optional argument of a SQL phrase to be added after the
128       "FROM plugin" section of the query, followed by variables to be bound
129       to the placeholders in the SQL phrase. Any SQL that is compatible with
130       SQLite can be used in the parameter.
131
132       Returns the number of objects that match the condition.
133
134       Throws an exception on error, typically directly from the DBI layer.
135
136   new
137         TO BE COMPLETED
138
139       The "new" constructor is used to create a new abstract object that is
140       not (yet) written to the database.
141
142       Returns a new Padre::DB::Plugin object.
143
144   create
145         my $object = Padre::DB::Plugin->create(
146
147             name => 'value',
148
149             version => 'value',
150
151             enabled => 'value',
152
153             config => 'value',
154
155         );
156
157       The "create" constructor is a one-step combination of "new" and
158       "insert" that takes the column parameters, creates a new
159       Padre::DB::Plugin object, inserts the appropriate row into the plugin
160       table, and then returns the object.
161
162       If the primary key column "name" is not provided to the constructor (or
163       it is false) the object returned will have "name" set to the new unique
164       identifier.
165
166       Returns a new plugin object, or throws an exception on error, typically
167       from the DBI layer.
168
169   insert
170         $object->insert;
171
172       The "insert" method commits a new object (created with the "new"
173       method) into the database.
174
175       If a the primary key column "name" is not provided to the constructor
176       (or it is false) the object returned will have "name" set to the new
177       unique identifier.
178
179       Returns the object itself as a convenience, or throws an exception on
180       error, typically from the DBI layer.
181
182   delete
183         # Delete a single instantiated object
184         $object->delete;
185
186         # Delete multiple rows from the plugin table
187         Padre::DB::Plugin->delete('where name > ?', 1000);
188
189       The "delete" method can be used in a class form and an instance form.
190
191       When used on an existing Padre::DB::Plugin instance, the "delete"
192       method removes that specific instance from the "plugin", leaving the
193       object intact for you to deal with post-delete actions as you wish.
194
195       When used as a class method, it takes a compulsory argument of a SQL
196       phrase to be added after the "DELETE FROM plugin" section of the query,
197       followed by variables to be bound to the placeholders in the SQL
198       phrase. Any SQL that is compatible with SQLite can be used in the
199       parameter.
200
201       Returns true on success or throws an exception on error, or if you
202       attempt to call delete without a SQL condition phrase.
203
204   truncate
205         # Delete all records in the plugin table
206         Padre::DB::Plugin->truncate;
207
208       To prevent the common and extremely dangerous error case where deletion
209       is called accidentally without providing a condition, the use of the
210       "delete" method without a specific condition is forbidden.
211
212       Instead, the distinct method "truncate" is provided to delete all
213       records in a table with specific intent.
214
215       Returns true, or throws an exception on error.
216

ACCESSORS

218   name
219         if ( $object->name ) {
220             print "Object has been inserted\n";
221         } else {
222             print "Object has not been inserted\n";
223         }
224
225       Returns true, or throws an exception on error.
226
227       REMAINING ACCESSORS TO BE COMPLETED
228

SQL

230       The plugin table was originally created with the following SQL command.
231
232         CREATE TABLE plugin (
233             name VARCHAR(255) PRIMARY KEY,
234             version VARCHAR(255),
235             enabled BOOLEAN,
236             config TEXT
237         )
238

SUPPORT

240       Padre::DB::Plugin is part of the Padre::DB API.
241
242       See the documentation for Padre::DB for more information.
243

AUTHOR

245       Adam Kennedy <adamk@cpan.org>
246
248       Copyright 2008-2011 The Padre development team as listed in Padre.pm.
249
250       This program is free software; you can redistribute it and/or modify it
251       under the same terms as Perl itself.
252
253       The full text of the license can be found in the LICENSE file included
254       with this module.
255
256
257
258perl v5.28.1                      2011-08-16              Padre::DB::Plugin(3)
Impressum