~ubuntu-branches/ubuntu/oneiric/bugzilla/oneiric

« back to all changes in this revision

Viewing changes to docs/html/api/Bugzilla/DB.html

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Bossek
  • Date: 2008-06-27 22:34:34 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080627223434-0ib57vstn43bb4a3
Tags: 3.0.4.1-1
* Update of French, Russian and German translations. (closes: #488251)
* Added Bulgarian and Belarusian translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
 
<html>
3
 
  <head>
4
 
    <title>
5
 
Bugzilla::DB</title>
6
 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7
 
  <link rel="stylesheet" title="style" type="text/css" href="../style.css" media="all" >
8
 
 
9
 
</head>
10
 
  <body id="pod">
11
 
<p class="backlinktop"><b><a name="___top" href="../index.html" accesskey="1" title="All Documents">&lt;&lt;</a></b></p>
12
 
<h1>Bugzilla::DB</h1>
13
 
<div class='indexgroup'>
14
 
<ul   class='indexList indexList1'>
15
 
  <li class='indexItem indexItem1'><a href='#NAME'>NAME</a>
16
 
  <li class='indexItem indexItem1'><a href='#SYNOPSIS'>SYNOPSIS</a>
17
 
  <li class='indexItem indexItem1'><a href='#DESCRIPTION'>DESCRIPTION</a>
18
 
  <li class='indexItem indexItem1'><a href='#CONSTANTS'>CONSTANTS</a>
19
 
  <li class='indexItem indexItem1'><a href='#CONNECTION'>CONNECTION</a>
20
 
  <ul   class='indexList indexList2'>
21
 
    <li class='indexItem indexItem2'><a href='#Functions'>Functions</a>
22
 
  </ul>
23
 
  <li class='indexItem indexItem1'><a href='#ABSTRACT_METHODS'>ABSTRACT METHODS</a>
24
 
  <ul   class='indexList indexList2'>
25
 
    <li class='indexItem indexItem2'><a href='#Constructor'>Constructor</a>
26
 
    <li class='indexItem indexItem2'><a href='#SQL_Generation'>SQL Generation</a>
27
 
  </ul>
28
 
  <li class='indexItem indexItem1'><a href='#IMPLEMENTED_METHODS'>IMPLEMENTED METHODS</a>
29
 
  <ul   class='indexList indexList2'>
30
 
    <li class='indexItem indexItem2'><a href='#General_Information_Methods'>General Information Methods</a>
31
 
    <li class='indexItem indexItem2'><a href='#Database_Setup_Methods'>Database Setup Methods</a>
32
 
    <li class='indexItem indexItem2'><a href='#Schema_Modification_Methods'>Schema Modification Methods</a>
33
 
    <li class='indexItem indexItem2'><a href='#Schema_Information_Methods'>Schema Information Methods</a>
34
 
    <li class='indexItem indexItem2'><a href='#Transaction_Methods'>Transaction Methods</a>
35
 
  </ul>
36
 
  <li class='indexItem indexItem1'><a href='#SUBCLASS_HELPERS'>SUBCLASS HELPERS</a>
37
 
  <li class='indexItem indexItem1'><a href='#SEE_ALSO'>SEE ALSO</a>
38
 
</ul>
39
 
</div>
40
 
 
41
 
<h1><a class='u' href='#___top' title='click to go to top of document'
42
 
name="NAME"
43
 
>NAME</a></h1>
44
 
 
45
 
<p>Bugzilla::DB - Database access routines,
46
 
using <a href="../DBI.html" class="podlinkpod"
47
 
>DBI</a></p>
48
 
 
49
 
<h1><a class='u' href='#___top' title='click to go to top of document'
50
 
name="SYNOPSIS"
51
 
>SYNOPSIS</a></h1>
52
 
 
53
 
<pre  class="code">  # Obtain db handle
54
 
  use Bugzilla::DB;
55
 
  my $dbh = Bugzilla-&#62;dbh;
56
 
 
57
 
  # prepare a query using DB methods
58
 
  my $sth = $dbh-&#62;prepare(&#34;SELECT &#34; .
59
 
                          $dbh-&#62;sql_date_format(&#34;creation_ts&#34;, &#34;%Y%m%d&#34;) .
60
 
                          &#34; FROM bugs WHERE bug_status != &#39;RESOLVED&#39; &#34; .
61
 
                          $dbh-&#62;sql_limit(1));
62
 
 
63
 
  # Execute the query
64
 
  $sth-&#62;execute;
65
 
 
66
 
  # Get the results
67
 
  my @result = $sth-&#62;fetchrow_array;
68
 
 
69
 
  # Schema Modification
70
 
  $dbh-&#62;bz_add_column($table, $name, \%definition, $init_value);
71
 
  $dbh-&#62;bz_add_index($table, $name, $definition);
72
 
  $dbh-&#62;bz_add_table($name);
73
 
  $dbh-&#62;bz_drop_index($table, $name);
74
 
  $dbh-&#62;bz_drop_table($name);
75
 
  $dbh-&#62;bz_alter_column($table, $name, \%new_def, $set_nulls_to);
76
 
  $dbh-&#62;bz_drop_column($table, $column);
77
 
  $dbh-&#62;bz_rename_column($table, $old_name, $new_name);
78
 
 
79
 
  # Schema Information
80
 
  my $column = $dbh-&#62;bz_column_info($table, $column);
81
 
  my $index  = $dbh-&#62;bz_index_info($table, $index);
82
 
 
83
 
  # General Information
84
 
  my @fields    = $dbh-&#62;bz_get_field_defs();</pre>
85
 
 
86
 
<h1><a class='u' href='#___top' title='click to go to top of document'
87
 
name="DESCRIPTION"
88
 
>DESCRIPTION</a></h1>
89
 
 
90
 
<p>Functions in this module allows creation of a database handle to connect to the Bugzilla database. This should never be done directly; all users should use the <a href="../Bugzilla.html" class="podlinkpod"
91
 
>Bugzilla</a> module to access the current <code  class="code">dbh</code> instead.</p>
92
 
 
93
 
<p>This module also contains methods extending the returned handle with functionality which is different between databases allowing for easy customization for particular database via inheritance. These methods should be always preffered over hard-coding SQL commands.</p>
94
 
 
95
 
<h1><a class='u' href='#___top' title='click to go to top of document'
96
 
name="CONSTANTS"
97
 
>CONSTANTS</a></h1>
98
 
 
99
 
<p>Subclasses of Bugzilla::DB are required to define certain constants. These constants are required to be subroutines or &#34;use constant&#34; variables.</p>
100
 
 
101
 
<dl>
102
 
<dt><a name="BLOB_TYPE"
103
 
><code  class="code">BLOB_TYPE</code></a></dt>
104
 
 
105
 
<dd>
106
 
<p>The <code  class="code">\%attr</code> argument that must be passed to bind_param in order to correctly escape a <code  class="code">LONGBLOB</code> type.</p>
107
 
</dd>
108
 
</dl>
109
 
 
110
 
<h1><a class='u' href='#___top' title='click to go to top of document'
111
 
name="CONNECTION"
112
 
>CONNECTION</a></h1>
113
 
 
114
 
<p>A new database handle to the required database can be created using this module. This is normally done by the <a href="../Bugzilla.html" class="podlinkpod"
115
 
>Bugzilla</a> module, and so these routines should not be called from anywhere else.</p>
116
 
 
117
 
<h2><a class='u' href='#___top' title='click to go to top of document'
118
 
name="Functions"
119
 
>Functions</a></h2>
120
 
 
121
 
<dl>
122
 
<dt><a name="connect_main"
123
 
><code  class="code">connect_main</code></a></dt>
124
 
 
125
 
<dd>
126
 
<dl>
127
 
<dt><a name="Description"
128
 
><b>Description</b></a></dt>
129
 
 
130
 
<dd>
131
 
<p>Function to connect to the main database, returning a new database handle.</p>
132
 
 
133
 
<dt><a name="Params"
134
 
><b>Params</b></a></dt>
135
 
 
136
 
<dd>
137
 
<dl>
138
 
<dt><a 
139
 
><code  class="code">$no_db_name</code> (optional) - If true, connect to the database server, but don&#39;t connect to a specific database. This is only used when creating a database. After you create the database, you should re-create a new Bugzilla::DB object without using this parameter.</a></dt>
140
 
</dl>
141
 
 
142
 
<dt><a name="Returns"
143
 
><b>Returns</b></a></dt>
144
 
 
145
 
<dd>
146
 
<p>New instance of the DB class</p>
147
 
</dd>
148
 
</dl>
149
 
 
150
 
<dt><a name="connect_shadow"
151
 
><code  class="code">connect_shadow</code></a></dt>
152
 
 
153
 
<dd>
154
 
<dl>
155
 
<dt><a name="Description"
156
 
><b>Description</b></a></dt>
157
 
 
158
 
<dd>
159
 
<p>Function to connect to the shadow database, returning a new database handle. This routine <code  class="code">die</code>s if no shadow database is configured.</p>
160
 
 
161
 
<dt><a name="Params_(none)"
162
 
><b>Params</b> (none)
163
 
<dt><a name="Returns"
164
 
><b>Returns</b></a></dt>
165
 
 
166
 
<dd>
167
 
<p>A new instance of the DB class</p>
168
 
</dd>
169
 
</dl>
170
 
 
171
 
<dt><a name="bz_check_requirements"
172
 
><code  class="code">bz_check_requirements</code></a></dt>
173
 
 
174
 
<dd>
175
 
<dl>
176
 
<dt><a name="Description"
177
 
><b>Description</b></a></dt>
178
 
 
179
 
<dd>
180
 
<p>Checks to make sure that you have the correct DBD and database version installed for the database that Bugzilla will be using. Prints a message and exits if you don&#39;t pass the requirements.</p>
181
 
 
182
 
<p>If <code  class="code">$db_check</code> is false (from <em  class="code">localconfig</em>), we won&#39;t check the database version.</p>
183
 
 
184
 
<dt><a name="Params"
185
 
><b>Params</b></a></dt>
186
 
 
187
 
<dd>
188
 
<dl>
189
 
<dt><a name="$output_-_true_if_the_function_should_display_informational_output_about_what_it&#39;s_doing,_such_as_versions_found."
190
 
><code  class="code">$output</code> - <code  class="code">true</code> if the function should display informational output about what it&#39;s doing, such as versions found.</a></dt>
191
 
</dl>
192
 
 
193
 
<dt><a name="Returns_(nothing)"
194
 
><b>Returns</b> (nothing)</a></dt>
195
 
</dl>
196
 
 
197
 
<dt><a name="bz_create_database"
198
 
><code  class="code">bz_create_database</code></a></dt>
199
 
 
200
 
<dd>
201
 
<dl>
202
 
<dt><a name="Description"
203
 
><b>Description</b></a></dt>
204
 
 
205
 
<dd>
206
 
<p>Creates an empty database with the name <code  class="code">$db_name</code>, if that database doesn&#39;t already exist. Prints an error message and exits if we can&#39;t create the database.</p>
207
 
 
208
 
<dt><a name="Params_(none)"
209
 
><b>Params</b> (none)
210
 
<dt><a name="Returns_(nothing)"
211
 
><b>Returns</b> (nothing)</a></dt>
212
 
</dl>
213
 
 
214
 
<dt><a name="_connect"
215
 
><code  class="code">_connect</code></a></dt>
216
 
 
217
 
<dd>
218
 
<dl>
219
 
<dt><a name="Description"
220
 
><b>Description</b></a></dt>
221
 
 
222
 
<dd>
223
 
<p>Internal function, creates and returns a new, connected instance of the correct DB class. This routine <code  class="code">die</code>s if no driver is specified.</p>
224
 
 
225
 
<dt><a name="Params"
226
 
><b>Params</b></a></dt>
227
 
 
228
 
<dd>
229
 
<dl>
230
 
<dt><a name="$driver_-_name_of_the_database_driver_to_use"
231
 
><code  class="code">$driver</code> - name of the database driver to use
232
 
<dt><a name="$host_-_host_running_the_database_we_are_connecting_to"
233
 
><code  class="code">$host</code> - host running the database we are connecting to
234
 
<dt><a name="$dbname_-_name_of_the_database_to_connect_to"
235
 
><code  class="code">$dbname</code> - name of the database to connect to
236
 
<dt><a name="$port_-_port_the_database_is_listening_on"
237
 
><code  class="code">$port</code> - port the database is listening on
238
 
<dt><a name="$sock_-_socket_the_database_is_listening_on"
239
 
><code  class="code">$sock</code> - socket the database is listening on
240
 
<dt><a name="$user_-_username_used_to_log_in_to_the_database"
241
 
><code  class="code">$user</code> - username used to log in to the database
242
 
<dt><a name="$pass_-_password_used_to_log_in_to_the_database"
243
 
><code  class="code">$pass</code> - password used to log in to the database</a></dt>
244
 
</dl>
245
 
 
246
 
<dt><a name="Returns"
247
 
><b>Returns</b></a></dt>
248
 
 
249
 
<dd>
250
 
<p>A new instance of the DB class</p>
251
 
</dd>
252
 
</dl>
253
 
 
254
 
<dt><a name="_handle_error"
255
 
><code  class="code">_handle_error</code></a></dt>
256
 
 
257
 
<dd>
258
 
<p>Function passed to the DBI::connect call for error handling. It shortens the error for printing.</p>
259
 
 
260
 
<dt><a name="import"
261
 
><code  class="code">import</code></a></dt>
262
 
 
263
 
<dd>
264
 
<p>Overrides the standard import method to check that derived class implements all required abstract methods. Also calls original implementation in its super class.</p>
265
 
</dd>
266
 
</dl>
267
 
 
268
 
<h1><a class='u' href='#___top' title='click to go to top of document'
269
 
name="ABSTRACT_METHODS"
270
 
>ABSTRACT METHODS</a></h1>
271
 
 
272
 
<p>Note: Methods which can be implemented generically for all DBs are implemented in this module. If needed, they can be overridden with DB specific code. Methods which do not have standard implementation are abstract and must be implemented for all supported databases separately. To avoid confusion with standard DBI methods, all methods returning string with formatted SQL command have prefix <code  class="code">sql_</code>. All other methods have prefix <code  class="code">bz_</code>.</p>
273
 
 
274
 
<h2><a class='u' href='#___top' title='click to go to top of document'
275
 
name="Constructor"
276
 
>Constructor</a></h2>
277
 
 
278
 
<dl>
279
 
<dt><a name="new"
280
 
><code  class="code">new</code></a></dt>
281
 
 
282
 
<dd>
283
 
<dl>
284
 
<dt><a name="Description"
285
 
><b>Description</b></a></dt>
286
 
 
287
 
<dd>
288
 
<p>Constructor. Abstract method, should be overridden by database specific code.</p>
289
 
 
290
 
<dt><a name="Params"
291
 
><b>Params</b></a></dt>
292
 
 
293
 
<dd>
294
 
<dl>
295
 
<dt><a name="$user_-_username_used_to_log_in_to_the_database"
296
 
><code  class="code">$user</code> - username used to log in to the database
297
 
<dt><a name="$pass_-_password_used_to_log_in_to_the_database"
298
 
><code  class="code">$pass</code> - password used to log in to the database
299
 
<dt><a name="$host_-_host_running_the_database_we_are_connecting_to"
300
 
><code  class="code">$host</code> - host running the database we are connecting to
301
 
<dt><a name="$dbname_-_name_of_the_database_to_connect_to"
302
 
><code  class="code">$dbname</code> - name of the database to connect to
303
 
<dt><a name="$port_-_port_the_database_is_listening_on"
304
 
><code  class="code">$port</code> - port the database is listening on
305
 
<dt><a name="$sock_-_socket_the_database_is_listening_on"
306
 
><code  class="code">$sock</code> - socket the database is listening on</a></dt>
307
 
</dl>
308
 
 
309
 
<dt><a name="Returns"
310
 
><b>Returns</b></a></dt>
311
 
 
312
 
<dd>
313
 
<p>A new instance of the DB class</p>
314
 
 
315
 
<dt><a name="Note"
316
 
><b>Note</b></a></dt>
317
 
 
318
 
<dd>
319
 
<p>The constructor should create a DSN from the parameters provided and then call <code  class="code">db_new()</code> method of its super class to create a new class instance. See <a href="../db_new.html" class="podlinkpod"
320
 
>db_new</a> description in this module. As per DBI documentation, all class variables must be prefixed with &#34;private_&#34;. See <a href="../DBI.html" class="podlinkpod"
321
 
>DBI</a>.</p>
322
 
</dd>
323
 
</dl>
324
 
</dd>
325
 
</dl>
326
 
 
327
 
<h2><a class='u' href='#___top' title='click to go to top of document'
328
 
name="SQL_Generation"
329
 
>SQL Generation</a></h2>
330
 
 
331
 
<dl>
332
 
<dt><a name="sql_regexp"
333
 
><code  class="code">sql_regexp</code></a></dt>
334
 
 
335
 
<dd>
336
 
<dl>
337
 
<dt><a name="Description"
338
 
><b>Description</b></a></dt>
339
 
 
340
 
<dd>
341
 
<p>Outputs SQL regular expression operator for POSIX regex searches (case insensitive) in format suitable for a given database.</p>
342
 
 
343
 
<p>Abstract method, should be overridden by database specific code.</p>
344
 
 
345
 
<dt><a name="Params"
346
 
><b>Params</b></a></dt>
347
 
 
348
 
<dd>
349
 
<dl>
350
 
<dt><a name="$expr_-_SQL_expression_for_the_text_to_be_searched_(scalar)"
351
 
><code  class="code">$expr</code> - SQL expression for the text to be searched (scalar)
352
 
<dt><a name="$pattern_-_the_regular_expression_to_search_for_(scalar)"
353
 
><code  class="code">$pattern</code> - the regular expression to search for (scalar)</a></dt>
354
 
</dl>
355
 
 
356
 
<dt><a name="Returns"
357
 
><b>Returns</b></a></dt>
358
 
 
359
 
<dd>
360
 
<p>Formatted SQL for regular expression search (e.g. REGEXP) (scalar)</p>
361
 
</dd>
362
 
</dl>
363
 
 
364
 
<dt><a name="sql_not_regexp"
365
 
><code  class="code">sql_not_regexp</code></a></dt>
366
 
 
367
 
<dd>
368
 
<dl>
369
 
<dt><a name="Description"
370
 
><b>Description</b></a></dt>
371
 
 
372
 
<dd>
373
 
<p>Outputs SQL regular expression operator for negative POSIX regex searches (case insensitive) in format suitable for a given database.</p>
374
 
 
375
 
<p>Abstract method, should be overridden by database specific code.</p>
376
 
 
377
 
<dt><a name="Params"
378
 
><b>Params</b></a></dt>
379
 
 
380
 
<dd>
381
 
<dl>
382
 
<dt><a name="$expr_-_SQL_expression_for_the_text_to_be_searched_(scalar)"
383
 
><code  class="code">$expr</code> - SQL expression for the text to be searched (scalar)
384
 
<dt><a name="$pattern_-_the_regular_expression_to_search_for_(scalar)"
385
 
><code  class="code">$pattern</code> - the regular expression to search for (scalar)</a></dt>
386
 
</dl>
387
 
 
388
 
<dt><a name="Returns"
389
 
><b>Returns</b></a></dt>
390
 
 
391
 
<dd>
392
 
<p>Formatted SQL for negative regular expression search (e.g. NOT REGEXP) (scalar)</p>
393
 
</dd>
394
 
</dl>
395
 
 
396
 
<dt><a name="sql_limit"
397
 
><code  class="code">sql_limit</code></a></dt>
398
 
 
399
 
<dd>
400
 
<dl>
401
 
<dt><a name="Description"
402
 
><b>Description</b></a></dt>
403
 
 
404
 
<dd>
405
 
<p>Returns SQL syntax for limiting results to some number of rows with optional offset if not starting from the begining.</p>
406
 
 
407
 
<p>Abstract method, should be overridden by database specific code.</p>
408
 
 
409
 
<dt><a name="Params"
410
 
><b>Params</b></a></dt>
411
 
 
412
 
<dd>
413
 
<dl>
414
 
<dt><a name="$limit_-_number_of_rows_to_return_from_query_(scalar)"
415
 
><code  class="code">$limit</code> - number of rows to return from query (scalar)
416
 
<dt><a name="$offset_-_number_of_rows_to_skip_prior_counting_(scalar)"
417
 
><code  class="code">$offset</code> - number of rows to skip prior counting (scalar)</a></dt>
418
 
</dl>
419
 
 
420
 
<dt><a name="Returns"
421
 
><b>Returns</b></a></dt>
422
 
 
423
 
<dd>
424
 
<p>Formatted SQL for limiting number of rows returned from query with optional offset (e.g. LIMIT 1, 1) (scalar)</p>
425
 
</dd>
426
 
</dl>
427
 
 
428
 
<dt><a name="sql_from_days"
429
 
><code  class="code">sql_from_days</code></a></dt>
430
 
 
431
 
<dd>
432
 
<dl>
433
 
<dt><a name="Description"
434
 
><b>Description</b></a></dt>
435
 
 
436
 
<dd>
437
 
<p>Outputs SQL syntax for converting Julian days to date.</p>
438
 
 
439
 
<p>Abstract method, should be overridden by database specific code.</p>
440
 
 
441
 
<dt><a name="Params"
442
 
><b>Params</b></a></dt>
443
 
 
444
 
<dd>
445
 
<dl>
446
 
<dt><a name="$days_-_days_to_convert_to_date"
447
 
><code  class="code">$days</code> - days to convert to date</a></dt>
448
 
</dl>
449
 
 
450
 
<dt><a name="Returns"
451
 
><b>Returns</b></a></dt>
452
 
 
453
 
<dd>
454
 
<p>Formatted SQL for returning Julian days in dates. (scalar)</p>
455
 
</dd>
456
 
</dl>
457
 
 
458
 
<dt><a name="sql_to_days"
459
 
><code  class="code">sql_to_days</code></a></dt>
460
 
 
461
 
<dd>
462
 
<dl>
463
 
<dt><a name="Description"
464
 
><b>Description</b></a></dt>
465
 
 
466
 
<dd>
467
 
<p>Outputs SQL syntax for converting date to Julian days.</p>
468
 
 
469
 
<p>Abstract method, should be overridden by database specific code.</p>
470
 
 
471
 
<dt><a name="Params"
472
 
><b>Params</b></a></dt>
473
 
 
474
 
<dd>
475
 
<dl>
476
 
<dt><a name="$date_-_date_to_convert_to_days"
477
 
><code  class="code">$date</code> - date to convert to days</a></dt>
478
 
</dl>
479
 
 
480
 
<dt><a name="Returns"
481
 
><b>Returns</b></a></dt>
482
 
 
483
 
<dd>
484
 
<p>Formatted SQL for returning date fields in Julian days. (scalar)</p>
485
 
</dd>
486
 
</dl>
487
 
 
488
 
<dt><a name="sql_date_format"
489
 
><code  class="code">sql_date_format</code></a></dt>
490
 
 
491
 
<dd>
492
 
<dl>
493
 
<dt><a name="Description"
494
 
><b>Description</b></a></dt>
495
 
 
496
 
<dd>
497
 
<p>Outputs SQL syntax for formatting dates.</p>
498
 
 
499
 
<p>Abstract method, should be overridden by database specific code.</p>
500
 
 
501
 
<dt><a name="Params"
502
 
><b>Params</b></a></dt>
503
 
 
504
 
<dd>
505
 
<dl>
506
 
<dt><a name="$date_-_date_or_name_of_date_type_column_(scalar)"
507
 
><code  class="code">$date</code> - date or name of date type column (scalar)
508
 
<dt><a 
509
 
><code  class="code">$format</code> - format string for date output (scalar) (<code  class="code">%Y</code> = year, four digits, <code  class="code">%y</code> = year, two digits, <code  class="code">%m</code> = month, <code  class="code">%d</code> = day, <code  class="code">%a</code> = weekday name, 3 letters, <code  class="code">%H</code> = hour 00-23, <code  class="code">%i</code> = minute, <code  class="code">%s</code> = second)</a></dt>
510
 
</dl>
511
 
 
512
 
<dt><a name="Returns"
513
 
><b>Returns</b></a></dt>
514
 
 
515
 
<dd>
516
 
<p>Formatted SQL for date formatting (scalar)</p>
517
 
</dd>
518
 
</dl>
519
 
 
520
 
<dt><a name="sql_interval"
521
 
><code  class="code">sql_interval</code></a></dt>
522
 
 
523
 
<dd>
524
 
<dl>
525
 
<dt><a name="Description"
526
 
><b>Description</b></a></dt>
527
 
 
528
 
<dd>
529
 
<p>Outputs proper SQL syntax for a time interval function.</p>
530
 
 
531
 
<p>Abstract method, should be overridden by database specific code.</p>
532
 
 
533
 
<dt><a name="Params"
534
 
><b>Params</b></a></dt>
535
 
 
536
 
<dd>
537
 
<dl>
538
 
<dt><a name="$interval_-_the_time_interval_requested_(e.g._&#39;30&#39;)_(integer)"
539
 
><code  class="code">$interval</code> - the time interval requested (e.g. &#39;30&#39;) (integer)
540
 
<dt><a name="$units_-_the_units_the_interval_is_in_(e.g._&#39;MINUTE&#39;)_(string)"
541
 
><code  class="code">$units</code> - the units the interval is in (e.g. &#39;MINUTE&#39;) (string)</a></dt>
542
 
</dl>
543
 
 
544
 
<dt><a name="Returns"
545
 
><b>Returns</b></a></dt>
546
 
 
547
 
<dd>
548
 
<p>Formatted SQL for interval function (scalar)</p>
549
 
</dd>
550
 
</dl>
551
 
 
552
 
<dt><a name="sql_position"
553
 
><code  class="code">sql_position</code></a></dt>
554
 
 
555
 
<dd>
556
 
<dl>
557
 
<dt><a name="Description"
558
 
><b>Description</b></a></dt>
559
 
 
560
 
<dd>
561
 
<p>Outputs proper SQL syntax determinig position of a substring (fragment) withing a string (text). Note: if the substring or text are string constants, they must be properly quoted (e.g. &#34;&#39;pattern&#39;&#34;).</p>
562
 
 
563
 
<dt><a name="Params"
564
 
><b>Params</b></a></dt>
565
 
 
566
 
<dd>
567
 
<dl>
568
 
<dt><a name="$fragment_-_the_string_fragment_we_are_searching_for_(scalar)"
569
 
><code  class="code">$fragment</code> - the string fragment we are searching for (scalar)
570
 
<dt><a name="$text_-_the_text_to_search_(scalar)"
571
 
><code  class="code">$text</code> - the text to search (scalar)</a></dt>
572
 
</dl>
573
 
 
574
 
<dt><a name="Returns"
575
 
><b>Returns</b></a></dt>
576
 
 
577
 
<dd>
578
 
<p>Formatted SQL for substring search (scalar)</p>
579
 
</dd>
580
 
</dl>
581
 
 
582
 
<dt><a name="sql_group_by"
583
 
><code  class="code">sql_group_by</code></a></dt>
584
 
 
585
 
<dd>
586
 
<dl>
587
 
<dt><a name="Description"
588
 
><b>Description</b></a></dt>
589
 
 
590
 
<dd>
591
 
<p>Outputs proper SQL syntax for grouping the result of a query.</p>
592
 
 
593
 
<p>For ANSI SQL databases, we need to group by all columns we are querying for (except for columns used in aggregate functions). Some databases require (or even allow) to specify only one or few columns if the result is uniquely defined. For those databases, the default implementation needs to be overloaded.</p>
594
 
 
595
 
<dt><a name="Params"
596
 
><b>Params</b></a></dt>
597
 
 
598
 
<dd>
599
 
<dl>
600
 
<dt><a name="$needed_columns_-_string_with_comma_separated_list_of_columns_we_need_to_group_by_to_get_expected_result_(scalar)"
601
 
><code  class="code">$needed_columns</code> - string with comma separated list of columns we need to group by to get expected result (scalar)
602
 
<dt><a 
603
 
><code  class="code">$optional_columns</code> - string with comma separated list of all other columns we are querying for, but which are not in the required list.</a></dt>
604
 
</dl>
605
 
 
606
 
<dt><a name="Returns"
607
 
><b>Returns</b></a></dt>
608
 
 
609
 
<dd>
610
 
<p>Formatted SQL for row grouping (scalar)</p>
611
 
</dd>
612
 
</dl>
613
 
 
614
 
<dt><a name="sql_string_concat"
615
 
><code  class="code">sql_string_concat</code></a></dt>
616
 
 
617
 
<dd>
618
 
<dl>
619
 
<dt><a name="Description"
620
 
><b>Description</b></a></dt>
621
 
 
622
 
<dd>
623
 
<p>Returns SQL syntax for concatenating multiple strings (constants or values from table columns) together.</p>
624
 
 
625
 
<dt><a name="Params"
626
 
><b>Params</b></a></dt>
627
 
 
628
 
<dd>
629
 
<dl>
630
 
<dt><a name="@params_-_array_of_column_names_or_strings_to_concatenate"
631
 
><code  class="code">@params</code> - array of column names or strings to concatenate</a></dt>
632
 
</dl>
633
 
 
634
 
<dt><a name="Returns"
635
 
><b>Returns</b></a></dt>
636
 
 
637
 
<dd>
638
 
<p>Formatted SQL for concatenating specified strings</p>
639
 
</dd>
640
 
</dl>
641
 
 
642
 
<dt><a name="sql_fulltext_search"
643
 
><code  class="code">sql_fulltext_search</code></a></dt>
644
 
 
645
 
<dd>
646
 
<dl>
647
 
<dt><a name="Description"
648
 
><b>Description</b></a></dt>
649
 
 
650
 
<dd>
651
 
<p>Returns SQL syntax for performing a full text search for specified text on a given column.</p>
652
 
 
653
 
<p>There is a ANSI SQL version of this method implemented using LIKE operator, but it&#39;s not a real full text search. DB specific modules should override this, as this generic implementation will be always much slower. This generic implementation returns &#39;relevance&#39; as 0 for no match, or 1 for a match.</p>
654
 
 
655
 
<dt><a name="Params"
656
 
><b>Params</b></a></dt>
657
 
 
658
 
<dd>
659
 
<dl>
660
 
<dt><a name="$column_-_name_of_column_to_search_(scalar)"
661
 
><code  class="code">$column</code> - name of column to search (scalar)
662
 
<dt><a name="$text_-_text_to_search_for_(scalar)"
663
 
><code  class="code">$text</code> - text to search for (scalar)</a></dt>
664
 
</dl>
665
 
 
666
 
<dt><a name="Returns"
667
 
><b>Returns</b></a></dt>
668
 
 
669
 
<dd>
670
 
<p>Formatted SQL for full text search</p>
671
 
</dd>
672
 
</dl>
673
 
 
674
 
<dt><a name="sql_istrcmp"
675
 
><code  class="code">sql_istrcmp</code></a></dt>
676
 
 
677
 
<dd>
678
 
<dl>
679
 
<dt><a name="Description"
680
 
><b>Description</b></a></dt>
681
 
 
682
 
<dd>
683
 
<p>Returns SQL for a case-insensitive string comparison.</p>
684
 
 
685
 
<dt><a name="Params"
686
 
><b>Params</b></a></dt>
687
 
 
688
 
<dd>
689
 
<dl>
690
 
<dt><a name="$left_-_What_should_be_on_the_left-hand-side_of_the_operation."
691
 
><code  class="code">$left</code> - What should be on the left-hand-side of the operation.
692
 
<dt><a name="$right_-_What_should_be_on_the_right-hand-side_of_the_operation."
693
 
><code  class="code">$right</code> - What should be on the right-hand-side of the operation.
694
 
<dt><a 
695
 
><code  class="code">$op</code> (optional) - What the operation is. Should be a valid ANSI SQL comparison operator, such as <code  class="code">=</code>, <code  class="code">&#60;</code>, <code  class="code">LIKE</code>, etc. Defaults to <code  class="code">=</code> if not specified.</a></dt>
696
 
</dl>
697
 
 
698
 
<dt><a name="Returns"
699
 
><b>Returns</b></a></dt>
700
 
 
701
 
<dd>
702
 
<p>A SQL statement that will run the comparison in a case-insensitive fashion.</p>
703
 
 
704
 
<dt><a name="Note"
705
 
><b>Note</b></a></dt>
706
 
 
707
 
<dd>
708
 
<p>Uses <a href="#sql_istring" class="podlinkpod"
709
 
>&#34;sql_istring&#34;</a>, so it has the same performance concerns. Try to avoid using this function unless absolutely necessary.</p>
710
 
 
711
 
<p>Subclass Implementors: Override sql_istring instead of this function, most of the time (this function uses sql_istring).</p>
712
 
</dd>
713
 
</dl>
714
 
 
715
 
<dt><a name="sql_istring"
716
 
><code  class="code">sql_istring</code></a></dt>
717
 
 
718
 
<dd>
719
 
<dl>
720
 
<dt><a name="Description"
721
 
><b>Description</b></a></dt>
722
 
 
723
 
<dd>
724
 
<p>Returns SQL syntax &#34;preparing&#34; a string or text column for case-insensitive comparison.</p>
725
 
 
726
 
<dt><a name="Params"
727
 
><b>Params</b></a></dt>
728
 
 
729
 
<dd>
730
 
<dl>
731
 
<dt><a name="$string_-_string_to_convert_(scalar)"
732
 
><code  class="code">$string</code> - string to convert (scalar)</a></dt>
733
 
</dl>
734
 
 
735
 
<dt><a name="Returns"
736
 
><b>Returns</b></a></dt>
737
 
 
738
 
<dd>
739
 
<p>Formatted SQL making the string case insensitive.</p>
740
 
 
741
 
<dt><a name="Note"
742
 
><b>Note</b></a></dt>
743
 
 
744
 
<dd>
745
 
<p>The default implementation simply calls LOWER on the parameter. If this is used to search on a text column with index, the index will not be usually used unless it was created as LOWER(column).</p>
746
 
</dd>
747
 
</dl>
748
 
 
749
 
<dt><a name="bz_lock_tables"
750
 
><code  class="code">bz_lock_tables</code></a></dt>
751
 
 
752
 
<dd>
753
 
<dl>
754
 
<dt><a name="Description"
755
 
><b>Description</b></a></dt>
756
 
 
757
 
<dd>
758
 
<p>Performs a table lock operation on specified tables. If the underlying database supports transactions, it should also implicitly start a new transaction.</p>
759
 
 
760
 
<p>Abstract method, should be overridden by database specific code.</p>
761
 
 
762
 
<dt><a name="Params"
763
 
><b>Params</b></a></dt>
764
 
 
765
 
<dd>
766
 
<dl>
767
 
<dt><a name="@tables_-_list_of_names_of_tables_to_lock_in_MySQL_notation_(ex._&#39;bugs_AS_bugs2_READ&#39;,_&#39;logincookies_WRITE&#39;)"
768
 
><code  class="code">@tables</code> - list of names of tables to lock in MySQL notation (ex. &#39;bugs AS bugs2 READ&#39;, &#39;logincookies WRITE&#39;)</a></dt>
769
 
</dl>
770
 
 
771
 
<dt><a name="Returns_(nothing)"
772
 
><b>Returns</b> (nothing)</a></dt>
773
 
</dl>
774
 
 
775
 
<dt><a name="bz_unlock_tables"
776
 
><code  class="code">bz_unlock_tables</code></a></dt>
777
 
 
778
 
<dd>
779
 
<dl>
780
 
<dt><a name="Description"
781
 
><b>Description</b></a></dt>
782
 
 
783
 
<dd>
784
 
<p>Performs a table unlock operation.</p>
785
 
 
786
 
<p>If the underlying database supports transactions, it should also implicitly commit or rollback the transaction.</p>
787
 
 
788
 
<p>Also, this function should allow to be called with the abort flag set even without locking tables first without raising an error to simplify error handling.</p>
789
 
 
790
 
<p>Abstract method, should be overridden by database specific code.</p>
791
 
 
792
 
<dt><a name="Params"
793
 
><b>Params</b></a></dt>
794
 
 
795
 
<dd>
796
 
<dl>
797
 
<dt><a 
798
 
><code  class="code">$abort</code> - <code  class="code">UNLOCK_ABORT</code> if the operation on locked tables failed (if transactions are supported, the action will be rolled back). No param if the operation succeeded. This is only used by <a href="../Bugzilla/Error.html#throw_error" class="podlinkpod"
799
 
>&#34;throw_error&#34; in Bugzilla::Error</a>.</a></dt>
800
 
</dl>
801
 
 
802
 
<dt><a name="Returns_(none)"
803
 
><b>Returns</b> (none)</a></dt>
804
 
</dl>
805
 
</dd>
806
 
</dl>
807
 
 
808
 
<h1><a class='u' href='#___top' title='click to go to top of document'
809
 
name="IMPLEMENTED_METHODS"
810
 
>IMPLEMENTED METHODS</a></h1>
811
 
 
812
 
<p>These methods are implemented in Bugzilla::DB, and only need to be implemented in subclasses if you need to override them for database-compatibility reasons.</p>
813
 
 
814
 
<h2><a class='u' href='#___top' title='click to go to top of document'
815
 
name="General_Information_Methods"
816
 
>General Information Methods</a></h2>
817
 
 
818
 
<p>These methods return information about data in the database.</p>
819
 
 
820
 
<dl>
821
 
<dt><a name="bz_last_key"
822
 
><code  class="code">bz_last_key</code></a></dt>
823
 
 
824
 
<dd>
825
 
<dl>
826
 
<dt><a name="Description"
827
 
><b>Description</b></a></dt>
828
 
 
829
 
<dd>
830
 
<p>Returns the last serial number, usually from a previous INSERT.</p>
831
 
 
832
 
<p>Must be executed directly following the relevant INSERT. This base implementation uses <a href="../DBI.html#last_insert_id" class="podlinkpod"
833
 
>&#34;last_insert_id&#34; in DBI</a>. If the DBD supports it, it is the preffered way to obtain the last serial index. If it is not supported, the DB-specific code needs to override this function.</p>
834
 
 
835
 
<dt><a name="Params"
836
 
><b>Params</b></a></dt>
837
 
 
838
 
<dd>
839
 
<dl>
840
 
<dt><a name="$table_-_name_of_table_containing_serial_column_(scalar)"
841
 
><code  class="code">$table</code> - name of table containing serial column (scalar)
842
 
<dt><a name="$column_-_name_of_column_containing_serial_data_type_(scalar)"
843
 
><code  class="code">$column</code> - name of column containing serial data type (scalar)</a></dt>
844
 
</dl>
845
 
 
846
 
<dt><a name="Returns"
847
 
><b>Returns</b></a></dt>
848
 
 
849
 
<dd>
850
 
<p>Last inserted ID (scalar)</p>
851
 
</dd>
852
 
</dl>
853
 
 
854
 
<dt><a name="bz_get_field_defs"
855
 
><code  class="code">bz_get_field_defs</code></a></dt>
856
 
 
857
 
<dd>
858
 
<dl>
859
 
<dt><a name="Description"
860
 
><b>Description</b></a></dt>
861
 
 
862
 
<dd>
863
 
<p>Returns a list of all the &#34;bug&#34; fields in Bugzilla. The list contains hashes, with a <code  class="code">name</code> key and a <code  class="code">description</code> key.</p>
864
 
 
865
 
<dt><a name="Params_(none)"
866
 
><b>Params</b> (none)
867
 
<dt><a name="Returns"
868
 
><b>Returns</b></a></dt>
869
 
 
870
 
<dd>
871
 
<p>List of all the &#34;bug&#34; fields</p>
872
 
</dd>
873
 
</dl>
874
 
</dd>
875
 
</dl>
876
 
 
877
 
<h2><a class='u' href='#___top' title='click to go to top of document'
878
 
name="Database_Setup_Methods"
879
 
>Database Setup Methods</a></h2>
880
 
 
881
 
<p>These methods are used by the Bugzilla installation programs to set up the database.</p>
882
 
 
883
 
<dl>
884
 
<dt><a name="bz_populate_enum_tables"
885
 
><code  class="code">bz_populate_enum_tables</code></a></dt>
886
 
 
887
 
<dd>
888
 
<dl>
889
 
<dt><a name="Description"
890
 
><b>Description</b></a></dt>
891
 
 
892
 
<dd>
893
 
<p>For an upgrade or an initial installation, populates the tables that hold the legal values for the old &#34;enum&#34; fields: <code  class="code">bug_severity</code>, <code  class="code">resolution</code>, etc. Prints out information if it inserts anything into the DB.</p>
894
 
 
895
 
<dt><a name="Params_(none)"
896
 
><b>Params</b> (none)
897
 
<dt><a name="Returns_(nothing)"
898
 
><b>Returns</b> (nothing)</a></dt>
899
 
</dl>
900
 
</dd>
901
 
</dl>
902
 
 
903
 
<h2><a class='u' href='#___top' title='click to go to top of document'
904
 
name="Schema_Modification_Methods"
905
 
>Schema Modification Methods</a></h2>
906
 
 
907
 
<p>These methods modify the current Bugzilla Schema.</p>
908
 
 
909
 
<p>Where a parameter says &#34;Abstract index/column definition&#34;, it returns/takes information in the formats defined for indexes and columns in <code  class="code">Bugzilla::DB::Schema::ABSTRACT_SCHEMA</code>.</p>
910
 
 
911
 
<dl>
912
 
<dt><a name="bz_add_column"
913
 
><code  class="code">bz_add_column</code></a></dt>
914
 
 
915
 
<dd>
916
 
<dl>
917
 
<dt><a name="Description"
918
 
><b>Description</b></a></dt>
919
 
 
920
 
<dd>
921
 
<p>Adds a new column to a table in the database. Prints out a brief statement that it did so, to stdout. Note that you cannot add a NOT NULL column that has no default -- the database won&#39;t know what to set all the NULL values to.</p>
922
 
 
923
 
<dt><a name="Params"
924
 
><b>Params</b></a></dt>
925
 
 
926
 
<dd>
927
 
<dl>
928
 
<dt><a name="$table_-_the_table_where_the_column_is_being_added"
929
 
><code  class="code">$table</code> - the table where the column is being added
930
 
<dt><a name="$name_-_the_name_of_the_new_column"
931
 
><code  class="code">$name</code> - the name of the new column
932
 
<dt><a name="\%definition_-_Abstract_column_definition_for_the_new_column"
933
 
><code  class="code">\%definition</code> - Abstract column definition for the new column
934
 
<dt><a 
935
 
><code  class="code">$init_value</code> (optional) - An initial value to set the column to. Required if your column is NOT NULL and has no DEFAULT set.</a></dt>
936
 
</dl>
937
 
 
938
 
<dt><a name="Returns_(nothing)"
939
 
><b>Returns</b> (nothing)</a></dt>
940
 
</dl>
941
 
 
942
 
<dt><a name="bz_add_index"
943
 
><code  class="code">bz_add_index</code></a></dt>
944
 
 
945
 
<dd>
946
 
<dl>
947
 
<dt><a name="Description"
948
 
><b>Description</b></a></dt>
949
 
 
950
 
<dd>
951
 
<p>Adds a new index to a table in the database. Prints out a brief statement that it did so, to stdout. If the index already exists, we will do nothing.</p>
952
 
 
953
 
<dt><a name="Params"
954
 
><b>Params</b></a></dt>
955
 
 
956
 
<dd>
957
 
<dl>
958
 
<dt><a name="$table_-_The_table_the_new_index_is_on."
959
 
><code  class="code">$table</code> - The table the new index is on.
960
 
<dt><a name="$name_-_A_name_for_the_new_index."
961
 
><code  class="code">$name</code> - A name for the new index.
962
 
<dt><a name="$definition_-_An_abstract_index_definition._Either_a_hashref_or_an_arrayref."
963
 
><code  class="code">$definition</code> - An abstract index definition. Either a hashref or an arrayref.</a></dt>
964
 
</dl>
965
 
 
966
 
<dt><a name="Returns_(nothing)"
967
 
><b>Returns</b> (nothing)</a></dt>
968
 
</dl>
969
 
 
970
 
<dt><a name="bz_add_table"
971
 
><code  class="code">bz_add_table</code></a></dt>
972
 
 
973
 
<dd>
974
 
<dl>
975
 
<dt><a name="Description"
976
 
><b>Description</b></a></dt>
977
 
 
978
 
<dd>
979
 
<p>Creates a new table in the database, based on the definition for that table in the abstract schema.</p>
980
 
 
981
 
<p>Note that unlike the other &#39;add&#39; functions, this does not take a definition, but always creates the table as it exists in <a href="../Bugzilla/DB/Schema.html#ABSTRACT_SCHEMA" class="podlinkpod"
982
 
>&#34;ABSTRACT_SCHEMA&#34; in Bugzilla::DB::Schema</a>.</p>
983
 
 
984
 
<p>If a table with that name already exists, then this function returns silently.</p>
985
 
 
986
 
<dt><a name="Params"
987
 
><b>Params</b></a></dt>
988
 
 
989
 
<dd>
990
 
<dl>
991
 
<dt><a name="$name_-_The_name_of_the_table_you_want_to_create."
992
 
><code  class="code">$name</code> - The name of the table you want to create.</a></dt>
993
 
</dl>
994
 
 
995
 
<dt><a name="Returns_(nothing)"
996
 
><b>Returns</b> (nothing)</a></dt>
997
 
</dl>
998
 
 
999
 
<dt><a name="bz_drop_index"
1000
 
><code  class="code">bz_drop_index</code></a></dt>
1001
 
 
1002
 
<dd>
1003
 
<dl>
1004
 
<dt><a name="Description"
1005
 
><b>Description</b></a></dt>
1006
 
 
1007
 
<dd>
1008
 
<p>Removes an index from the database. Prints out a brief statement that it did so, to stdout. If the index doesn&#39;t exist, we do nothing.</p>
1009
 
 
1010
 
<dt><a name="Params"
1011
 
><b>Params</b></a></dt>
1012
 
 
1013
 
<dd>
1014
 
<dl>
1015
 
<dt><a name="$table_-_The_table_that_the_index_is_on."
1016
 
><code  class="code">$table</code> - The table that the index is on.
1017
 
<dt><a name="$name_-_The_name_of_the_index_that_you_want_to_drop."
1018
 
><code  class="code">$name</code> - The name of the index that you want to drop.</a></dt>
1019
 
</dl>
1020
 
 
1021
 
<dt><a name="Returns_(nothing)"
1022
 
><b>Returns</b> (nothing)</a></dt>
1023
 
</dl>
1024
 
 
1025
 
<dt><a name="bz_drop_table"
1026
 
><code  class="code">bz_drop_table</code></a></dt>
1027
 
 
1028
 
<dd>
1029
 
<dl>
1030
 
<dt><a name="Description"
1031
 
><b>Description</b></a></dt>
1032
 
 
1033
 
<dd>
1034
 
<p>Drops a table from the database. If the table doesn&#39;t exist, we just return silently.</p>
1035
 
 
1036
 
<dt><a name="Params"
1037
 
><b>Params</b></a></dt>
1038
 
 
1039
 
<dd>
1040
 
<dl>
1041
 
<dt><a name="$name_-_The_name_of_the_table_to_drop."
1042
 
><code  class="code">$name</code> - The name of the table to drop.</a></dt>
1043
 
</dl>
1044
 
 
1045
 
<dt><a name="Returns_(nothing)"
1046
 
><b>Returns</b> (nothing)</a></dt>
1047
 
</dl>
1048
 
 
1049
 
<dt><a name="bz_alter_column"
1050
 
><code  class="code">bz_alter_column</code></a></dt>
1051
 
 
1052
 
<dd>
1053
 
<dl>
1054
 
<dt><a name="Description"
1055
 
><b>Description</b></a></dt>
1056
 
 
1057
 
<dd>
1058
 
<p>Changes the data type of a column in a table. Prints out the changes being made to stdout. If the new type is the same as the old type, the function returns without changing anything.</p>
1059
 
 
1060
 
<dt><a name="Params"
1061
 
><b>Params</b></a></dt>
1062
 
 
1063
 
<dd>
1064
 
<dl>
1065
 
<dt><a name="$table_-_the_table_where_the_column_is"
1066
 
><code  class="code">$table</code> - the table where the column is
1067
 
<dt><a name="$name_-_the_name_of_the_column_you_want_to_change"
1068
 
><code  class="code">$name</code> - the name of the column you want to change
1069
 
<dt><a name="\%new_def_-_An_abstract_column_definition_for_the_new_data_type_of_the_columm"
1070
 
><code  class="code">\%new_def</code> - An abstract column definition for the new data type of the columm
1071
 
<dt><a 
1072
 
><code  class="code">$set_nulls_to</code> (Optional) - If you are changing the column to be NOT NULL, you probably also want to set any existing NULL columns to a particular value. Specify that value here. <b>NOTE</b>: The value should not already be SQL-quoted.</a></dt>
1073
 
</dl>
1074
 
 
1075
 
<dt><a name="Returns_(nothing)"
1076
 
><b>Returns</b> (nothing)</a></dt>
1077
 
</dl>
1078
 
 
1079
 
<dt><a name="bz_drop_column"
1080
 
><code  class="code">bz_drop_column</code></a></dt>
1081
 
 
1082
 
<dd>
1083
 
<dl>
1084
 
<dt><a name="Description"
1085
 
><b>Description</b></a></dt>
1086
 
 
1087
 
<dd>
1088
 
<p>Removes a column from a database table. If the column doesn&#39;t exist, we return without doing anything. If we do anything, we print a short message to <code  class="code">stdout</code> about the change.</p>
1089
 
 
1090
 
<dt><a name="Params"
1091
 
><b>Params</b></a></dt>
1092
 
 
1093
 
<dd>
1094
 
<dl>
1095
 
<dt><a name="$table_-_The_table_where_the_column_is"
1096
 
><code  class="code">$table</code> - The table where the column is
1097
 
<dt><a name="$column_-_The_name_of_the_column_you_want_to_drop"
1098
 
><code  class="code">$column</code> - The name of the column you want to drop</a></dt>
1099
 
</dl>
1100
 
 
1101
 
<dt><a name="Returns_(nothing)"
1102
 
><b>Returns</b> (nothing)</a></dt>
1103
 
</dl>
1104
 
 
1105
 
<dt><a name="bz_rename_column"
1106
 
><code  class="code">bz_rename_column</code></a></dt>
1107
 
 
1108
 
<dd>
1109
 
<dl>
1110
 
<dt><a name="Description"
1111
 
><b>Description</b></a></dt>
1112
 
 
1113
 
<dd>
1114
 
<p>Renames a column in a database table. If the <code  class="code">$old_name</code> column doesn&#39;t exist, we return without doing anything. If <code  class="code">$old_name</code> and <code  class="code">$new_name</code> both already exist in the table specified, we fail.</p>
1115
 
 
1116
 
<dt><a name="Params"
1117
 
><b>Params</b></a></dt>
1118
 
 
1119
 
<dd>
1120
 
<dl>
1121
 
<dt><a name="$table_-_The_name_of_the_table_containing_the_column_that_you_want_to_rename"
1122
 
><code  class="code">$table</code> - The name of the table containing the column that you want to rename
1123
 
<dt><a name="$old_name_-_The_current_name_of_the_column_that_you_want_to_rename"
1124
 
><code  class="code">$old_name</code> - The current name of the column that you want to rename
1125
 
<dt><a name="$new_name_-_The_new_name_of_the_column"
1126
 
><code  class="code">$new_name</code> - The new name of the column</a></dt>
1127
 
</dl>
1128
 
 
1129
 
<dt><a name="Returns_(nothing)"
1130
 
><b>Returns</b> (nothing)</a></dt>
1131
 
</dl>
1132
 
 
1133
 
<dt><a name="bz_rename_table"
1134
 
><code  class="code">bz_rename_table</code></a></dt>
1135
 
 
1136
 
<dd>
1137
 
<dl>
1138
 
<dt><a name="Description"
1139
 
><b>Description</b></a></dt>
1140
 
 
1141
 
<dd>
1142
 
<p>Renames a table in the database. Does nothing if the table doesn&#39;t exist.</p>
1143
 
 
1144
 
<p>Throws an error if the old table exists and there is already a table with the new name.</p>
1145
 
 
1146
 
<dt><a name="Params"
1147
 
><b>Params</b></a></dt>
1148
 
 
1149
 
<dd>
1150
 
<dl>
1151
 
<dt><a name="$old_name_-_The_current_name_of_the_table."
1152
 
><code  class="code">$old_name</code> - The current name of the table.
1153
 
<dt><a name="$new_name_-_What_you&#39;re_renaming_the_table_to."
1154
 
><code  class="code">$new_name</code> - What you&#39;re renaming the table to.</a></dt>
1155
 
</dl>
1156
 
 
1157
 
<dt><a name="Returns_(nothing)"
1158
 
><b>Returns</b> (nothing)</a></dt>
1159
 
</dl>
1160
 
</dd>
1161
 
</dl>
1162
 
 
1163
 
<h2><a class='u' href='#___top' title='click to go to top of document'
1164
 
name="Schema_Information_Methods"
1165
 
>Schema Information Methods</a></h2>
1166
 
 
1167
 
<p>These methods return information about the current Bugzilla database schema, as it currently exists on the disk.</p>
1168
 
 
1169
 
<p>Where a parameter says &#34;Abstract index/column definition&#34;, it returns/takes information in the formats defined for indexes and columns for <a href="../Bugzilla/DB/Schema.html#ABSTRACT_SCHEMA" class="podlinkpod"
1170
 
>&#34;ABSTRACT_SCHEMA&#34; in Bugzilla::DB::Schema</a>.</p>
1171
 
 
1172
 
<dl>
1173
 
<dt><a name="bz_column_info"
1174
 
><code  class="code">bz_column_info</code></a></dt>
1175
 
 
1176
 
<dd>
1177
 
<dl>
1178
 
<dt><a name="Description"
1179
 
><b>Description</b></a></dt>
1180
 
 
1181
 
<dd>
1182
 
<p>Get abstract column definition.</p>
1183
 
 
1184
 
<dt><a name="Params"
1185
 
><b>Params</b></a></dt>
1186
 
 
1187
 
<dd>
1188
 
<dl>
1189
 
<dt><a name="$table_-_The_name_of_the_table_the_column_is_in."
1190
 
><code  class="code">$table</code> - The name of the table the column is in.
1191
 
<dt><a name="$column_-_The_name_of_the_column."
1192
 
><code  class="code">$column</code> - The name of the column.</a></dt>
1193
 
</dl>
1194
 
 
1195
 
<dt><a name="Returns"
1196
 
><b>Returns</b></a></dt>
1197
 
 
1198
 
<dd>
1199
 
<p>An abstract column definition for that column. If the table or column does not exist, we return <code  class="code">undef</code>.</p>
1200
 
</dd>
1201
 
</dl>
1202
 
 
1203
 
<dt><a name="bz_index_info"
1204
 
><code  class="code">bz_index_info</code></a></dt>
1205
 
 
1206
 
<dd>
1207
 
<dl>
1208
 
<dt><a name="Description"
1209
 
><b>Description</b></a></dt>
1210
 
 
1211
 
<dd>
1212
 
<p>Get abstract index definition.</p>
1213
 
 
1214
 
<dt><a name="Params"
1215
 
><b>Params</b></a></dt>
1216
 
 
1217
 
<dd>
1218
 
<dl>
1219
 
<dt><a name="$table_-_The_table_the_index_is_on."
1220
 
><code  class="code">$table</code> - The table the index is on.
1221
 
<dt><a name="$index_-_The_name_of_the_index."
1222
 
><code  class="code">$index</code> - The name of the index.</a></dt>
1223
 
</dl>
1224
 
 
1225
 
<dt><a name="Returns"
1226
 
><b>Returns</b></a></dt>
1227
 
 
1228
 
<dd>
1229
 
<p>An abstract index definition for that index, always in hashref format. The hashref will always contain the <code  class="code">TYPE</code> element, but it will be an empty string if it&#39;s just a normal index.</p>
1230
 
 
1231
 
<p>If the index does not exist, we return <code  class="code">undef</code>.</p>
1232
 
</dd>
1233
 
</dl>
1234
 
</dd>
1235
 
</dl>
1236
 
 
1237
 
<h2><a class='u' href='#___top' title='click to go to top of document'
1238
 
name="Transaction_Methods"
1239
 
>Transaction Methods</a></h2>
1240
 
 
1241
 
<p>These methods deal with the starting and stopping of transactions in the database.</p>
1242
 
 
1243
 
<dl>
1244
 
<dt><a name="bz_start_transaction"
1245
 
><code  class="code">bz_start_transaction</code></a></dt>
1246
 
 
1247
 
<dd>
1248
 
<p>Starts a transaction if supported by the database being used. Returns nothing and takes no parameters.</p>
1249
 
 
1250
 
<dt><a name="bz_commit_transaction"
1251
 
><code  class="code">bz_commit_transaction</code></a></dt>
1252
 
 
1253
 
<dd>
1254
 
<p>Ends a transaction, commiting all changes, if supported by the database being used. Returns nothing and takes no parameters.</p>
1255
 
 
1256
 
<dt><a name="bz_rollback_transaction"
1257
 
><code  class="code">bz_rollback_transaction</code></a></dt>
1258
 
 
1259
 
<dd>
1260
 
<p>Ends a transaction, rolling back all changes, if supported by the database being used. Returns nothing and takes no parameters.</p>
1261
 
</dd>
1262
 
</dl>
1263
 
 
1264
 
<h1><a class='u' href='#___top' title='click to go to top of document'
1265
 
name="SUBCLASS_HELPERS"
1266
 
>SUBCLASS HELPERS</a></h1>
1267
 
 
1268
 
<p>Methods in this class are intended to be used by subclasses to help them with their functions.</p>
1269
 
 
1270
 
<dl>
1271
 
<dt><a name="db_new"
1272
 
><code  class="code">db_new</code></a></dt>
1273
 
 
1274
 
<dd>
1275
 
<dl>
1276
 
<dt><a name="Description"
1277
 
><b>Description</b></a></dt>
1278
 
 
1279
 
<dd>
1280
 
<p>Constructor</p>
1281
 
 
1282
 
<dt><a name="Params"
1283
 
><b>Params</b></a></dt>
1284
 
 
1285
 
<dd>
1286
 
<dl>
1287
 
<dt><a name="$dsn_-_database_connection_string"
1288
 
><code  class="code">$dsn</code> - database connection string
1289
 
<dt><a name="$user_-_username_used_to_log_in_to_the_database"
1290
 
><code  class="code">$user</code> - username used to log in to the database
1291
 
<dt><a name="$pass_-_password_used_to_log_in_to_the_database"
1292
 
><code  class="code">$pass</code> - password used to log in to the database
1293
 
<dt><a name="\%attributes_-_set_of_attributes_for_DB_connection_(optional)"
1294
 
><code  class="code">\%attributes</code> - set of attributes for DB connection (optional)</a></dt>
1295
 
</dl>
1296
 
 
1297
 
<dt><a name="Returns"
1298
 
><b>Returns</b></a></dt>
1299
 
 
1300
 
<dd>
1301
 
<p>A new instance of the DB class</p>
1302
 
 
1303
 
<dt><a name="Note"
1304
 
><b>Note</b></a></dt>
1305
 
 
1306
 
<dd>
1307
 
<p>The name of this constructor is not <code  class="code">new</code>, as that would make our check for implementation of <code  class="code">new</code> by derived class useless.</p>
1308
 
</dd>
1309
 
</dl>
1310
 
</dd>
1311
 
</dl>
1312
 
 
1313
 
<h1><a class='u' href='#___top' title='click to go to top of document'
1314
 
name="SEE_ALSO"
1315
 
>SEE ALSO</a></h1>
1316
 
 
1317
 
<p><a href="../DBI.html" class="podlinkpod"
1318
 
>DBI</a></p>
1319
 
 
1320
 
<p><a href="../Bugzilla/Constants.html#DB_MODULE" class="podlinkpod"
1321
 
>&#34;DB_MODULE&#34; in Bugzilla::Constants</a></p>
1322
 
<p class="backlinkbottom"><b><a name="___bottom" href="../index.html" title="All Documents">&lt;&lt;</a></b></p>
1323
 
 
1324
 
<!-- end doc -->
1325
 
 
1326
 
</body></html>