1Padre::DB::SessionFile(U3s)er Contributed Perl DocumentatPiaodnre::DB::SessionFile(3)
2
3
4

NAME

6       Padre::DB::SessionFile - Padre::DB class for the session_file table
7

SYNOPSIS

9         my @files = Padre::DB::SessionFile->select(
10             'where session = ?', $session_id,
11         );
12

DESCRIPTION

14       This class allows storing in Padre's database the files referenced by a
15       given session (see "Padre::DB::Session").
16

METHODS

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

ACCESSORS

226   id
227         if ( $object->id ) {
228             print "Object has been inserted\n";
229         } else {
230             print "Object has not been inserted\n";
231         }
232
233       Returns true, or throws an exception on error.
234
235       REMAINING ACCESSORS TO BE COMPLETED
236

SQL

238       The session_file table was originally created with the following SQL
239       command.
240
241         CREATE TABLE session_file (
242             id INTEGER NOT NULL PRIMARY KEY,
243             file VARCHAR(255) NOT NULL,
244             position INTEGER NOT NULL,
245             focus BOOLEAN NOT NULL,
246             session INTEGER NOT NULL,
247             FOREIGN KEY (session) REFERENCES session(id)
248         )
249

SUPPORT

251       Padre::DB::SessionFile is part of the Padre::DB API.
252
253       See the documentation for Padre::DB for more information.
254

AUTHOR

256       Adam Kennedy <adamk@cpan.org>
257
259       Copyright 2008-2011 The Padre development team as listed in Padre.pm.
260
261       This program is free software; you can redistribute it and/or modify it
262       under the same terms as Perl itself.
263
264       The full text of the license can be found in the LICENSE file included
265       with this module.
266
267
268
269perl v5.32.0                      2020-07-28         Padre::DB::SessionFile(3)
Impressum