add default propoerties to connection
[m6w6/ext-pq] / src / php_pqres.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_PQRES_H
15 #define PHP_PQRES_H
16
17 #include "php_pqconn.h"
18 typedef enum php_pqres_fetch {
19 PHP_PQRES_FETCH_ARRAY,
20 PHP_PQRES_FETCH_ASSOC,
21 PHP_PQRES_FETCH_OBJECT
22 } php_pqres_fetch_t;
23
24 typedef struct php_pqres_iterator {
25 zend_object_iterator zi;
26 zval *current_val;
27 unsigned index;
28 php_pqres_fetch_t fetch_type;
29 } php_pqres_iterator_t;
30
31 typedef struct php_pqres {
32 PGresult *res;
33 php_pqres_iterator_t *iter;
34 HashTable bound;
35 HashTable converters;
36 unsigned default_fetch_type:2;
37 } php_pqres_t;
38
39 typedef struct php_pqres_object {
40 zend_object zo;
41 zend_object_value zv;
42 HashTable *prophandler;
43 php_pqres_t *intern;
44 } php_pqres_object_t;
45
46 STATUS php_pqres_success(PGresult *res TSRMLS_DC);
47 void php_pqres_init_instance_data(PGresult *res, php_pqconn_object_t *obj, php_pqres_object_t **ptr TSRMLS_DC);
48 zval *php_pqres_row_to_zval(PGresult *res, unsigned row, php_pqres_fetch_t fetch_type, zval **data_ptr TSRMLS_DC);
49
50 #include "php_pq_object.h"
51 #include "php_pqconn_event.h"
52 #define PHP_PQclear(_r) do { \
53 php_pqres_object_t *_o = PQresultInstanceData((_r), php_pqconn_event); \
54 if (_o) { \
55 php_pq_object_delref(_o TSRMLS_CC); \
56 } else { \
57 PQclear(_r); \
58 } \
59 } while(0)
60
61 zend_class_entry *php_pqres_class_entry;
62 zend_object_value php_pqres_create_object_ex(zend_class_entry *ce, php_pqres_t *intern, php_pqres_object_t **ptr TSRMLS_DC);
63
64 PHP_MINIT_FUNCTION(pqres);
65 PHP_MSHUTDOWN_FUNCTION(pqres);
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 */