1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #ifdef PHP_WIN32
22 # define PDO_ODBC_TYPE "Win32"
23 #endif
24
25 #ifndef PDO_ODBC_TYPE
26 # warning Please fix configure to give your ODBC libraries a name
27 # define PDO_ODBC_TYPE "Unknown"
28 #endif
29
30
31 #if HAVE_SQLCLI1_H
32 # include <sqlcli1.h>
33 # if defined(DB268K) && HAVE_LIBRARYMANAGER_H
34 # include <LibraryManager.h>
35 # endif
36 #endif
37
38 #if HAVE_ODBC_H
39 # include <odbc.h>
40 #endif
41
42 #if HAVE_IODBC_H
43 # include <iodbc.h>
44 #endif
45
46 #if HAVE_SQLUNIX_H && !defined(PHP_WIN32)
47 # include <sqlunix.h>
48 #endif
49
50 #if HAVE_SQLTYPES_H
51 # include <sqltypes.h>
52 #endif
53
54 #if HAVE_SQLUCODE_H
55 # include <sqlucode.h>
56 #endif
57
58 #if HAVE_SQL_H
59 # include <sql.h>
60 #endif
61
62 #if HAVE_ISQL_H
63 # include <isql.h>
64 #endif
65
66 #if HAVE_SQLEXT_H
67 # include <sqlext.h>
68 #endif
69
70 #if HAVE_ISQLEXT_H
71 # include <isqlext.h>
72 #endif
73
74 #if HAVE_UDBCEXT_H
75 # include <udbcext.h>
76 #endif
77
78 #if HAVE_CLI0CORE_H
79 # include <cli0core.h>
80 #endif
81
82 #if HAVE_CLI0EXT1_H
83 # include <cli0ext.h>
84 #endif
85
86 #if HAVE_CLI0CLI_H
87 # include <cli0cli.h>
88 #endif
89
90 #if HAVE_CLI0DEFS_H
91 # include <cli0defs.h>
92 #endif
93
94 #if HAVE_CLI0ENV_H
95 # include <cli0env.h>
96 #endif
97
98 #if HAVE_ODBCSDK_H
99 # include <odbcsdk.h>
100 #endif
101
102
103
104
105 #if !defined(HENV) && !defined(SQLHENV) && defined(SQLHANDLE)
106 # define PDO_ODBC_HENV SQLHANDLE
107 # define PDO_ODBC_HDBC SQLHANDLE
108 # define PDO_ODBC_HSTMT SQLHANDLE
109 #elif !defined(HENV) && (defined(SQLHENV) || defined(DB2CLI_VER))
110 # define PDO_ODBC_HENV SQLHENV
111 # define PDO_ODBC_HDBC SQLHDBC
112 # define PDO_ODBC_HSTMT SQLHSTMT
113 #else
114 # define PDO_ODBC_HENV HENV
115 # define PDO_ODBC_HDBC HDBC
116 # define PDO_ODBC_HSTMT HSTMT
117 #endif
118
119
120 typedef struct {
121 char last_state[6];
122 char last_err_msg[SQL_MAX_MESSAGE_LENGTH];
123 SDWORD last_error;
124 const char *file, *what;
125 int line;
126 } pdo_odbc_errinfo;
127
128 typedef struct {
129 PDO_ODBC_HENV env;
130 PDO_ODBC_HDBC dbc;
131 pdo_odbc_errinfo einfo;
132 unsigned assume_utf8:1;
133 unsigned _spare:31;
134 } pdo_odbc_db_handle;
135
136 typedef struct {
137 char *data;
138 zend_ulong datalen;
139 SQLLEN fetched_len;
140 SWORD coltype;
141 char colname[128];
142 unsigned is_long;
143 unsigned is_unicode:1;
144 unsigned _spare:31;
145 } pdo_odbc_column;
146
147 typedef struct {
148 PDO_ODBC_HSTMT stmt;
149 pdo_odbc_column *cols;
150 pdo_odbc_db_handle *H;
151 pdo_odbc_errinfo einfo;
152 char *convbuf;
153 zend_ulong convbufsize;
154 unsigned going_long:1;
155 unsigned assume_utf8:1;
156 unsigned _spare:30;
157 } pdo_odbc_stmt;
158
159 typedef struct {
160 SQLLEN len;
161 SQLSMALLINT paramtype;
162 char *outbuf;
163 unsigned is_unicode:1;
164 unsigned _spare:31;
165 } pdo_odbc_param;
166
167 extern pdo_driver_t pdo_odbc_driver;
168 extern struct pdo_stmt_methods odbc_stmt_methods;
169
170 void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement, char *what, const char *file, int line);
171 #define pdo_odbc_drv_error(what) pdo_odbc_error(dbh, NULL, SQL_NULL_HSTMT, what, __FILE__, __LINE__)
172 #define pdo_odbc_stmt_error(what) pdo_odbc_error(stmt->dbh, stmt, SQL_NULL_HSTMT, what, __FILE__, __LINE__)
173 #define pdo_odbc_doer_error(what) pdo_odbc_error(dbh, NULL, stmt, what, __FILE__, __LINE__)
174
175 void pdo_odbc_init_error_table(void);
176 void pdo_odbc_fini_error_table(void);
177
178 #ifdef SQL_ATTR_CONNECTION_POOLING
179 extern zend_ulong pdo_odbc_pool_on;
180 extern zend_ulong pdo_odbc_pool_mode;
181 #endif
182
183 enum {
184 PDO_ODBC_ATTR_USE_CURSOR_LIBRARY = PDO_ATTR_DRIVER_SPECIFIC,
185 PDO_ODBC_ATTR_ASSUME_UTF8
186 };
187
188
189
190
191
192
193
194
195