~ubuntu-branches/ubuntu/maverick/libdbi/maverick-proposed

« back to all changes in this revision

Viewing changes to doc/driver-guide/helperfuncs.html

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Goirand
  • Date: 2007-11-26 05:53:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071126055313-29bzt00k533rgkg8
Tags: 0.8.2-3
* New maintainer (Closes: #444424)
* Now cleaning everything correctly on the clean target
* Now managing updates of config.sub and config.guess correctly
* Removed useless postinst and postrm from debian folder as they are
  generated by dh_makeshlibs anyway
* Cleaned a bit the debian/rules for readability
* Reviewed the debian/copyright for accuracy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2
2
<HTML
3
3
><HEAD
4
4
><TITLE
5
5
>DBD Helper Functions</TITLE
6
6
><META
7
7
NAME="GENERATOR"
8
 
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
9
9
REL="HOME"
10
10
TITLE="Database Independent Abstraction Layer for C"
11
11
HREF="index.html"><LINK
13
13
TITLE="Driver Functions"
14
14
HREF="driverfuncs.html"><LINK
15
15
REL="PREVIOUS"
16
 
TITLE="Database Query Functions"
17
 
HREF="driverfuncs-dbquery.html"><LINK
 
16
TITLE="Public Database Query Functions"
 
17
HREF="driverfuncs-publicdbquery.html"><LINK
18
18
REL="NEXT"
19
19
TITLE="GNU Free Documentation License"
20
20
HREF="copying-fdl.html"></HEAD
37
37
><TH
38
38
COLSPAN="3"
39
39
ALIGN="center"
40
 
>Database Independent Abstraction Layer for C: libdbi Driver Author's Guide (OUTDATED SEE README!)</TH
 
40
>Database Independent Abstraction Layer for C: libdbi Driver Author's Guide</TH
41
41
></TR
42
42
><TR
43
43
><TD
45
45
ALIGN="left"
46
46
VALIGN="bottom"
47
47
><A
48
 
HREF="driverfuncs-dbquery.html"
 
48
HREF="driverfuncs-publicdbquery.html"
49
49
ACCESSKEY="P"
50
50
>Prev</A
51
51
></TD
74
74
CLASS="SECTION"
75
75
><A
76
76
NAME="HELPERFUNCS"
77
 
>2.3. DBD Helper Functions</A
 
77
>2.4. DBD Helper Functions</A
78
78
></H1
 
79
><P
 
80
>libdbi implements a couple of functions which come in handy when implementing database engine drivers. Call them from your driver code if appropriate.</P
79
81
><DIV
80
82
CLASS="SECTION"
81
83
><H2
82
84
CLASS="SECTION"
83
85
><A
84
86
NAME="INTERNAL-DBD-RESULT-CREATE"
85
 
>2.3.1. _dbd_result_create</A
 
87
>2.4.1. _dbd_result_create</A
86
88
></H2
87
 
><P
88
 
><TABLE
89
 
BORDER="0"
90
 
BGCOLOR="#E0E0E0"
91
 
WIDTH="100%"
92
 
><TR
93
 
><TD
94
 
><FONT
95
 
COLOR="#000000"
96
 
><PRE
97
 
CLASS="PROGRAMLISTING"
98
 
>dbi_result_t *_dbd_result_create(dbi_conn_t *conn, void *handle, unsigned int numrows_matched, unsigned int numrows_affected)</PRE
99
 
></FONT
100
 
></TD
101
 
></TR
102
 
></TABLE
103
 
></P
 
89
><DIV
 
90
CLASS="FUNCSYNOPSIS"
 
91
><P
 
92
></P
 
93
><A
 
94
NAME="AEN650"
 
95
></A
 
96
><P
 
97
><CODE
 
98
><CODE
 
99
CLASS="FUNCDEF"
 
100
>dbi_result_t *<B
 
101
CLASS="FSFUNC"
 
102
>_dbd_result_create</B
 
103
></CODE
 
104
>(dbi_conn_t *<VAR
 
105
CLASS="PDPARAM"
 
106
>conn</VAR
 
107
>, void *<VAR
 
108
CLASS="PDPARAM"
 
109
>handle</VAR
 
110
>, unsigned long long <VAR
 
111
CLASS="PDPARAM"
 
112
>numrows_matched</VAR
 
113
>, unsigned long long <VAR
 
114
CLASS="PDPARAM"
 
115
>numrows_affected</VAR
 
116
>);</CODE
 
117
></P
 
118
><P
 
119
></P
 
120
></DIV
104
121
><P
105
122
>Allocates a new dbi_result_t, filling the number of rows matched and affected, storing the database-specific result handle, and allocating room for rows to be stored.</P
106
123
><P
109
126
CLASS="VARIABLELIST"
110
127
><DL
111
128
><DT
112
 
><EM
113
 
>Arguments</EM
114
 
></DT
 
129
>Arguments</DT
115
130
><DD
116
131
><P
117
 
><VAR
 
132
><TT
118
133
CLASS="LITERAL"
119
 
>conn</VAR
 
134
>conn</TT
120
135
>: The target connection.</P
121
136
><P
122
 
><VAR
 
137
><TT
123
138
CLASS="LITERAL"
124
 
>handle</VAR
 
139
>handle</TT
125
140
>: The database-specific result handle used internally by the driver.</P
126
141
><P
127
 
><VAR
 
142
><TT
128
143
CLASS="LITERAL"
129
 
>numrows_matched</VAR
 
144
>numrows_matched</TT
130
145
>: The number of rows matched by the query.</P
131
146
><P
132
 
><VAR
 
147
><TT
133
148
CLASS="LITERAL"
134
 
>numrows_affected</VAR
 
149
>numrows_affected</TT
135
150
>: The number of rows affected by the query.</P
136
151
></DD
137
152
><DT
138
 
><EM
139
 
>Returns</EM
140
 
></DT
 
153
>Returns</DT
141
154
><DD
142
155
><P
143
156
>A new DBI result object.</P
151
164
CLASS="SECTION"
152
165
><A
153
166
NAME="INTERNAL-DBD-RESULT-SET-NUMFIELDS"
154
 
>2.3.2. _dbd_result_set_numfields</A
 
167
>2.4.2. _dbd_result_set_numfields</A
155
168
></H2
156
 
><P
157
 
><TABLE
158
 
BORDER="0"
159
 
BGCOLOR="#E0E0E0"
160
 
WIDTH="100%"
161
 
><TR
162
 
><TD
163
 
><FONT
164
 
COLOR="#000000"
165
 
><PRE
166
 
CLASS="PROGRAMLISTING"
167
 
>void _dbd_result_set_numfields(dbi_result_t *result, unsigned int numfields)</PRE
168
 
></FONT
169
 
></TD
170
 
></TR
171
 
></TABLE
172
 
></P
173
 
><P
174
 
>Sets a result's number of fields and allocates room for field information to be stored.</P
 
169
><DIV
 
170
CLASS="FUNCSYNOPSIS"
 
171
><P
 
172
></P
 
173
><A
 
174
NAME="AEN681"
 
175
></A
 
176
><P
 
177
><CODE
 
178
><CODE
 
179
CLASS="FUNCDEF"
 
180
>void <B
 
181
CLASS="FSFUNC"
 
182
>_dbd_result_set_numfields</B
 
183
></CODE
 
184
>(dbi_result_t *<VAR
 
185
CLASS="PDPARAM"
 
186
>result</VAR
 
187
>, unsigned int <VAR
 
188
CLASS="PDPARAM"
 
189
>numfields</VAR
 
190
>);</CODE
 
191
></P
 
192
><P
 
193
></P
 
194
></DIV
 
195
><P
 
196
>Sets a result's number of fields and allocates memory for field information to be stored.</P
175
197
><P
176
198
></P
177
199
><DIV
178
200
CLASS="VARIABLELIST"
179
201
><DL
180
202
><DT
181
 
><EM
182
 
>Arguments</EM
183
 
></DT
 
203
>Arguments</DT
184
204
><DD
185
205
><P
186
 
><VAR
 
206
><TT
187
207
CLASS="LITERAL"
188
 
>result</VAR
 
208
>result</TT
189
209
>: The target result.</P
190
210
><P
191
 
><VAR
 
211
><TT
192
212
CLASS="LITERAL"
193
 
>numfields</VAR
 
213
>numfields</TT
194
214
>: The number of fields in the result set.</P
195
215
></DD
196
216
></DL
202
222
CLASS="SECTION"
203
223
><A
204
224
NAME="INTERNAL-DBD-RESULT-ADD-FIELD"
205
 
>2.3.3. _dbd_result_add_field</A
 
225
>2.4.3. _dbd_result_add_field</A
206
226
></H2
207
 
><P
208
 
><TABLE
209
 
BORDER="0"
210
 
BGCOLOR="#E0E0E0"
211
 
WIDTH="100%"
212
 
><TR
213
 
><TD
214
 
><FONT
215
 
COLOR="#000000"
216
 
><PRE
217
 
CLASS="PROGRAMLISTING"
218
 
>void _dbd_result_add_field(dbi_result_t *result, unsigned int idx, char *name, unsigned short type, unsigned int attribs)</PRE
219
 
></FONT
220
 
></TD
221
 
></TR
222
 
></TABLE
223
 
></P
 
227
><DIV
 
228
CLASS="FUNCSYNOPSIS"
 
229
><P
 
230
></P
 
231
><A
 
232
NAME="AEN700"
 
233
></A
 
234
><P
 
235
><CODE
 
236
><CODE
 
237
CLASS="FUNCDEF"
 
238
>void <B
 
239
CLASS="FSFUNC"
 
240
>_dbd_result_add_field</B
 
241
></CODE
 
242
>(dbi_result_t *<VAR
 
243
CLASS="PDPARAM"
 
244
>result</VAR
 
245
>, unsigned int <VAR
 
246
CLASS="PDPARAM"
 
247
>idx</VAR
 
248
>, char *<VAR
 
249
CLASS="PDPARAM"
 
250
>name</VAR
 
251
>, unsigned short <VAR
 
252
CLASS="PDPARAM"
 
253
>type</VAR
 
254
>, unsigned int <VAR
 
255
CLASS="PDPARAM"
 
256
>attribs</VAR
 
257
>);</CODE
 
258
></P
 
259
><P
 
260
></P
 
261
></DIV
224
262
><P
225
263
>Stores information about the target field into the result set.</P
226
264
><P
229
267
CLASS="VARIABLELIST"
230
268
><DL
231
269
><DT
232
 
><EM
233
 
>Arguments</EM
234
 
></DT
 
270
>Arguments</DT
235
271
><DD
236
272
><P
237
 
><VAR
 
273
><TT
238
274
CLASS="LITERAL"
239
 
>result</VAR
 
275
>result</TT
240
276
>: The target result.</P
241
277
><P
242
 
><VAR
 
278
><TT
243
279
CLASS="LITERAL"
244
 
>idx</VAR
 
280
>idx</TT
245
281
>: The numeric field index.</P
246
282
><P
247
 
><VAR
 
283
><TT
248
284
CLASS="LITERAL"
249
 
>name</VAR
 
285
>name</TT
250
286
>: The name of the field.</P
251
287
><P
252
 
><VAR
 
288
><TT
253
289
CLASS="LITERAL"
254
 
>type</VAR
 
290
>type</TT
255
291
>: The datatype of the field.</P
256
292
><P
257
 
><VAR
 
293
><TT
258
294
CLASS="LITERAL"
259
 
>attribs</VAR
 
295
>attribs</TT
260
296
>: The attributes of the field.</P
261
297
></DD
262
298
></DL
268
304
CLASS="SECTION"
269
305
><A
270
306
NAME="INTERNAL-DBD-ROW-ALLOCATE"
271
 
>2.3.4. _dbd_row_allocate</A
 
307
>2.4.4. _dbd_row_allocate</A
272
308
></H2
273
 
><P
274
 
><TABLE
275
 
BORDER="0"
276
 
BGCOLOR="#E0E0E0"
277
 
WIDTH="100%"
278
 
><TR
279
 
><TD
280
 
><FONT
281
 
COLOR="#000000"
282
 
><PRE
283
 
CLASS="PROGRAMLISTING"
284
 
>dbi_row_t *_dbd_row_allocate(unsigned int numfields)</PRE
285
 
></FONT
286
 
></TD
287
 
></TR
288
 
></TABLE
289
 
></P
 
309
><DIV
 
310
CLASS="FUNCSYNOPSIS"
 
311
><P
 
312
></P
 
313
><A
 
314
NAME="AEN731"
 
315
></A
 
316
><P
 
317
><CODE
 
318
><CODE
 
319
CLASS="FUNCDEF"
 
320
>dbi_row_t *<B
 
321
CLASS="FSFUNC"
 
322
>_dbd_row_allocate</B
 
323
></CODE
 
324
>(unsigned int <VAR
 
325
CLASS="PDPARAM"
 
326
>numfields</VAR
 
327
>);</CODE
 
328
></P
 
329
><P
 
330
></P
 
331
></DIV
290
332
><P
291
333
>Allocates a new row, ready to be filled with data.</P
292
334
><P
295
337
CLASS="VARIABLELIST"
296
338
><DL
297
339
><DT
298
 
><EM
299
 
>Arguments</EM
300
 
></DT
 
340
>Arguments</DT
301
341
><DD
302
342
><P
303
 
><VAR
 
343
><TT
304
344
CLASS="LITERAL"
305
 
>numfields</VAR
 
345
>numfields</TT
306
346
>: The number of fields in the result set.</P
307
347
></DD
308
348
><DT
309
 
><EM
310
 
>Returns</EM
311
 
></DT
 
349
>Returns</DT
312
350
><DD
313
351
><P
314
352
>A new DBI row, or NULL on error.</P
322
360
CLASS="SECTION"
323
361
><A
324
362
NAME="INTERNAL-DBD-ROW-FINALIZE"
325
 
>2.3.5. _dbd_row_finalize</A
 
363
>2.4.5. _dbd_row_finalize</A
326
364
></H2
327
 
><P
328
 
><TABLE
329
 
BORDER="0"
330
 
BGCOLOR="#E0E0E0"
331
 
WIDTH="100%"
332
 
><TR
333
 
><TD
334
 
><FONT
335
 
COLOR="#000000"
336
 
><PRE
337
 
CLASS="PROGRAMLISTING"
338
 
>void _dbd_row_finalize(dbi_result_t *result, dbi_row_t *row, unsigned int idx)</PRE
339
 
></FONT
340
 
></TD
341
 
></TR
342
 
></TABLE
343
 
></P
 
365
><DIV
 
366
CLASS="FUNCSYNOPSIS"
 
367
><P
 
368
></P
 
369
><A
 
370
NAME="AEN750"
 
371
></A
 
372
><P
 
373
><CODE
 
374
><CODE
 
375
CLASS="FUNCDEF"
 
376
>void <B
 
377
CLASS="FSFUNC"
 
378
>_dbd_row_finalize</B
 
379
></CODE
 
380
>(dbi_result_t *<VAR
 
381
CLASS="PDPARAM"
 
382
>result</VAR
 
383
>, dbi_row_t *<VAR
 
384
CLASS="PDPARAM"
 
385
>row</VAR
 
386
>, unsigned long long <VAR
 
387
CLASS="PDPARAM"
 
388
>rowidx</VAR
 
389
>);</CODE
 
390
></P
 
391
><P
 
392
></P
 
393
></DIV
344
394
><P
345
395
>Associates and stores the row with the result set, once the row's data has been filled.</P
346
396
><P
349
399
CLASS="VARIABLELIST"
350
400
><DL
351
401
><DT
352
 
><EM
353
 
>Arguments</EM
354
 
></DT
 
402
>Arguments</DT
355
403
><DD
356
404
><P
357
 
><VAR
 
405
><TT
358
406
CLASS="LITERAL"
359
 
>result</VAR
 
407
>result</TT
360
408
>: The target result set.</P
361
409
><P
362
 
><VAR
 
410
><TT
363
411
CLASS="LITERAL"
364
 
>row</VAR
 
412
>row</TT
365
413
>: The target row object.</P
366
414
><P
367
 
><VAR
 
415
><TT
368
416
CLASS="LITERAL"
369
 
>idx</VAR
 
417
>rowidx</TT
370
418
>: The index of the row.</P
371
419
></DD
372
420
></DL
378
426
CLASS="SECTION"
379
427
><A
380
428
NAME="INTERNAL-DBD-INTERNAL-ERROR-HANDLER"
381
 
>2.3.6. _dbd_internal_error_handler</A
 
429
>2.4.6. _dbd_internal_error_handler</A
382
430
></H2
383
 
><P
384
 
><TABLE
385
 
BORDER="0"
386
 
BGCOLOR="#E0E0E0"
387
 
WIDTH="100%"
388
 
><TR
389
 
><TD
390
 
><FONT
391
 
COLOR="#000000"
392
 
><PRE
393
 
CLASS="PROGRAMLISTING"
394
 
>void _dbd_internal_error_handler(dbi_conn_t *conn, const char *errmsg, const int errno)</PRE
395
 
></FONT
396
 
></TD
397
 
></TR
398
 
></TABLE
399
 
></P
 
431
><DIV
 
432
CLASS="FUNCSYNOPSIS"
 
433
><P
 
434
></P
 
435
><A
 
436
NAME="AEN773"
 
437
></A
 
438
><P
 
439
><CODE
 
440
><CODE
 
441
CLASS="FUNCDEF"
 
442
>void <B
 
443
CLASS="FSFUNC"
 
444
>_dbd_internal_error_handler</B
 
445
></CODE
 
446
>(dbi_conn_t *<VAR
 
447
CLASS="PDPARAM"
 
448
>conn</VAR
 
449
>, const char *<VAR
 
450
CLASS="PDPARAM"
 
451
>errmsg</VAR
 
452
>, const int <VAR
 
453
CLASS="PDPARAM"
 
454
>errno</VAR
 
455
>);</CODE
 
456
></P
 
457
><P
 
458
></P
 
459
></DIV
400
460
><P
401
461
>Saves error message information generated by libdbi (rather than by the database or its API). If an old error message string exists, it will be freed.</P
402
462
><P
405
465
CLASS="VARIABLELIST"
406
466
><DL
407
467
><DT
408
 
><EM
409
 
>Arguments</EM
410
 
></DT
 
468
>Arguments</DT
411
469
><DD
412
470
><P
413
 
><VAR
 
471
><TT
414
472
CLASS="LITERAL"
415
 
>conn</VAR
 
473
>conn</TT
416
474
>: The target connection.</P
417
475
><P
418
 
><VAR
 
476
><TT
419
477
CLASS="LITERAL"
420
 
>errmsg</VAR
 
478
>errmsg</TT
421
479
>: The error message to store. This will be stdup'd by libdbi so it has its own copy.</P
422
480
><P
423
 
><VAR
 
481
><TT
424
482
CLASS="LITERAL"
425
 
>errno</VAR
 
483
>errno</TT
426
484
>: The error number to store.</P
427
485
></DD
428
486
></DL
429
487
></DIV
430
488
></DIV
 
489
><DIV
 
490
CLASS="SECTION"
 
491
><H2
 
492
CLASS="SECTION"
 
493
><A
 
494
NAME="INTERNAL-DBD-RESULT-CREATE-FROM-STRINGARRAY"
 
495
>2.4.7. _dbd_result_create_from_stringarray</A
 
496
></H2
 
497
><DIV
 
498
CLASS="FUNCSYNOPSIS"
 
499
><P
 
500
></P
 
501
><A
 
502
NAME="AEN796"
 
503
></A
 
504
><P
 
505
><CODE
 
506
><CODE
 
507
CLASS="FUNCDEF"
 
508
>dbi_result_t *<B
 
509
CLASS="FSFUNC"
 
510
>_dbd_result_create_from_stringarray</B
 
511
></CODE
 
512
>(dbi_conn_t *<VAR
 
513
CLASS="PDPARAM"
 
514
>conn</VAR
 
515
>, unsigned long long <VAR
 
516
CLASS="PDPARAM"
 
517
>numrows_matched</VAR
 
518
>, const char **<VAR
 
519
CLASS="PDPARAM"
 
520
>stringarray</VAR
 
521
>);</CODE
 
522
></P
 
523
><P
 
524
></P
 
525
></DIV
 
526
><P
 
527
>Creates a result object from an array of strings which contains the data of a single field for each row.</P
 
528
><P
 
529
></P
 
530
><DIV
 
531
CLASS="VARIABLELIST"
 
532
><DL
 
533
><DT
 
534
>Arguments</DT
 
535
><DD
 
536
><P
 
537
><TT
 
538
CLASS="LITERAL"
 
539
>conn</TT
 
540
>: The target connection.</P
 
541
><P
 
542
><TT
 
543
CLASS="LITERAL"
 
544
>numrows_matched</TT
 
545
>: The number of rows contained in the <CODE
 
546
CLASS="PARAMETER"
 
547
>stringarray</CODE
 
548
>.</P
 
549
><P
 
550
><TT
 
551
CLASS="LITERAL"
 
552
>stringarray</TT
 
553
>: A pointer to an array of strings with <CODE
 
554
CLASS="PARAMETER"
 
555
>numrows_matched</CODE
 
556
> members.</P
 
557
></DD
 
558
><DT
 
559
><EM
 
560
>Returns</EM
 
561
></DT
 
562
><DD
 
563
><P
 
564
>A result object, or NULL if there is an error.</P
 
565
></DD
 
566
></DL
 
567
></DIV
 
568
></DIV
 
569
><DIV
 
570
CLASS="SECTION"
 
571
><H2
 
572
CLASS="SECTION"
 
573
><A
 
574
NAME="INTERNAL-DBD-REGISTER-DRIVER-CAP"
 
575
>2.4.8. _dbd_register_driver_cap</A
 
576
></H2
 
577
><DIV
 
578
CLASS="FUNCSYNOPSIS"
 
579
><P
 
580
></P
 
581
><A
 
582
NAME="AEN826"
 
583
></A
 
584
><P
 
585
><CODE
 
586
><CODE
 
587
CLASS="FUNCDEF"
 
588
>void <B
 
589
CLASS="FSFUNC"
 
590
>_dbd_register_driver_cap</B
 
591
></CODE
 
592
>(dbi_driver_t *<VAR
 
593
CLASS="PDPARAM"
 
594
>driver</VAR
 
595
>, const char *<VAR
 
596
CLASS="PDPARAM"
 
597
>capname</VAR
 
598
>, int <VAR
 
599
CLASS="PDPARAM"
 
600
>value</VAR
 
601
>);</CODE
 
602
></P
 
603
><P
 
604
></P
 
605
></DIV
 
606
><P
 
607
>Adds a key-value pair to the list of driver capabilities.</P
 
608
><P
 
609
></P
 
610
><DIV
 
611
CLASS="VARIABLELIST"
 
612
><DL
 
613
><DT
 
614
>Arguments</DT
 
615
><DD
 
616
><P
 
617
><TT
 
618
CLASS="LITERAL"
 
619
>driver</TT
 
620
>: The target driver.</P
 
621
><P
 
622
><TT
 
623
CLASS="LITERAL"
 
624
>capname</TT
 
625
>: The key.</P
 
626
><P
 
627
><TT
 
628
CLASS="LITERAL"
 
629
>value</TT
 
630
>: The value.</P
 
631
></DD
 
632
></DL
 
633
></DIV
 
634
></DIV
 
635
><DIV
 
636
CLASS="SECTION"
 
637
><H2
 
638
CLASS="SECTION"
 
639
><A
 
640
NAME="INTERNAL-DBD-REGISTER-CONN-CAP"
 
641
>2.4.9. _dbd_register_conn_cap</A
 
642
></H2
 
643
><DIV
 
644
CLASS="FUNCSYNOPSIS"
 
645
><P
 
646
></P
 
647
><A
 
648
NAME="AEN849"
 
649
></A
 
650
><P
 
651
><CODE
 
652
><CODE
 
653
CLASS="FUNCDEF"
 
654
>void <B
 
655
CLASS="FSFUNC"
 
656
>_dbd_register_conn_cap</B
 
657
></CODE
 
658
>(dbi_conn_t *<VAR
 
659
CLASS="PDPARAM"
 
660
>conn</VAR
 
661
>, const char *<VAR
 
662
CLASS="PDPARAM"
 
663
>capname</VAR
 
664
>, int <VAR
 
665
CLASS="PDPARAM"
 
666
>value</VAR
 
667
>);</CODE
 
668
></P
 
669
><P
 
670
></P
 
671
></DIV
 
672
><P
 
673
>Adds a key-value pair to the list of connection capabilities.</P
 
674
><P
 
675
></P
 
676
><DIV
 
677
CLASS="VARIABLELIST"
 
678
><DL
 
679
><DT
 
680
>Arguments</DT
 
681
><DD
 
682
><P
 
683
><TT
 
684
CLASS="LITERAL"
 
685
>conn</TT
 
686
>: The target connection.</P
 
687
><P
 
688
><TT
 
689
CLASS="LITERAL"
 
690
>capname</TT
 
691
>: The key.</P
 
692
><P
 
693
><TT
 
694
CLASS="LITERAL"
 
695
>value</TT
 
696
>: The value.</P
 
697
></DD
 
698
></DL
 
699
></DIV
 
700
></DIV
 
701
><DIV
 
702
CLASS="SECTION"
 
703
><H2
 
704
CLASS="SECTION"
 
705
><A
 
706
NAME="INTERNAL-DBD-PARSE-DATETIME"
 
707
>2.4.10. _dbd_parse_datetime</A
 
708
></H2
 
709
><DIV
 
710
CLASS="FUNCSYNOPSIS"
 
711
><P
 
712
></P
 
713
><A
 
714
NAME="AEN872"
 
715
></A
 
716
><P
 
717
><CODE
 
718
><CODE
 
719
CLASS="FUNCDEF"
 
720
>time_t <B
 
721
CLASS="FSFUNC"
 
722
>_dbd_parse_datetime</B
 
723
></CODE
 
724
>(const char *<VAR
 
725
CLASS="PDPARAM"
 
726
>raw</VAR
 
727
>, unsigned int <VAR
 
728
CLASS="PDPARAM"
 
729
>attribs</VAR
 
730
>);</CODE
 
731
></P
 
732
><P
 
733
></P
 
734
></DIV
 
735
><P
 
736
>Parses the input time, date, or datetime string and converts the value into a time_t value.</P
 
737
><P
 
738
></P
 
739
><DIV
 
740
CLASS="VARIABLELIST"
 
741
><DL
 
742
><DT
 
743
>Arguments</DT
 
744
><DD
 
745
><P
 
746
><TT
 
747
CLASS="LITERAL"
 
748
>raw</TT
 
749
>: A zero-terminated string containing a time, date, or datetime value. Accepted formats are YYYY-MM-DD for date values, HH:MM:SS for time values, and YYYY-MM-DD HH:MM:SS for datetime values. The separators must be present, but can be any character.</P
 
750
><P
 
751
><TT
 
752
CLASS="LITERAL"
 
753
>attribs</TT
 
754
>: The field attributes of raw.</P
 
755
></DD
 
756
><DT
 
757
><EM
 
758
>Returns</EM
 
759
></DT
 
760
><DD
 
761
><P
 
762
>The numeric equivalent of the input based on UTC. In case of an error, this function returns the start of the Unix epoch.</P
 
763
></DD
 
764
></DL
 
765
></DIV
 
766
></DIV
 
767
><DIV
 
768
CLASS="SECTION"
 
769
><H2
 
770
CLASS="SECTION"
 
771
><A
 
772
NAME="INTERNAL-DBD-ESCAPE-CHARS"
 
773
>2.4.11. _dbd_escape_chars</A
 
774
></H2
 
775
><DIV
 
776
CLASS="FUNCSYNOPSIS"
 
777
><P
 
778
></P
 
779
><A
 
780
NAME="AEN896"
 
781
></A
 
782
><P
 
783
><CODE
 
784
><CODE
 
785
CLASS="FUNCDEF"
 
786
>size_t <B
 
787
CLASS="FSFUNC"
 
788
>_dbd_escape_chars</B
 
789
></CODE
 
790
>(char *<VAR
 
791
CLASS="PDPARAM"
 
792
>dest</VAR
 
793
>, const char *<VAR
 
794
CLASS="PDPARAM"
 
795
>orig</VAR
 
796
>, size_t <VAR
 
797
CLASS="PDPARAM"
 
798
>orig_size</VAR
 
799
>, const char *<VAR
 
800
CLASS="PDPARAM"
 
801
>toescape</VAR
 
802
>);</CODE
 
803
></P
 
804
><P
 
805
></P
 
806
></DIV
 
807
><P
 
808
>Escapes the characters contained in <CODE
 
809
CLASS="PARAMETER"
 
810
>toescape</CODE
 
811
> in the string <CODE
 
812
CLASS="PARAMETER"
 
813
>orig</CODE
 
814
> and puts the result into the allocated memory pointed to by <CODE
 
815
CLASS="PARAMETER"
 
816
>dest</CODE
 
817
>. The size of <CODE
 
818
CLASS="PARAMETER"
 
819
>dest</CODE
 
820
> must be at least (<CODE
 
821
CLASS="PARAMETER"
 
822
>orig_size</CODE
 
823
>*2)+5. The characters are escaped by preceding them with a backslash.</P
 
824
><P
 
825
></P
 
826
><DIV
 
827
CLASS="VARIABLELIST"
 
828
><DL
 
829
><DT
 
830
>Arguments</DT
 
831
><DD
 
832
><P
 
833
><TT
 
834
CLASS="LITERAL"
 
835
>dest</TT
 
836
>: Pointer to allocated memory which will receive the escaped string.</P
 
837
><P
 
838
><TT
 
839
CLASS="LITERAL"
 
840
>orig</TT
 
841
>: The string to escape.</P
 
842
><P
 
843
><TT
 
844
CLASS="LITERAL"
 
845
>orig_size</TT
 
846
>: The length of the string to escape.</P
 
847
><P
 
848
><TT
 
849
CLASS="LITERAL"
 
850
>toescape</TT
 
851
>: A string containing all characters that need escaping.</P
 
852
></DD
 
853
><DT
 
854
><EM
 
855
>Returns</EM
 
856
></DT
 
857
><DD
 
858
><P
 
859
>The length, in bytes, of the escaped string.</P
 
860
></DD
 
861
></DL
 
862
></DIV
 
863
></DIV
 
864
><DIV
 
865
CLASS="SECTION"
 
866
><H2
 
867
CLASS="SECTION"
 
868
><A
 
869
NAME="INTERNAL-DBD-ENCODE-BINARY"
 
870
>2.4.12. _dbd_encode_binary</A
 
871
></H2
 
872
><DIV
 
873
CLASS="FUNCSYNOPSIS"
 
874
><P
 
875
></P
 
876
><A
 
877
NAME="AEN933"
 
878
></A
 
879
><P
 
880
><CODE
 
881
><CODE
 
882
CLASS="FUNCDEF"
 
883
>size_t <B
 
884
CLASS="FSFUNC"
 
885
>_dbd_encode_binary</B
 
886
></CODE
 
887
>(const unsigned char *<VAR
 
888
CLASS="PDPARAM"
 
889
>in</VAR
 
890
>, size_t <VAR
 
891
CLASS="PDPARAM"
 
892
>n</VAR
 
893
>, unsigned char *<VAR
 
894
CLASS="PDPARAM"
 
895
>out</VAR
 
896
>);</CODE
 
897
></P
 
898
><P
 
899
></P
 
900
></DIV
 
901
><P
 
902
>Encodes a binary string as a zero-terminated string which can be safely included in a SQL query. Use <A
 
903
HREF="helperfuncs.html#INTERNAL-DBD-DECODE-BINARY"
 
904
>_dbd_decode_binary</A
 
905
> to decode the string again.</P
 
906
><P
 
907
></P
 
908
><DIV
 
909
CLASS="VARIABLELIST"
 
910
><DL
 
911
><DT
 
912
>Arguments</DT
 
913
><DD
 
914
><P
 
915
><TT
 
916
CLASS="LITERAL"
 
917
>in</TT
 
918
>: Pointer to the binary string.</P
 
919
><P
 
920
><TT
 
921
CLASS="LITERAL"
 
922
>n</TT
 
923
>: Length, in bytes, of the binary string <CODE
 
924
CLASS="PARAMETER"
 
925
>in</CODE
 
926
>.</P
 
927
><P
 
928
><TT
 
929
CLASS="LITERAL"
 
930
>out</TT
 
931
>: Pointer to allocated memory which will receive the escaped string. The size must be at least 2 +(257*<CODE
 
932
CLASS="PARAMETER"
 
933
>n</CODE
 
934
>)/254 bytes.</P
 
935
></DD
 
936
><DT
 
937
><EM
 
938
>Returns</EM
 
939
></DT
 
940
><DD
 
941
><P
 
942
>The length, in bytes, of the escaped string.</P
 
943
></DD
 
944
></DL
 
945
></DIV
 
946
></DIV
 
947
><DIV
 
948
CLASS="SECTION"
 
949
><H2
 
950
CLASS="SECTION"
 
951
><A
 
952
NAME="INTERNAL-DBD-DECODE-BINARY"
 
953
>2.4.13. _dbd_decode_binary</A
 
954
></H2
 
955
><DIV
 
956
CLASS="FUNCSYNOPSIS"
 
957
><P
 
958
></P
 
959
><A
 
960
NAME="AEN964"
 
961
></A
 
962
><P
 
963
><CODE
 
964
><CODE
 
965
CLASS="FUNCDEF"
 
966
>size_t <B
 
967
CLASS="FSFUNC"
 
968
>_dbd_decode_binary</B
 
969
></CODE
 
970
>(const unsigned char *<VAR
 
971
CLASS="PDPARAM"
 
972
>in</VAR
 
973
>, unsigned char *<VAR
 
974
CLASS="PDPARAM"
 
975
>out</VAR
 
976
>);</CODE
 
977
></P
 
978
><P
 
979
></P
 
980
></DIV
 
981
><P
 
982
>Decodes a zero-terminated string with escaped characters as created by <A
 
983
HREF="helperfuncs.html#INTERNAL-DBD-ENCODE-BINARY"
 
984
>_dbd_encode_binary</A
 
985
>.</P
 
986
><P
 
987
></P
 
988
><DIV
 
989
CLASS="VARIABLELIST"
 
990
><DL
 
991
><DT
 
992
>Arguments</DT
 
993
><DD
 
994
><P
 
995
><TT
 
996
CLASS="LITERAL"
 
997
>in</TT
 
998
>: Pointer to the input string.</P
 
999
><P
 
1000
><TT
 
1001
CLASS="LITERAL"
 
1002
>out</TT
 
1003
>: Pointer to allocated memory which will receive the unescaped string. The output string is always shorter than the input string, i.e. if the size of <CODE
 
1004
CLASS="PARAMETER"
 
1005
>out</CODE
 
1006
> is the same as the size of <CODE
 
1007
CLASS="PARAMETER"
 
1008
>in</CODE
 
1009
>, you're on the safe side. The implementation allows to decode the string in place, i.e. <CODE
 
1010
CLASS="PARAMETER"
 
1011
>out</CODE
 
1012
> may be the same as <CODE
 
1013
CLASS="PARAMETER"
 
1014
>in</CODE
 
1015
>.</P
 
1016
></DD
 
1017
><DT
 
1018
><EM
 
1019
>Returns</EM
 
1020
></DT
 
1021
><DD
 
1022
><P
 
1023
>The length, in bytes, of the unescaped binary string.</P
 
1024
></DD
 
1025
></DL
 
1026
></DIV
 
1027
></DIV
431
1028
></DIV
432
1029
><DIV
433
1030
CLASS="NAVFOOTER"
445
1042
ALIGN="left"
446
1043
VALIGN="top"
447
1044
><A
448
 
HREF="driverfuncs-dbquery.html"
 
1045
HREF="driverfuncs-publicdbquery.html"
449
1046
ACCESSKEY="P"
450
1047
>Prev</A
451
1048
></TD
473
1070
WIDTH="33%"
474
1071
ALIGN="left"
475
1072
VALIGN="top"
476
 
>Database Query Functions</TD
 
1073
>Public Database Query Functions</TD
477
1074
><TD
478
1075
WIDTH="34%"
479
1076
ALIGN="center"