-
Notifications
You must be signed in to change notification settings - Fork 3
/
pq.stub.php
2357 lines (2357 loc) · 65.6 KB
/
pq.stub.php
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
<?php
/**
* This is a modern binding to the mature [libpq](http://www.postgresql.org/docs/current/static/libpq.html), the official PostgreSQL C-client library.
*
* ### Highlights:
*
* * Nearly 100% support for [asynchronous usage](pq/Connection/: Asynchronous Usage).
* * Extended [type support by pg_type](pq/Types/: Overview).
* * Fetching simple [multi-dimensional array maps](pq/Result/map).
* * Working [Gateway implementation](https://bitbucket.org/m6w6/pq-gateway).
*/
namespace pq;
use pq;
/**
* Fast import/export using COPY.
*/
class COPY {
/**
* Start a COPY operation from STDIN to the PostgreSQL server.
*/
const FROM_STDIN = 0;
/**
* Start a COPY operation from the server to STDOUT.
*/
const TO_STDOUT = 1;
/**
* The connection to the PostgreSQL server.
*
* @public
* @readonly
* @var \pq\Connection
*/
public $connection;
/**
* The expression of the COPY statement used to start the operation.
*
* @public
* @readonly
* @var string
*/
public $expression;
/**
* The drection of the COPY operation (pq\COPY::FROM_STDIN or pq\COPY::TO_STDOUT).
*
* @public
* @readonly
* @var int
*/
public $direction;
/**
* Any additional options used to start the COPY operation.
*
* @public
* @readonly
* @var string
*/
public $options;
/**
* Start a COPY operation.
*
* @param \pq\Connection $conn The connection to use for the COPY operation.
* @param string $expression The expression generating the data to copy.
* @param int $direction Data direction (pq\COPY::FROM_STDIN or pq\COPY::TO_STDOUT).
* @param string $options Any COPY options (see the [official PostgreSQL documentation](http://www.postgresql.org/docs/current/static/sql-copy.html) for details.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function __construct(\pq\Connection $conn, string $expression, int $direction, string $options = NULL) {}
/**
* End the COPY operation to the server during pq\Result::COPY_IN state.
*
* @param string $error If set, the COPY operation will abort with provided message.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function end(string $error = NULL) {}
/**
* Receive data from the server during pq\Result::COPY_OUT state.
*
* @param string $data Data read from the server.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @return bool success.
*/
function get(string &$data) {}
/**
* Send data to the server during pq\Result::COPY_IN state.
*
* @param string $data Data to send to the server.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function put(string $data) {}
}
/**
* Request cancellation of an asynchronous query.
*/
class Cancel {
/**
* The connection to cancel the query on.
*
* @public
* @readonly
* @var \pq\Connection
*/
public $connection;
/**
* Create a new cancellation request for an [asynchronous](pq/Connection/: Asynchronous Usage) query.
*
* @param \pq\Connection $conn The connection to request cancellation on.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function __construct(\pq\Connection $conn) {}
/**
* Perform the cancellation request.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function cancel() {}
}
/**
* The connection to the PostgreSQL server.
*
* See the [General Usage](pq/Connection/: General Usage) page for an introduction on how to use this class.
*/
class Connection {
/**
* (Re-)open a persistent connection.
*/
const PERSISTENT = 2;
/**
* If the connection is not already open, perform the connection attempt [asynchronously](pq/Connection/: Asynchronous Usage).
*/
const ASYNC = 1;
/**
* Everything well; if a connection has been newly and synchronously created, the connection will always have this status right after creation.
*/
const OK = 0;
/**
* Broken connection; consider pq\Connection::reset() or recreation.
*/
const BAD = 1;
/**
* Waiting for connection to be made.
*/
const STARTED = 2;
/**
* Connection okay; waiting to send.
*/
const MADE = 3;
/**
* Waiting for a response from the server.
*/
const AWAITING_RESPONSE = 4;
/**
* Received authentication; waiting for backend start-up to finish.
*/
const AUTH_OK = 5;
/**
* Negotiating SSL encryption.
*/
const SSL_STARTUP = 7;
/**
* Negotiating environment-driven parameter settings.
*/
const SETENV = 6;
/**
* No active transaction.
*/
const TRANS_IDLE = 0;
/**
* A transaction command is in progress.
*/
const TRANS_ACTIVE = 1;
/**
* Idling in a valid transaction block.
*/
const TRANS_INTRANS = 2;
/**
* Idling in a failed transaction block.
*/
const TRANS_INERROR = 3;
/**
* Bad connection.
*/
const TRANS_UNKNOWN = 4;
/**
* The connection procedure has failed.
*/
const POLLING_FAILED = 0;
/**
* Select for read-readiness.
*/
const POLLING_READING = 1;
/**
* Select for write-readiness.
*/
const POLLING_WRITING = 2;
/**
* The connection has been successfully made.
*/
const POLLING_OK = 3;
/**
* Register the event handler for notices.
*/
const EVENT_NOTICE = 'notice';
/**
* Register the event handler for any created results.
*/
const EVENT_RESULT = 'result';
/**
* Register the event handler for connection resets.
*/
const EVENT_RESET = 'reset';
/**
* A [connection status constant](pq/Connection#Connection.Status:) value.
*
* @public
* @readonly
* @var int
*/
public $status;
/**
* A [transaction status constant](pq/Connection#Transaction.Status:) value.
*
* @public
* @readonly
* @var int
*/
public $transactionStatus;
/**
* The server socket resource.
*
* @public
* @readonly
* @var resource
*/
public $socket;
/**
* Whether the connection is busy with [asynchronous operations](pq/Connection/: Asynchronous Usage).
*
* @public
* @readonly
* @var bool
*/
public $busy;
/**
* Any error message on failure.
*
* @public
* @readonly
* @var string
*/
public $errorMessage;
/**
* List of registered event handlers.
*
* @public
* @readonly
* @var array
*/
public $eventHandlers;
/**
* Connection character set.
*
* @public
* @var string
*/
public $encoding = NULL;
/**
* Whether to fetch [asynchronous](pq/Connection/: Asynchronous Usage) results in unbuffered mode, i.e. each row generates a distinct pq\Result.
*
* @public
* @var bool
*/
public $unbuffered = FALSE;
/**
* Whether to set the underlying socket nonblocking, useful for asynchronous handling of writes. See also pq\Connection::flush().
*
* ### Connection Information:
*
* @public
* @var bool
*/
public $nonblocking = FALSE;
/**
* The database name of the connection.
*
* @public
* @readonly
* @var string
*/
public $db;
/**
* The user name of the connection.
*
* @public
* @readonly
* @var string
*/
public $user;
/**
* The password of the connection.
*
* @public
* @readonly
* @var string
*/
public $pass;
/**
* The server host name of the connection.
*
* @public
* @readonly
* @var string
*/
public $host;
/**
* The port of the connection.
*
* @public
* @readonly
* @var string
*/
public $port;
/**
* The command-line options passed in the connection request.
*
* ### Inheritable Defaults:
*
* @public
* @readonly
* @var string
*/
public $options;
/**
* Default fetch type for future pq\Result instances.
*
* @public
* @var int
*/
public $defaultFetchType = \pq\Result::FETCH_ARRAY;
/**
* Default conversion bitmask for future pq\Result instances.
*
* @public
* @var int
*/
public $defaultAutoConvert = \pq\Result::CONV_ALL;
/**
* Default transaction isolation level for future pq\Transaction instances.
*
* @public
* @var int
*/
public $defaultTransactionIsolation = \pq\Transaction::READ_COMMITTED;
/**
* Default transaction readonlyness for future pq\Transaction instances.
*
* @public
* @var bool
*/
public $defaultTransactionReadonly = FALSE;
/**
* Default transaction deferrability for future pq\Transaction instances.
*
* @public
* @var bool
*/
public $defaultTransactionDeferrable = FALSE;
/**
* Create a new PostgreSQL connection.
* See also [General Usage](pq/Connection/: General Usage).
*
* @param string $dsn A ***connection string*** as described [in the PostgreSQL documentation](http://www.postgresql.org/docs/current/static/libpq-connect.html#LIBPQ-CONNSTRING).
* @param int $flags See [connection flag constants](pq/Connection#Connection.Flags:).
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function __construct(string $dsn = "", int $flags = 0) {}
/**
* Declare a cursor for a query.
*
* @param string $name The identifying name of the cursor.
* @param int $flags Any combination of pq\Cursor constants.
* @param string $query The query for which to open a cursor.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\RuntimeException
* @throws \pq\Exception\BadMethodCallException
* @return \pq\Cursor an open cursor instance.
*/
function declare(string $name, int $flags, string $query) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) declare a cursor for a query.
*
* > ***NOTE***:
* If pq\Connection::$unbuffered is TRUE, each call to pq\Connection::getResult() will generate a distinct pq\Result containing exactly one row.
*
* @param string $name The identifying name of the cursor.
* @param int $flags Any combination of pq\Cursor constants.
* @param string $query The query for which to open a cursor.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\RuntimeException
* @throws \pq\Exception\BadMethodCallException
* @return \pq\Cursor an open cursor instance.
*/
function declareAsync(string $name, int $flags, string $query) {}
/**
* Escape binary data for use within a query with the type bytea.
*
* > ***NOTE:***
* The result is not wrapped in single quotes.
*
* @param string $binary The binary data to escape.
* @throws \pq\Exception\BadMethodCallException
* @return string|FALSE string the escaped binary data.
* or FALSE if escaping fails.
*/
function escapeBytea(string $binary) {}
/**
* [Execute one or multiple SQL queries](pq/Connection/: Executing Queries) on the connection.
*
* > ***NOTE:***
* > Only the last result will be returned, if the query string contains more than one SQL query.
*
* @param string $query The queries to send to the server, separated by semi-colon.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @throws \pq\Exception\DomainException
* @return \pq\Result
*/
function exec(string $query) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) [execute an SQL query](pq/Connection: Executing Queries) on the connection.
*
* > ***NOTE***:
* If pq\Connection::$unbuffered is TRUE, each call to pq\Connection::getResult() will generate a distinct pq\Result containing exactly one row.
*
* @param string $query The query to send to the server.
* @param callable $callback as function(pq\Result $res)
* The callback to execute when the query finishes.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function execAsync(string $query, callable $callback = NULL) {}
/**
* [Execute an SQL query](pq/Connection: Executing Queries) with properly escaped parameters substituted.
*
* @param string $query The query to execute.
* @param array $params The parameter list to substitute.
* @param array $types Corresponding list of type OIDs for the parameters.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\RuntimeException
* @throws \pq\Exception\DomainException
* @return \pq\Result
*/
function execParams(string $query, array $params, array $types = NULL) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) [execute an SQL query](pq/Connection: Executing Queries) with properly escaped parameters substituted.
*
* > ***NOTE***:
* If pq\Connection::$unbuffered is TRUE, each call to pq\Connection::getResult() will generate a distinct pq\Result containing exactly one row.
*
* @param string $query The query to execute.
* @param array $params The parameter list to substitute.
* @param array $types Corresponding list of type OIDs for the parameters.
* @param callable $cb as function(\pq\Result $res) : void
* Result handler callback.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\RuntimeException
* @throws \pq\Exception\BadMethodCallException
*/
function execParamsAsync(string $query, array $params, array $types = NULL, callable $cb = NULL) {}
/**
* Flush pending writes on the connection.
* Call after sending any command or data on a nonblocking connection.
*
* If it returns FALSE, wait for the socket to become read or write-ready.
* If it becomes write-ready, call pq\Connection::flush() again.
* If it becomes read-ready, call pq\Connection::poll(), then call pq\Connection::flush() again.
* Repeat until pq\Connection::flush() returns TRUE.
*
* > ***NOTE:***
* > This method was added in v1.1.0, resp. v2.1.0.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\RuntimeException
* @return bool whether everything has been flushed.
*/
function flush() {}
/**
* Fetch the result of an [asynchronous](pq/Connection/: Asynchronous Usage) query.
*
* If the query hasn't finished yet, the call will block until the result is available.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @return NULL|\pq\Result NULL if there has not been a query
* or \pq\Result when the query has finished
*/
function getResult() {}
/**
* Listen on $channel for notifications.
* See pq\Connection::unlisten().
*
* @param string $channel The channel to listen on.
* @param callable $listener as function(string $channel, string $message, int $pid)
* A callback automatically called whenever a notification on $channel arrives.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function listen(string $channel, callable $listener) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) start listening on $channel for notifcations.
* See pq\Connection::listen().
*
* @param string $channel The channel to listen on.
* @param callable $listener as function(string $channel, string $message, int $pid)
* A callback automatically called whenever a notification on $channel arrives.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function listenAsync(string $channel, callable $listener) {}
/**
* Notify all listeners on $channel with $message.
*
* @param string $channel The channel to notify.
* @param string $message The message to send.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function notify(string $channel, string $message) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) start notifying all listeners on $channel with $message.
*
* @param string $channel The channel to notify.
* @param string $message The message to send.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function notifyAsync(string $channel, string $message) {}
/**
* Stops listening for an event type.
*
* @param string $event Any pq\Connection::EVENT_*.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @return bool success.
*/
function off(string $event) {}
/**
* Listen for an event.
*
* @param string $event Any pq\Connection::EVENT_*.
* @param callable $callback as function(pq\Connection $c[, pq\Result $r)
* The callback to invoke on event.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @return int number of previously attached event listeners.
*/
function on(string $event, callable $callback) {}
/**
* Poll an [asynchronously](pq/Connection/: Asynchronous Usage) operating connection.
* See pq\Connection::resetAsync() for an usage example.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\RuntimeException
* @throws \pq\Exception\BadMethodCallException
* @return int pq\Connection::POLLING_* constant
*/
function poll() {}
/**
* Prepare a named statement for later execution with pq\Statement::execute().
*
* @param string $name The identifying name of the prepared statement.
* @param string $query The query to prepare.
* @param array $types An array of type OIDs for the substitution parameters.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @return \pq\Statement a prepared statement instance.
*/
function prepare(string $name, string $query, array $types = NULL) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) prepare a named statement for later execution with pq\Statement::exec().
*
* > ***NOTE***:
* If pq\Connection::$unbuffered is TRUE, each call to pq\Connection::getResult() will generate a distinct pq\Result containing exactly one row.
*
* @param string $name The identifying name of the prepared statement.
* @param string $query The query to prepare.
* @param array $types An array of type OIDs for the substitution parameters.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @return \pq\Statement a prepared statement instance.
*/
function prepareAsync(string $name, string $query, array $types = NULL) {}
/**
* Quote a string for safe use in a query.
* The result is truncated at any zero byte and wrapped in single quotes.
*
* > ***NOTE:***
* Beware of matching character encodings.
*
* @param string $payload The payload to quote for use in a query.
* @throws \pq\Exception\BadMethodCallException
* @return string|FALSE string a single-quote wrapped string safe for literal use in a query.
* or FALSE if quoting fails.
*/
function quote(string $payload) {}
/**
* Quote an identifier for safe usage as name.
*
* > ***NOTE:***
* Beware of case-sensitivity.
*
* @param string $name The name to quote.
* @throws \pq\Exception\BadMethodCallException
* @return string|FALSE string the quoted identifier.
* or FALSE if quoting fails.
*/
function quoteName(string $name) {}
/**
* Attempt to reset a possibly broken connection to a working state.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function reset() {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) reset a possibly broken connection to a working state.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function resetAsync() {}
/**
* Set a data type converter.
*
* @param \pq\Converter $converter An instance implementing pq\Converter.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
*/
function setConverter(\pq\Converter $converter) {}
/**
* Begin a transaction.
*
* @param int $isolation Any pq\Transaction isolation level constant
* (defaults to pq\Connection::$defaultTransactionIsolation).
* @param bool $readonly Whether the transaction executes only reads
* (defaults to pq\Connection::$defaultTransactionReadonly).
* @param bool $deferrable Whether the transaction is deferrable
* (defaults to pq\Connection::$defaultTransactionDeferrable).
*
* > ***NOTE:***
* A transaction can only be deferrable if it also is readonly and serializable.
* See the official [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/sql-set-transaction.html) for further information.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @return \pq\Transaction a begun transaction instance.
*/
function startTransaction(int $isolation = \pq\Transaction::READ_COMMITTED, bool $readonly = FALSE, bool $deferrable = FALSE) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) begin a transaction.
*
* @param int $isolation Any pq\Transaction isolation level constant
* (defaults to pq\Connection::$defaultTransactionIsolation).
* @param bool $readonly Whether the transaction executes only reads
* (defaults to pq\Connection::$defaultTransactionReadonly).
* @param bool $deferrable Whether the transaction is deferrable
* (defaults to pq\Connection::$defaultTransactionDeferrable).
*
* > ***NOTE:***
* A transaction can only be deferrable if it also is readonly and serializable.
* See the official [PostgreSQL documentation](http://www.postgresql.org/docs/current/static/sql-set-transaction.html) for further information.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @return \pq\Transaction an asynchronously begun transaction instance.
*/
function startTransactionAsync(int $isolation = \pq\Transaction::READ_COMMITTED, bool $readonly = FALSE, bool $deferrable = FALSE) {}
/**
* Trace protocol communication with the server.
*
* > ***NOTE:***
* Calling pq\Connection::trace() without argument or NULL stops tracing.
*
* @param resource $stream The resource to which the protocol trace will be output.
* (The stream must be castable to STDIO).
* @throws \pq\Exception\BadMethodCallException
* @return bool success.
*/
function trace($stream = NULL) {}
/**
* Unescape bytea data retrieved from the server.
*
* @param string $bytea Bytea data retrieved from the server.
* @throws \pq\Exception\BadMethodCallException
* @return string|FALSE string unescaped binary data.
* or FALSE if unescaping fails.
*/
function unescapeBytea(string $bytea) {}
/**
* Stop listening for notifications on channel $channel.
* See pq\Connection::listen().
*
* @param string $channel The name of a channel which is currently listened on.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function unlisten(string $channel) {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) stop listening for notifications on channel $channel.
* See pq\Connection::unlisten() and pq\Connection::listenAsync().
*
* @param string $channel The name of a channel which is currently listened on.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function unlistenAsync(string $channel) {}
/**
* Stop applying a data type converter.
*
* @param \pq\Converter $converter A converter previously set with pq\Connection::setConverter().
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
*/
function unsetConverter(\pq\Converter $converter) {}
}
/**
* Interface for type conversions.
*/
interface Converter {
/**
* Convert a string received from the PostgreSQL server back to a PHP type.
*
* @param string $data String data received from the server.
* @param int $type The type OID of the data. Irrelevant for single-type converters.
* @return mixed the value converted to a PHP type.
*/
function convertFromString(string $data, int $type);
/**
* Convert a value to a string for use in a query.
*
* @param mixed $value The PHP value which should be converted to a string.
* @param int $type The type OID the converter should handle. Irrelevant for singly-type converters.
* @return string a textual representation of the value accepted by the PostgreSQL server.
*/
function convertToString($value, int $type);
/**
* Announce which types the implementing converter can handle.
*
* @return array OIDs of handled types.
*/
function convertTypes();
}
/**
* Declare a cursor.
*/
class Cursor {
/**
* Causes the cursor to return data in binary rather than in text format. You probably do not want to use that.
*/
const BINARY = 1;
/**
* The data returned by the cursor should be unaffected by updates to the tables underlying the cursor that take place after the cursor was opened.
*/
const INSENSITIVE = 2;
/**
* The cursor should stay usable after the transaction that created it was successfully committed.
*/
const WITH_HOLD = 4;
/**
* Force that rows can be retrieved in any order from the cursor.
*/
const SCROLL = 16;
/**
* Force that rows are only retrievable in sequiential order.
*
* > ***NOTE:***
* See the [notes in the official PostgreSQL documentation](http://www.postgresql.org/docs/current/static/sql-declare.html#SQL-DECLARE-NOTES) for more information.
*/
const NO_SCROLL = 32;
/**
* The connection the cursor was declared on.
*
* @public
* @readonly
* @var \pq\Connection
*/
public $connection;
/**
* The identifying name of the cursor.
*
* @public
* @readonly
* @var string
*/
public $name;
/**
* Declare a cursor.
* See pq\Connection::declare().
*
* @param \pq\Connection $connection The connection on which the cursor should be declared.
* @param string $name The name of the cursor.
* @param int $flags See pq\Cursor constants.
* @param string $query The query for which the cursor should be opened.
* @param bool $async Whether to declare the cursor [asynchronously](pq/Connection/: Asynchronous Usage).
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function __construct(\pq\Connection $connection, string $name, int $flags, string $query, bool $async) {}
/**
* Close an open cursor.
* This is a no-op on already closed cursors.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function close() {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) close an open cursor.
* See pq\Cursor::close().
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function closeAsync() {}
/**
* Fetch rows from the cursor.
* See pq\Cursor::move().
*
* @param string $spec What to fetch.
*
* ### Fetch argument:
*
* FETCH and MOVE usually accepts arguments like the following, where `count` is the number of rows:
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @return \pq\Result the fetched row(s).
*/
function fetch(string $spec = "1") {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) fetch rows from the cursor.
* See pq\Cursor::fetch().
*
* @param string $spec What to fetch.
* @param callable $callback as function(pq\Result $res)
* A callback to execute when the result is ready.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function fetchAsync(string $spec = "1", callable $callback = NULL) {}
/**
* Move the cursor.
* See pq\Cursor::fetch().
*
* @param string $spec What to fetch.
*
* ### Fetch argument:
*
* FETCH and MOVE usually accepts arguments like the following, where `count` is the number of rows:
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
* @return \pq\Result command status.
*/
function move(string $spec = "1") {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) move the cursor.
* See pq\Cursor::move().
*
* @param string $spec What to fetch.
* @param callable $callback as function(pq\Result $res)
* A callback to execute when the command completed.
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function moveAsync(string $spec = "1", callable $callback = NULL) {}
/**
* Reopen a cursor.
* This is a no-op on already open cursors.
*
* > ***NOTE:***
* Only cursors closed by pq\Cursor::close() will be reopened.
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function open() {}
/**
* [Asynchronously](pq/Connection/: Asynchronous Usage) reopen a cursor.
* See pq\Cursor::open().
*
* @throws \pq\Exception\InvalidArgumentException
* @throws \pq\Exception\BadMethodCallException
* @throws \pq\Exception\RuntimeException
*/
function openAsync() {}
}
/**
* A simple DateTime wrapper with predefined formats which supports stringification and JSON.
*/
class DateTime extends \DateTime implements \JsonSerializable {
/**
* The default format of any date/time type automatically converted by pq\Result (depends on the actual type of the column).
*
* @public
* @var string
*/
public $format = "Y-m-d H:i:s.uO";
/**
* Stringify the DateTime instance according to pq\DateTime::$format.
*
* @return string the DateTime as string.
*/
function __toString() {}
/**
* Serialize to JSON.
* Alias of pq\DateTime::__toString().
*
* @return string the DateTime stringified according to pq\DateTime::$format.
*/
function jsonSerialize() {}
}
/**
* A base interface for all pq\Exception classes.
*/
interface Exception {
/**
* An invalid argument was passed to a method (pq\Exception\InvalidArgumentException).
*/
const INVALID_ARGUMENT = 0;
/**
* A runtime exception occurred (pq\Exception\RuntimeException).
*/
const RUNTIME = 1;
/**
* The connection failed (pq\Exception\RuntimeException).
*/
const CONNECTION_FAILED = 2;
/**
* An input/output exception occurred (pq\Exception\RuntimeException).
*/
const IO = 3;
/**
* Escaping an argument or identifier failed internally (pq\Exception\RuntimeException).
*/
const ESCAPE = 4;
/**
* An object's constructor was not called (pq\Exception\BadMethodCallException).
*/
const UNINITIALIZED = 6;
/**
* Calling this method was not expected (yet) (pq\Exception\BadMethodCallException).
*/
const BAD_METHODCALL = 5;
/**
* SQL syntax error (pq\Exception\DomainException).
*/
const SQL = 8;
/**
* Implementation domain error (pq\Exception\DomainException).
*/
const DOMAIN = 7;
}
/**
* A *large object*.
*
* > ***NOTE:***
* Working with *large objects* requires an active transaction.
*/