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