79507fdf1fa9ca5b1aac9c77cf930e98786cedfc
[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
19 typedef enum php_pqres_fetch {
20 PHP_PQRES_FETCH_ARRAY,
21 PHP_PQRES_FETCH_ASSOC,
22 PHP_PQRES_FETCH_OBJECT
23 } php_pqres_fetch_t;
24
25 #define PHP_PQRES_CONV_BOOL 0x0001
26 #define PHP_PQRES_CONV_INT 0x0002
27 #define PHP_PQRES_CONV_FLOAT 0x0004
28 #define PHP_PQRES_CONV_BYTEA 0x0008
29 #define PHP_PQRES_CONV_SCALAR 0x000f
30 #define PHP_PQRES_CONV_ARRAY 0x0010
31 #define PHP_PQRES_CONV_DATETIME 0x0020
32 #define PHP_PQRES_CONV_JSON 0x0100
33 #define PHP_PQRES_CONV_ALL 0xffff
34
35 typedef struct php_pqres_iterator {
36 zend_object_iterator zi;
37 zval current_val;
38 unsigned index;
39 php_pqres_fetch_t fetch_type;
40 } php_pqres_iterator_t;
41
42 typedef struct php_pqres {
43 PGresult *res;
44 php_pqres_iterator_t *iter;
45 HashTable bound;
46 HashTable converters;
47 unsigned auto_convert;
48 php_pqres_fetch_t default_fetch_type;
49 } php_pqres_t;
50
51 typedef struct php_pqres_object {
52 PHP_PQ_OBJ_DECL(php_pqres_t *)
53 } php_pqres_object_t;
54
55 extern ZEND_RESULT_CODE php_pqres_success(PGresult *res);
56 extern php_pqres_object_t *php_pqres_init_instance_data(PGresult *res, php_pqconn_object_t *obj);
57 extern zval *php_pqres_row_to_zval(PGresult *res, unsigned row, php_pqres_fetch_t fetch_type, zval *data);
58 extern zval *php_pqres_typed_zval(php_pqres_t *res, Oid typ, zval *zv);
59 extern php_pqres_fetch_t php_pqres_fetch_type(php_pqres_t *res);
60
61 #include "php_pq_object.h"
62 #include "php_pqconn_event.h"
63
64 extern zend_class_entry *php_pqres_class_entry;
65 extern php_pqres_object_t *php_pqres_create_object_ex(zend_class_entry *ce, php_pqres_t *intern);
66
67 extern PHP_MINIT_FUNCTION(pqres);
68 extern PHP_MSHUTDOWN_FUNCTION(pqres);
69
70 #endif
71
72 /*
73 * Local variables:
74 * tab-width: 4
75 * c-basic-offset: 4
76 * End:
77 * vim600: noet sw=4 ts=4 fdm=marker
78 * vim<600: noet sw=4 ts=4
79 */