test
[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 typedef enum php_pqres_fetch {
18 PHP_PQRES_FETCH_ARRAY,
19 PHP_PQRES_FETCH_ASSOC,
20 PHP_PQRES_FETCH_OBJECT
21 } php_pqres_fetch_t;
22
23 typedef struct php_pqres_iterator {
24 zend_object_iterator zi;
25 zval *current_val;
26 unsigned index;
27 php_pqres_fetch_t fetch_type;
28 } php_pqres_iterator_t;
29
30 typedef struct php_pqres {
31 PGresult *res;
32 php_pqres_iterator_t *iter;
33 HashTable bound;
34 } php_pqres_t;
35
36 typedef struct php_pqres_object {
37 zend_object zo;
38 zend_object_value zv;
39 HashTable *prophandler;
40 php_pqres_t *intern;
41 } php_pqres_object_t;
42
43 STATUS php_pqres_success(PGresult *res TSRMLS_DC);
44 void php_pqres_init_instance_data(PGresult *res, php_pqres_object_t **ptr TSRMLS_DC);
45 zval *php_pqres_row_to_zval(PGresult *res, unsigned row, php_pqres_fetch_t fetch_type, zval **data_ptr TSRMLS_DC);
46
47 #include "php_pq_object.h"
48 #include "php_pqconn_event.h"
49 #define PHP_PQclear(_r) do { \
50 php_pqres_object_t *_o = PQresultInstanceData((_r), php_pqconn_event); \
51 if (_o) { \
52 php_pq_object_delref(_o TSRMLS_CC); \
53 } else { \
54 PQclear(_r); \
55 } \
56 } while(0)
57
58 zend_class_entry *php_pqres_class_entry;
59 zend_object_value php_pqres_create_object_ex(zend_class_entry *ce, php_pqres_t *intern, php_pqres_object_t **ptr TSRMLS_DC);
60
61 PHP_MINIT_FUNCTION(pqres);
62
63 #endif
64
65 /*
66 * Local variables:
67 * tab-width: 4
68 * c-basic-offset: 4
69 * End:
70 * vim600: noet sw=4 ts=4 fdm=marker
71 * vim<600: noet sw=4 ts=4
72 */