1Padre::DB::Snippets(3)User Contributed Perl DocumentationPadre::DB::Snippets(3)
2
3
4

NAME

6       Padre::DB::Snippets - Padre::DB class for the snippets table
7

SYNOPSIS

9       TO BE COMPLETED
10

DESCRIPTION

12       TO BE COMPLETED
13

METHODS

15   select
16         # Get all objects in list context
17         my @list = Padre::DB::Snippets->select;
18
19         # Get a subset of objects in scalar context
20         my $array_ref = Padre::DB::Snippets->select(
21             'where id > ? order by id',
22             1000,
23         );
24
25       The "select" method executes a typical SQL "SELECT" query on the
26       snippets table.
27
28       It takes an optional argument of a SQL phrase to be added after the
29       "FROM snippets" section of the query, followed by variables to be bound
30       to the placeholders in the SQL phrase. Any SQL that is compatible with
31       SQLite can be used in the parameter.
32
33       Returns a list of Padre::DB::Snippets objects when called in list
34       context, or a reference to an ARRAY of Padre::DB::Snippets objects when
35       called in scalar context.
36
37       Throws an exception on error, typically directly from the DBI layer.
38
39   count
40         # How many objects are in the table
41         my $rows = Padre::DB::Snippets->count;
42
43         # How many objects
44         my $small = Padre::DB::Snippets->count(
45             'where id > ?',
46             1000,
47         );
48
49       The "count" method executes a "SELECT COUNT(*)" query on the snippets
50       table.
51
52       It takes an optional argument of a SQL phrase to be added after the
53       "FROM snippets" section of the query, followed by variables to be bound
54       to the placeholders in the SQL phrase. Any SQL that is compatible with
55       SQLite can be used in the parameter.
56
57       Returns the number of objects that match the condition.
58
59       Throws an exception on error, typically directly from the DBI layer.
60
61   new
62       TO BE COMPLETED
63
64       The "new" constructor is used to create a new abstract object that is
65       not (yet) written to the database.
66
67       Returns a new Padre::DB::Snippets object.
68
69   create
70         my $object = Padre::DB::Snippets->create(
71
72             id => 'value',
73
74             mimetype => 'value',
75
76             category => 'value',
77
78             name => 'value',
79
80             snippet => 'value',
81
82         );
83
84       The "create" constructor is a one-step combination of "new" and
85       "insert" that takes the column parameters, creates a new
86       Padre::DB::Snippets object, inserts the appropriate row into the
87       snippets table, and then returns the object.
88
89       If the primary key column "id" is not provided to the constructor (or
90       it is false) the object returned will have "id" set to the new unique
91       identifier.
92
93       Returns a new snippets object, or throws an exception on error,
94       typically from the DBI layer.
95
96   insert
97         $object->insert;
98
99       The "insert" method commits a new object (created with the "new"
100       method) into the database.
101
102       If a the primary key column "id" is not provided to the constructor (or
103       it is false) the object returned will have "id" set to the new unique
104       identifier.
105
106       Returns the object itself as a convenience, or throws an exception on
107       error, typically from the DBI layer.
108
109   delete
110         # Delete a single instantiated object
111         $object->delete;
112
113         # Delete multiple rows from the snippets table
114         Padre::DB::Snippets->delete('where id > ?', 1000);
115
116       The "delete" method can be used in a class form and an instance form.
117
118       When used on an existing Padre::DB::Snippets instance, the "delete"
119       method removes that specific instance from the "snippets", leaving the
120       object ntact for you to deal with post-delete actions as you wish.
121
122       When used as a class method, it takes a compulsory argument of a SQL
123       phrase to be added after the "DELETE FROM snippets" section of the
124       query, followed by variables to be bound to the placeholders in the SQL
125       phrase. Any SQL that is compatible with SQLite can be used in the
126       parameter.
127
128       Returns true on success or throws an exception on error, or if you
129       attempt to call delete without a SQL condition phrase.
130
131   truncate
132         # Delete all records in the snippets table
133         Padre::DB::Snippets->truncate;
134
135       To prevent the common and extremely dangerous error case where deletion
136       is called accidentally without providing a condition, the use of the
137       "delete" method without a specific condition is forbidden.
138
139       Instead, the distinct method "truncate" is provided to delete all
140       records in a table with specific intent.
141
142       Returns true, or throws an exception on error.
143

ACCESSORS

145   id
146         if ( $object->id ) {
147             print "Object has been inserted\n";
148         } else {
149             print "Object has not been inserted\n";
150         }
151
152       Returns true, or throws an exception on error.
153
154       REMAINING ACCESSORS TO BE COMPLETED
155

SQL

157       The snippets table was originally created with the following SQL
158       command.
159
160         CREATE TABLE snippets (
161               id INTEGER PRIMARY KEY,
162               mimetype VARCHAR(255),
163               category VARCHAR(255),
164               name VARCHAR(255),
165               snippet TEXT
166         )
167

SUPPORT

169       Padre::DB::Snippets is part of the Padre::DB API.
170
171       See the documentation for Padre::DB for more information.
172

AUTHOR

174       Adam Kennedy
175
177       Copyright 2008-2010 The Padre development team as listed in Padre.pm.
178
179       This program is free software; you can redistribute it and/or modify it
180       under the same terms as Perl itself.
181
182       The full text of the license can be found in the LICENSE file included
183       with this module.
184
185
186
187perl v5.12.1                      2010-01-02            Padre::DB::Snippets(3)
Impressum