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