-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSQLClient.html
1948 lines (1556 loc) · 75.3 KB
/
SQLClient.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<html>
<head>
<title>SQLClient documentation</title>
</head>
<body>
<font face="palatino linotype">
<h1><a name="title$SQLClient">SQLClient documentation</a></h1>
<h3>Authors</h3>
<dl>
<dt>Richard Frith-Macdonald (<a href="mailto:[email protected]"><code>[email protected]</code></a>)</dt>
<dd>
</dd>
</dl>
<p><b>Version:</b> 1.4</p>
<p><b>Date:</b> 2004/05/07 08:16:16</p>
<p><b>Copyright:</b> (C) 2004 Free Software Foundation, Inc.</p>
<div>
<hr width="50%" align="left" />
<h3>Contents -</h3>
<ol>
<li>
<a href="#001000000000">The SQLClient library</a>
</li>
<li>
<a href="#001001000000">What is the SQLClient library?</a>
</li>
<li>
<a href="#001002000000">What backend bundles are available?</a>
</li>
<li>
<a href="#001003000000">Where can you get it? How can you install it?</a>
</li>
<li>
<a href="#002000000000">Software documentation for the SQLClient class</a>
</li>
<li>
<a href="#003000000000">Software documentation for the SQLRecord class</a>
</li>
<li>
<a href="#004000000000">Software documentation for the SQLClient(Convenience)
category</a>
</li>
<li>
<a href="#005000000000">Software documentation for the SQLClient(Logging)
category</a>
</li>
<li>
<a href="#006000000000">Software documentation for the SQLClient(Subclass)
category</a>
</li>
<li>
<a href="#007000000000">SQLClient variables</a>
</li>
</ol>
<hr width="50%" align="left" />
</div>
<h1><a name="001000000000">The SQLClient library</a></h1>
<h2><a name="001001000000">What is the SQLClient library?</a></h2>
<p>
The SQLClient library is designed to provide a simple
interface to SQL databases for GNUstep
applications. It does not attempt the sort of
abstraction provided by the much more
sophisticated GDL2 library, but rather allows
applications to directly execute SQL queries and
statements.
</p>
<p>
The major features of the SQLClient library are - </p>
<ul>
<li>
Simple API for executing queries and statements... a
variable length sequence of comma separated
strings and other objects (NSNumber, NSDate,
NSData) are concatenated into a single SQL
statement and executed.
</li>
<li>
Support multiple sumultaneous named connections to
a database server in a thread-safe manner. <br />
</li>
<li>
Support multiple simultaneous connections to
different database servers with backend driver
bundles loaded for different database engines.
Clear, simple subclassing of the abstract base class
to enable easy implementation of new backend bundles.
</li>
<li>
Configuration for all connections held in one
place and referenced by connection name for ease of
configuration control. Changes via
NSUserDefaults can even allow
reconfiguration of client instances within
a running application.
</li>
<li>
Thread safe operation... The base class supports
locking such that a single instance can be shared
between multiple threads.
</li>
</ul>
<h2><a name="001002000000">
What backend bundles are available?
</a></h2>
<p>
Current backend bundles are - </p>
<ul>
<li>
ECPG - a bundle using the embedded SQL interface for
postgres. <br /> This is based on a similar code
which has been in production use for over eighteen
months, so it should be reliable.
</li>
<li>
Postgres - a bundle using the libpq native
interface for postgres. <br /> This is the
preferred backend as it allows 'SELECT FOR
UPDATE', which the ECPG backend cannot support due
to limitations in the postgres implementation of
cursors. The code is however not as well tested as
the ECPG interface.
</li>
<li>
MySQL - a bundle using the mysqlclient library for
*recent* MySQL. <br /> I don't use MySQL... but
the test program ran successfully with a vanilla
install of the MySQL packages for recent Debian
unstable.
</li>
<li>
Oracle - a bundle using embedded SQL for Oracle.
<br /> Completely untested... may even need some
work to compile... but this *is* based on code which
was working about a year ago. <br /> No support for
BLOBs yet.
</li>
</ul>
<h2><a name="001003000000">
Where can you get it? How can you install it?
</a></h2>
<p>
The SQLClient library is currently only available via CVS
from the GNUstep CVS repository. <br /> See
<https://savannah.gnu.org/cvs/?group=gnustep>
<br /> You need to check out
<code>gnustep/dev-libs/SQLClient</code>
</p>
<p>
To build this library you must have a basic GNUstep
environment set up...
</p>
<ul>
<li>
The gnustep-make package must have been built and
installed.
</li>
<li>
The gnustep-base package must have been built and
installed.
</li>
<li>
You must hace sourced the GNUstep.sh script (from
gnustep-make) to set up environment variables
needed for building this.
</li>
<li>
If this environment is in place, all you should need to
do is run 'make' to configure and build the library,
'make install' to install it.
</li>
<li>
Then you can run the test programs.
</li>
<li>
Your most likely problems are that the configure
script may not detect the database libraries you
want... Please figure out how to modify
<code>configure.ac</code> so that it will detect the
required headers and libraries on your system, and
supply na patch.
</li>
<li>
Once the library is installed, you can include the
header file
<code><SQLClient/SQLClient.h%gt;</code> and link
your programs with the <code>SQLClient</code> library
to use it.
</li>
</ul>
<p>
Bug reports, patches, and contributions (eg a backend
bundle for a new database) should be entered on the
GNUstep project page
<http://savannah.gnu.org/projects/gnustep>
and the bug reporting page
<http://savannah.gnu.org/bugs/?group=gnustep>
</p>
<h1><a name="002000000000">
Software documentation for the SQLClient class
</a></h1>
<h2><a name="class$SQLClient">SQLClient</a> : <a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSObject.html#class$NSObject">NSObject</a></h2>
<blockquote>
<dl>
<dt><b>Declared in:</b></dt>
<dd>SQLClient.h</dd>
</dl>
</blockquote>
<p>
</p>
<p>
The SQLClient class encapsulates dynamic SQL access to
relational database systems. A shared instance
of the class is used for each database (as identified by
the name of the database), and the number of
simultanous database connections is managed
too.
</p>
<p>
</p>
<p>
SQLClient is an abstract base class... when you
create an instance of it, you are actually creating
an instance of a concrete subclass whose implementation
is loaded from a bundle.
</p>
<p>
</p>
<br/><hr width="50%" align="left" />
<h2>Instance Variables for SQLClient Class</h2>
<h3><a name="ivariable$SQLClient*_client">_client</a></h3>
@private NSString* <b>_client</b>;<br />
<p>
Identifier within backend
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_database">_database</a></h3>
@private NSString* <b>_database</b>;<br />
<p>
The configured database name/host
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_debugging">_debugging</a></h3>
@private unsigned int <b>_debugging</b>;<br />
<p>
The current debugging level
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_duration">_duration</a></h3>
@private NSTimeInterval <b>_duration</b>;<br />
<p>
<em>Description forthcoming.</em>
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_inTransaction">_inTransaction</a></h3>
@private BOOL <b>_inTransaction</b>;<br />
<p>
A flag indicating whether this instance is currently
within a transaction. This variable must
<em>only</em> be set by the
<a rel="gsdoc" href="#method$SQLClient-begin">
-begin
</a>
, <a rel="gsdoc" href="#method$SQLClient-commit">-commit</a>
or
<a rel="gsdoc" href="#method$SQLClient-rollback">
-rollback
</a>
methods. <br /> Are we inside a transaction?
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_lastOperation">_lastOperation</a></h3>
@private NSDate* <b>_lastOperation</b>;<br />
<p>
Timestamp of last operation. <br /> Maintained by
the
<a rel="gsdoc" href="#method$SQLClient-simpleExecute:">
-simpleExecute:
</a>
and
<a rel="gsdoc" href="#method$SQLClient-simpleQuery:">
-simpleQuery:
</a>
methods.
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_name">_name</a></h3>
@private NSString* <b>_name</b>;<br />
<p>
Unique identifier for instance
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_password">_password</a></h3>
@private NSString* <b>_password</b>;<br />
<p>
The configured password
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*_user">_user</a></h3>
@private NSString* <b>_user</b>;<br />
<p>
The configured user
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*connected">connected</a></h3>
@private BOOL <b>connected</b>;<br />
<p>
A flag indicating whether this instance is currently
connected to the backend database server. This
variable must <em>only</em> be set by the
<a rel="gsdoc" href="#method$SQLClient-backendConnect">
-backendConnect
</a>
or
<a rel="gsdoc" href="#method$SQLClient-backendDisconnect">
-backendDisconnect
</a>
methods.
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*extra">extra</a></h3>
@private void* <b>extra</b>;<br />
<p>
For subclass specific data
</p>
<hr width="25%" align="left" />
<h3><a name="ivariable$SQLClient*lock">lock</a></h3>
@private NSRecursiveLock* <b>lock</b>;<br />
<p>
Maintain thread-safety
</p>
<hr width="25%" align="left" />
<br/><hr width="50%" align="left" /><br/>
<b>Method summary</b>
<ul>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Convenience)-queryRecord:,...">-queryRecord:,...</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Convenience)-queryString:,...">-queryString:,...</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Convenience)-singletons:">-singletons:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)+debugging">+debugging</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)+durationLogging">+durationLogging</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)+setDebugging:">+setDebugging:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)+setDurationLogging:">+setDurationLogging:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)-debug:,...">-debug:,...</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)-debugging">-debugging</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)-durationLogging">-durationLogging</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)-setDebugging:">-setDebugging:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Logging)-setDurationLogging:">-setDurationLogging:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Subclass)-backendConnect">-backendConnect</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Subclass)-backendDisconnect">-backendDisconnect</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Subclass)-backendExecute:">-backendExecute:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Subclass)-backendQuery:">-backendQuery:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Subclass)-copyEscapedBLOB:into:">-copyEscapedBLOB:into:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Subclass)-insertBLOBs:intoStatement:length:withMarker:length:giving:">-insertBLOBs:intoStatement:length:withMarker:length:giving:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient(Subclass)-lengthOfEscapedBLOB:">-lengthOfEscapedBLOB:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient+allClients">+allClients</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient+clientWithConfiguration:name:">+clientWithConfiguration:name:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient+existingClient:">+existingClient:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient+maxConnections">+maxConnections</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient+purgeConnections:">+purgeConnections:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient+setMaxConnections:">+setMaxConnections:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-begin">-begin</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-clientName">-clientName</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-commit">-commit</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-connect">-connect</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-connected">-connected</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-database">-database</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-disconnect">-disconnect</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-execute:,...">-execute:,...</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-execute:with:">-execute:with:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-initWithConfiguration:">-initWithConfiguration:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-initWithConfiguration:name:">-initWithConfiguration:name:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-isInTransaction">-isInTransaction</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-lastOperation">-lastOperation</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-name">-name</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-password">-password</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-query:,...">-query:,...</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-query:with:">-query:with:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-quote:">-quote:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-quoteCString:">-quoteCString:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-quoteChar:">-quoteChar:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-quoteFloat:">-quoteFloat:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-quoteInteger:">-quoteInteger:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-rollback">-rollback</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-setDatabase:">-setDatabase:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-setName:">-setName:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-setPassword:">-setPassword:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-setUser:">-setUser:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-simpleExecute:">-simpleExecute:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-simpleQuery:">-simpleQuery:</a></li>
<li><a rel="gsdoc" href="SQLClient.html#method$SQLClient-user">-user</a></li>
</ul>
<hr width="50%" align="left" />
<h3><a name="method$SQLClient+allClients">allClients </a></h3>
+ (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSArray.html#class$NSArray">NSArray</a>*) <b>allClients</b>;<br />
<p>
Returns an array containing all the SQLClient
instances.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient+clientWithConfiguration:name:">clientWithConfiguration: name: </a></h3>
+ (<a rel="gsdoc" href="#class$SQLClient">SQLClient</a>*) <b>clientWithConfiguration:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSDictionary.html#class$NSDictionary">NSDictionary</a>*)config<b> name:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*)reference;<br />
<p>
Return an existing SQLClient instance (using
+existingClient:) if possible, or creates
one, initialises it using
<a rel="gsdoc" href="#method$SQLClient-initWithConfiguration:name:">
-initWithConfiguration:name:
</a>
, and returns the new instance (autoreleased). <br />
Returns <code>nil</code> on failure.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient+existingClient:">existingClient: </a></h3>
+ (<a rel="gsdoc" href="#class$SQLClient">SQLClient</a>*) <b>existingClient:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*)reference;<br />
<p>
Return an existing SQLClient instance for the
specified name if one exists, otherwise returns
<code>nil</code>.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient+maxConnections">maxConnections </a></h3>
+ (unsigned int) <b>maxConnections</b>;<br />
<p>
Return the maximum number of simultaneous database
connections permitted (set by
<a rel="gsdoc" href="#method$SQLClient+setMaxConnections:">
+setMaxConnections:
</a>
and defaults to 8)
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient+purgeConnections:">purgeConnections: </a></h3>
+ (void) <b>purgeConnections:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSDate.html#class$NSDate">NSDate</a>*)since;<br />
<p>
</p>
<p>
Use this method to reduce the number of database
connections currently active so that it is
less than the limit set by the
<a rel="gsdoc" href="#method$SQLClient+setMaxConnections:">
+setMaxConnections:
</a>
method. This mechanism is used internally by the
class to ensure that, when it is about to open a
new connection, the limit is not exceeded.
</p>
<p>
</p>
<p>
If <var>since</var> is not <code>nil</code>, then any
connection which has not been used more
recently than that date is disconnected anyway.
<br /> You can (and probably should) use this
periodically to purge idle connections, but
you can also pass a date in the future to close all
connections.
</p>
<p>
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient+setMaxConnections:">setMaxConnections: </a></h3>
+ (void) <b>setMaxConnections:</b> (unsigned int)c;<br />
<p>
</p>
<p>
Set the maximum number of simultaneous database
connections permitted (defaults to 8 and may
not be set less than 1).
</p>
<p>
</p>
<p>
This value is used by the
<a rel="gsdoc" href="#method$SQLClient+purgeConnections:">
+purgeConnections:
</a>
method to determine how many connections should be
disconnected when it is called.
</p>
<p>
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-begin">begin </a></h3>
- (void) <b>begin</b>;<br />
<p>
Start a transaction for this database client. <br />
You <strong>must</strong> match this with either a
<a rel="gsdoc" href="#method$SQLClient-commit">
-commit
</a>
or a <a rel="gsdoc" href="#method$SQLClient-rollback">-rollback</a>
.
<br />
</p>
<p>
Normally, if you execute an SQL statement
without using this method first, the
<em>autocommit</em> feature is employed, and the
statement takes effect immediately. Use of this
method permits you to execute several statements
in sequence, and only have them take effect (as a
single operation) when you call the
<a rel="gsdoc" href="#method$SQLClient-commit">
-commit
</a>
method.
</p>
<p>
</p>
<p>
NB. You must <strong>not</strong> execute an SQL
statement which would start a transaction
directly... use only this method.
</p>
<p>
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-clientName">clientName </a></h3>
- (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*) <b>clientName</b>;<br />
<p>
Return the client name for this instance. <br />
Normally this is useful only for
debugging/reporting purposes, but if
you are using multiple instances of this class in your
application, and you are using embedded SQL,
you will need to use this method to fetch the
client/connection name and store its
C-string representation in a variable
'connectionName' declared to the sql
preprocessor, so you can then have statements
of the form - 'exec sql at :connectionName...'.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-commit">commit </a></h3>
- (void) <b>commit</b>;<br />
<p>
Complete a transaction for this database client.
<br /> This <strong>must</strong> match an earlier
<a rel="gsdoc" href="#method$SQLClient-begin">
-begin
</a>
.
</p>
<p>
NB. You must <strong>not</strong> execute an SQL
statement which would commit or rollback a
transaction directly... use only this method
or the
<a rel="gsdoc" href="#method$SQLClient-rollback">
-rollback
</a>
method.
</p>
<p>
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-connect">connect </a></h3>
- (BOOL) <b>connect</b>;<br />
<p>
If the <em>connected</em> instance variable is
<code>NO</code>, this method calls
<a rel="gsdoc" href="#method$SQLClient-backendConnect">
-backendConnect
</a>
to ensure that there is a connection to the database
server established. Returns the result. <br />
Performs any necessary locking for thread safety.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-connected">connected </a></h3>
- (BOOL) <b>connected</b>;<br />
<p>
Return a flag to say whether a connection to the
database server is currently live. This is mostly
useful for debug/reporting, but is used internally
to keep track of active connections.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-database">database </a></h3>
- (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*) <b>database</b>;<br />
<p>
Return the database name for this instance (or
<code>nil</code>).
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-disconnect">disconnect </a></h3>
- (void) <b>disconnect</b>;<br />
<p>
If the <em>connected</em> instance variable is
<code>YES</code>, this method calls
<a rel="gsdoc" href="#method$SQLClient-backendDisconnect">
-backendDisconnect
</a>
to ensure that the connection to the database server is
dropped. <br /> Performs any necessary locking for
thread safety.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-execute:,...">execute: ,...</a></h3>
- (void) <b>execute:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*)stmt<b>,...</b>;<br />
<p>
Perform arbitrary operation
<em>which does not return any value.</em> <br /> This
arguments to this method are a <code>nil</code>
terminated list which are concatenated in the
manner of the *
<a rel="gsdoc" href="/usr/home/brains99/GNUstep/Local/Library/Documentation/Libraries/Server/BSSQL.html#method$BSSQL-prepare:args:">
-prepare:args:
</a>
method. <br /> Any string arguments are assumed to
have been quoted appropriately already, but non-string
arguments are automatically quoted using the
<a rel="gsdoc" href="#method$SQLClient-quote:">
-quote:
</a>
method.
<pre>
[db execute: @"UPDATE ", table, @" SET Name = ",
myName, " WHERE ID = ", myId, nil];
</pre>
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-execute:with:">execute: with: </a></h3>
- (void) <b>execute:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*)stmt<b> with:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSDictionary.html#class$NSDictionary">NSDictionary</a>*)values;<br />
<p>
Takes the statement and substitutes in
<var>values</var> from the dictionary where markup of
the format {key} is found. <br /> Passes the result to
the
<a rel="gsdoc" href="#method$SQLClient-execute:,...">
-execute:,...
</a>
method.
<pre>
[db execute: @"UPDATE {Table} SET Name = {Name} WHERE ID = {ID}"
with: values];
</pre>
Any non-string <var>values</var> in the dictionary will
be replaced by the results of the
<a rel="gsdoc" href="#method$SQLClient-quote:">
-quote:
</a>
method. <br /> The markup format may also be
{key?default} where <em>default</em> is a
string to be used if there is no value for the
<em>key</em> in the dictionary.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-initWithConfiguration:">initWithConfiguration: </a></h3>
- (id) <b>initWithConfiguration:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSDictionary.html#class$NSDictionary">NSDictionary</a>*)config;<br />
<p>
Calls
<a rel="gsdoc" href="#method$SQLClient-initWithConfiguration:name:">
-initWithConfiguration:name:
</a>
passing a <code>nil</code> reference name.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-initWithConfiguration:name:">initWithConfiguration: name: </a></h3>
- (id) <b>initWithConfiguration:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSDictionary.html#class$NSDictionary">NSDictionary</a>*)config<b> name:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*)reference;<br />
<p>
Initialise using the supplied configuration, or
if that is <code>nil</code>, try to use values from
NSUserDefaults (and automatically update
when the defaults change). <br /> Uses the
<var>reference</var> name to determine configuration
information... and if a <code>nil</code> name
is supplied, defaults to the value of the SQLClientName
as a user default string or 'Database' if no other name
is provided. <br /> If a SQLClient instance already
exists with the name used for this instance, the
receiver is deallocated and the existing instance
is retained and returned... there may only ever be one
instance for a particular <var>reference</var>
name. <br /> <br /> The <var>config</var> argument
(or the SQLClientReferences user default) is a
dictionary with names as keys and dictionaries
as its values. Configuration entries from the dictionary
corresponding to the database client are used
if possible, general entries are used otherwise. <br />
Database... is the name of the database to use, if
it is missing then 'Database' may be used instead.
<br /> User... is the name of the database user to
use, if it is missing then 'User' may be used instead.
<br /> Password... is the name of the database user
password, if it is missing then 'Password' may be
used instead. <br /> ServerType... is the name of the
backend server to be used... by convention the name
of a bundle containing the interface to that backend. If
this is missing then 'Postgres' is used. <br />
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-isInTransaction">isInTransaction </a></h3>
- (BOOL) <b>isInTransaction</b>;<br />
<p>
Return the state of the flag indicating whether the
library thinks a transaction is in progress. This
flag is normally maintained by
<a rel="gsdoc" href="#method$SQLClient-begin">
-begin
</a>
, <a rel="gsdoc" href="#method$SQLClient-commit">-commit</a>
, and
<a rel="gsdoc" href="#method$SQLClient-rollback">
-rollback
</a>
.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-lastOperation">lastOperation </a></h3>
- (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSDate.html#class$NSDate">NSDate</a>*) <b>lastOperation</b>;<br />
<p>
Returns the date/time stamp of the last database
operation performed by the receiver, or
<code>nil</code> if no operation has ever been done
by it. <br /> Simply connecting to or disconnecting from
the databsse does not count as an operation.
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-name">name </a></h3>
- (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*) <b>name</b>;<br />
<p>
Return the database reference name for this instance
(or <code>nil</code>).
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-password">password </a></h3>
- (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*) <b>password</b>;<br />
<p>
Return the database password for this instance (or
<code>nil</code>).
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-query:,...">query: ,...</a></h3>
- (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSArray.html#class$NSMutableArray">NSMutableArray</a>*) <b>query:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*)stmt<b>,...</b>;<br />
<p>
</p>
<p>
Perform arbitrary query
<em>which returns values.</em>
</p>
<p>
</p>
<p>
This method has at least one argument, the string
starting the statement to be executed (which
must have the prefix 'select ').
</p>
<p>
</p>
<p>
Additional arguments are a <code>nil</code>
terminated list which also be strings, and
these are appended to the statement. <br /> Any
string arguments are assumed to have been quoted
appropriately already, but non-string
arguments are automatically quoted using the
<a rel="gsdoc" href="#method$SQLClient-quote:">
-quote:
</a>
method.
</p>
<p>
<pre>
result = [db query: @"SELECT Name FROM ", table, nil];
</pre>
</p>
<p>
Upon error, an exception is raised. </p>
<p>
</p>
<p>
The query returns an array of records (each of which
is represented by an SQLRecord object).
</p>
<p>
</p>
<p>
Each SQLRecord object contains one or more fields,
in the order in which they occurred in the query.
Fields may also be retrieved by name.
</p>
<p>
</p>
<p>
NULL field items are returned as NSNull objects. </p>
<p>
</p>
<p>
Most other field items are returned as NSString
objects.
</p>
<p>
</p>
<p>
Date and timestamp field items are returned as
NSDate objects.
</p>
<p>
</p>
<hr width="25%" align="left" />
<h3><a name="method$SQLClient-query:with:">query: with: </a></h3>
- (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSArray.html#class$NSMutableArray">NSMutableArray</a>*) <b>query:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSString.html#class$NSString">NSString</a>*)stmt<b> with:</b> (<a rel="gsdoc" href="/usr/home/brains99/GNUstep/System/Library/Documentation/Developer/Base/Reference/NSDictionary.html#class$NSDictionary">NSDictionary</a>*)values;<br />
<p>
Takes the query statement and substitutes in
<var>values</var> from the dictionary where markup of