xref: /PHP-5.3/ext/sqlite3/php_sqlite3_structs.h (revision a2045ff3)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 5                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1997-2013 The PHP Group                                |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 3.01 of the PHP license,      |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.php.net/license/3_01.txt                                  |
11    | If you did not receive a copy of the PHP license and are unable to   |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@php.net so we can mail you a copy immediately.               |
14    +----------------------------------------------------------------------+
15    | Authors: Scott MacVicar <scottmac@php.net>                           |
16    +----------------------------------------------------------------------+
17 */
18 
19 /* $Id$ */
20 
21 #ifndef PHP_SQLITE_STRUCTS_H
22 #define PHP_SQLITE_STRUCTS_H
23 
24 #include <sqlite3.h>
25 
26 /* for backwards compatability reasons */
27 #ifndef SQLITE_OPEN_READONLY
28 #define SQLITE_OPEN_READONLY 0x00000001
29 #endif
30 
31 #ifndef SQLITE_OPEN_READWRITE
32 #define SQLITE_OPEN_READWRITE 0x00000002
33 #endif
34 
35 #ifndef SQLITE_OPEN_CREATE
36 #define SQLITE_OPEN_CREATE 0x00000004
37 #endif
38 
39 /* Structure for SQLite Statement Parameter. */
40 struct php_sqlite3_bound_param  {
41 	long param_number;
42 	char *name;
43 	int name_len;
44 	long type;
45 
46 	zval *parameter;
47 };
48 
49 struct php_sqlite3_fci {
50 	zend_fcall_info fci;
51 	zend_fcall_info_cache fcc;
52 };
53 
54 /* Structure for SQLite function. */
55 typedef struct _php_sqlite3_func {
56 	struct _php_sqlite3_func *next;
57 
58 	const char *func_name;
59 	int argc;
60 
61 	zval *func, *step, *fini;
62 	struct php_sqlite3_fci afunc, astep, afini;
63 } php_sqlite3_func;
64 
65 /* Structure for SQLite collation function */
66 typedef struct _php_sqlite3_collation {
67 	struct _php_sqlite3_collation *next;
68 
69 	const char *collation_name;
70 	zval *cmp_func;
71 	struct php_sqlite3_fci fci;
72 } php_sqlite3_collation;
73 
74 /* Structure for SQLite Database object. */
75 typedef struct _php_sqlite3_db_object  {
76 	zend_object zo;
77 	int initialised;
78 	sqlite3 *db;
79 	php_sqlite3_func *funcs;
80 	php_sqlite3_collation *collations;
81 
82 	zend_bool exception;
83 
84 	zend_llist free_list;
85 } php_sqlite3_db_object;
86 
87 /* Structure for SQLite Database object. */
88 typedef struct _php_sqlite3_agg_context  {
89 	zval *zval_context;
90 	long row_count;
91 } php_sqlite3_agg_context;
92 
93 typedef struct _php_sqlite3_stmt_object php_sqlite3_stmt;
94 typedef struct _php_sqlite3_result_object php_sqlite3_result;
95 
96 /* sqlite3 objects to be destroyed */
97 typedef struct _php_sqlite3_free_list {
98 	zval *stmt_obj_zval;
99 	php_sqlite3_stmt *stmt_obj;
100 } php_sqlite3_free_list;
101 
102 /* Structure for SQLite Result object. */
103 struct _php_sqlite3_result_object  {
104 	zend_object zo;
105 	php_sqlite3_db_object *db_obj;
106 	php_sqlite3_stmt *stmt_obj;
107 	zval *stmt_obj_zval;
108 
109 	int is_prepared_statement;
110 	int complete;
111 };
112 
113 /* Structure for SQLite Statement object. */
114 struct _php_sqlite3_stmt_object  {
115 	zend_object zo;
116 	sqlite3_stmt *stmt;
117 	php_sqlite3_db_object *db_obj;
118 	zval *db_obj_zval;
119 
120 	int initialised;
121 
122 	/* Keep track of the zvals for bound parameters */
123 	HashTable *bound_params;
124 };
125 
126 #endif
127 
128 
129 /*
130  * Local variables:
131  * tab-width: 4
132  * c-basic-offset: 4
133  * indent-tabs-mode: t
134  * End:
135  */
136