refactor auto conversion
[m6w6/ext-pq] / src / php_pqconn.h
1 /*
2 +--------------------------------------------------------------------+
3 | PECL :: pq |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2013, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
11 */
12
13
14 #ifndef PHP_PQCONN_H
15 #define PHP_PQCONN_H
16
17 #define PHP_PQCONN_ASYNC 0x01
18 #define PHP_PQCONN_PERSISTENT 0x02
19
20 #include <ext/raphf/php_raphf.h>
21 #include "php_pq_callback.h"
22 #include "php_pq_params.h"
23
24 typedef struct php_pqconn {
25 PGconn *conn;
26 int (*poller)(PGconn *);
27 php_resource_factory_t factory;
28 HashTable listeners;
29 HashTable converters;
30 HashTable eventhandlers;
31 php_pq_callback_t onevent;
32 unsigned unbuffered:1;
33 unsigned default_fetch_type:2;
34 unsigned default_txn_isolation:2;
35 unsigned default_txn_readonly:1;
36 unsigned default_txn_deferrable:1;
37 unsigned default_auto_convert:16;
38 } php_pqconn_t;
39
40 typedef struct php_pqconn_object {
41 zend_object zo;
42 zend_object_value zv;
43 HashTable *prophandler;
44 php_pqconn_t *intern;
45 } php_pqconn_object_t;
46
47 typedef struct php_pqconn_resource_factory_data {
48 char *dsn;
49 long flags;
50 } php_pqconn_resource_factory_data_t;
51
52 php_resource_factory_ops_t *php_pqconn_get_resource_factory_ops(void);
53
54 zend_class_entry *php_pqconn_class_entry;
55 zend_object_value php_pqconn_create_object_ex(zend_class_entry *ce, php_pqconn_t *intern, php_pqconn_object_t **ptr TSRMLS_DC);
56 void php_pqconn_notify_listeners(php_pqconn_object_t *obj TSRMLS_DC);
57 STATUS php_pqconn_prepare(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC);
58 STATUS php_pqconn_prepare_async(zval *object, php_pqconn_object_t *obj, const char *name, const char *query, php_pq_params_t *params TSRMLS_DC);
59 STATUS php_pqconn_start_transaction(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC);
60 STATUS php_pqconn_start_transaction_async(zval *zconn, php_pqconn_object_t *conn_obj, long isolation, zend_bool readonly, zend_bool deferrable TSRMLS_DC);
61 STATUS php_pqconn_declare(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC);
62 STATUS php_pqconn_declare_async(zval *object, php_pqconn_object_t *obj, const char *decl TSRMLS_DC);
63
64 PHP_MINIT_FUNCTION(pqconn);
65 PHP_MSHUTDOWN_FUNCTION(pqconn);
66
67 #endif
68
69 /*
70 * Local variables:
71 * tab-width: 4
72 * c-basic-offset: 4
73 * End:
74 * vim600: noet sw=4 ts=4 fdm=marker
75 * vim<600: noet sw=4 ts=4
76 */