php_odbc_includes.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 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: Stig Sæther Bakken <ssb@php.net> |
  16. | Andreas Karajannis <Andreas.Karajannis@gmd.de> |
  17. | Kevin N. Shallow <kshallow@tampabay.rr.com> (Birdstep) |
  18. +----------------------------------------------------------------------+
  19. */
  20. /* $Id$ */
  21. #ifndef PHP_ODBC_INCLUDES_H
  22. #define PHP_ODBC_INCLUDES_H
  23. #if HAVE_UODBC
  24. /* checking in the same order as in configure.in */
  25. #if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35) /* Solid Server */
  26. #define ODBC_TYPE "Solid"
  27. #if defined(HAVE_SOLID)
  28. # include <cli0core.h>
  29. # include <cli0ext1.h>
  30. # include <cli0env.h>
  31. #elif defined(HAVE_SOLID_30)
  32. # include <cli0cli.h>
  33. # include <cli0defs.h>
  34. # include <cli0env.h>
  35. #elif defined(HAVE_SOLID_35)
  36. # if !defined(PHP_WIN32)
  37. # include <sqlunix.h>
  38. # endif /* end: #if !defined(PHP_WIN32) */
  39. # include <sqltypes.h>
  40. # include <sqlucode.h>
  41. # include <sqlext.h>
  42. # include <sql.h>
  43. #endif /* end: #if defined(HAVE_SOLID) */
  44. #undef HAVE_SQL_EXTENDED_FETCH
  45. PHP_FUNCTION(solid_fetch_prev);
  46. #define SQLSMALLINT SWORD
  47. #define SQLUSMALLINT UWORD
  48. #ifndef SQL_SUCCEEDED
  49. #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
  50. #endif
  51. #elif defined(HAVE_EMPRESS) /* Empress */
  52. #define ODBC_TYPE "Empress"
  53. #include <sql.h>
  54. #include <sqlext.h>
  55. #undef HAVE_SQL_EXTENDED_FETCH
  56. #elif defined(HAVE_ADABAS) /* Adabas D */
  57. #define ODBC_TYPE "Adabas D"
  58. #include <WINDOWS.H>
  59. #include <sql.h>
  60. #include <sqlext.h>
  61. #define HAVE_SQL_EXTENDED_FETCH 1
  62. #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
  63. #define SQLINTEGER ULONG
  64. #define SQLUSMALLINT USHORT
  65. #elif defined(HAVE_SAPDB) /* SAP DB */
  66. #define ODBC_TYPE "SAP DB"
  67. #include <WINDOWS.H>
  68. #include <sql.h>
  69. #include <sqlext.h>
  70. #define HAVE_SQL_EXTENDED_FETCH 1
  71. #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
  72. #elif defined(HAVE_IODBC) /* iODBC library */
  73. #ifdef CHAR
  74. #undef CHAR
  75. #endif
  76. #ifdef SQLCHAR
  77. #undef SQLCHAR
  78. #endif
  79. #define ODBC_TYPE "iODBC"
  80. #include <sql.h>
  81. #include <sqlext.h>
  82. #include <iodbcext.h>
  83. #define HAVE_SQL_EXTENDED_FETCH 1
  84. #elif defined(HAVE_UNIXODBC) /* unixODBC library */
  85. #ifdef CHAR
  86. #undef CHAR
  87. #endif
  88. #ifdef SQLCHAR
  89. #undef SQLCHAR
  90. #endif
  91. #define ODBC_TYPE "unixODBC"
  92. #undef ODBCVER
  93. #include <sql.h>
  94. #include <sqlext.h>
  95. #define HAVE_SQL_EXTENDED_FETCH 1
  96. #elif defined(HAVE_ESOOB) /* Easysoft ODBC-ODBC Bridge library */
  97. #define ODBC_TYPE "ESOOB"
  98. #include <sql.h>
  99. #include <sqlext.h>
  100. #define HAVE_SQL_EXTENDED_FETCH 1
  101. #elif defined(HAVE_ODBC_ROUTER) /* ODBCRouter.com */
  102. #ifdef CHAR
  103. #undef CHAR
  104. #endif
  105. #ifdef SQLCHAR
  106. #undef SQLCHAR
  107. #endif
  108. #define ODBC_TYPE "ODBCRouter"
  109. #include <odbcsdk.h>
  110. #undef HAVE_SQL_EXTENDED_FETCH
  111. #elif defined(HAVE_OPENLINK) /* OpenLink ODBC drivers */
  112. #define ODBC_TYPE "Openlink"
  113. #include <iodbc.h>
  114. #include <isql.h>
  115. #include <isqlext.h>
  116. #include <udbcext.h>
  117. #define HAVE_SQL_EXTENDED_FETCH 1
  118. #ifndef SQLSMALLINT
  119. #define SQLSMALLINT SWORD
  120. #endif
  121. #ifndef SQLUSMALLINT
  122. #define SQLUSMALLINT UWORD
  123. #endif
  124. #elif defined(HAVE_BIRDSTEP) /* Raima Birdstep */
  125. #define ODBC_TYPE "Birdstep"
  126. #define UNIX
  127. /*
  128. * Extended Fetch in the Birdstep ODBC API is incapable of returning long varchar (memo) fields.
  129. * So the following line has been commented-out to accommodate. - KNS
  130. *
  131. * #define HAVE_SQL_EXTENDED_FETCH 1
  132. */
  133. #include <sql.h>
  134. #include <sqlext.h>
  135. #define SQLINTEGER SDWORD
  136. #define SQLSMALLINT SWORD
  137. #define SQLUSMALLINT UWORD
  138. #elif defined(HAVE_DBMAKER) /* DBMaker */
  139. #define ODBC_TYPE "DBMaker"
  140. #undef ODBCVER
  141. #define ODBCVER 0x0300
  142. #define HAVE_SQL_EXTENDED_FETCH 1
  143. #include <odbc.h>
  144. #elif defined(HAVE_CODBC) /* Custom ODBC */
  145. #define ODBC_TYPE "Custom ODBC"
  146. #define HAVE_SQL_EXTENDED_FETCH 1
  147. #include <odbc.h>
  148. #elif defined(HAVE_IBMDB2) /* DB2 CLI */
  149. #define ODBC_TYPE "IBM DB2 CLI"
  150. #define HAVE_SQL_EXTENDED_FETCH 1
  151. #include <sqlcli1.h>
  152. #ifdef DB268K
  153. /* Need to include ASLM for 68K applications */
  154. #include <LibraryManager.h>
  155. #endif
  156. #else /* MS ODBC */
  157. #define HAVE_SQL_EXTENDED_FETCH 1
  158. #include <WINDOWS.H>
  159. #include <sql.h>
  160. #include <sqlext.h>
  161. #endif
  162. /* Common defines */
  163. #if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC ) || defined (HAVE_IODBC)
  164. #define ODBC_SQL_ENV_T SQLHANDLE
  165. #define ODBC_SQL_CONN_T SQLHANDLE
  166. #define ODBC_SQL_STMT_T SQLHANDLE
  167. #elif defined( HAVE_SOLID_35 ) || defined( HAVE_SAPDB ) || defined ( HAVE_EMPRESS )
  168. #define ODBC_SQL_ENV_T SQLHENV
  169. #define ODBC_SQL_CONN_T SQLHDBC
  170. #define ODBC_SQL_STMT_T SQLHSTMT
  171. #else
  172. #define ODBC_SQL_ENV_T HENV
  173. #define ODBC_SQL_CONN_T HDBC
  174. #define ODBC_SQL_STMT_T HSTMT
  175. #endif
  176. typedef struct odbc_connection {
  177. ODBC_SQL_ENV_T henv;
  178. ODBC_SQL_CONN_T hdbc;
  179. char laststate[6];
  180. char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
  181. int id;
  182. int persistent;
  183. } odbc_connection;
  184. typedef struct odbc_result_value {
  185. char name[256];
  186. char *value;
  187. SQLLEN vallen;
  188. SQLLEN coltype;
  189. } odbc_result_value;
  190. typedef struct odbc_param_info {
  191. SQLSMALLINT sqltype;
  192. SQLSMALLINT scale;
  193. SQLSMALLINT nullable;
  194. SQLULEN precision;
  195. } odbc_param_info;
  196. typedef struct odbc_result {
  197. ODBC_SQL_STMT_T stmt;
  198. odbc_result_value *values;
  199. SQLSMALLINT numcols;
  200. SQLSMALLINT numparams;
  201. # if HAVE_SQL_EXTENDED_FETCH
  202. int fetch_abs;
  203. # endif
  204. long longreadlen;
  205. int binmode;
  206. int fetched;
  207. odbc_param_info * param_info;
  208. odbc_connection *conn_ptr;
  209. } odbc_result;
  210. ZEND_BEGIN_MODULE_GLOBALS(odbc)
  211. char *defDB;
  212. char *defUser;
  213. char *defPW;
  214. long allow_persistent;
  215. long check_persistent;
  216. long max_persistent;
  217. long max_links;
  218. long num_persistent;
  219. long num_links;
  220. int defConn;
  221. long defaultlrl;
  222. long defaultbinmode;
  223. long default_cursortype;
  224. char laststate[6];
  225. char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
  226. HashTable *resource_list;
  227. HashTable *resource_plist;
  228. ZEND_END_MODULE_GLOBALS(odbc)
  229. int odbc_add_result(HashTable *list, odbc_result *result);
  230. odbc_result *odbc_get_result(HashTable *list, int count);
  231. void odbc_del_result(HashTable *list, int count);
  232. int odbc_add_conn(HashTable *list, HDBC conn);
  233. odbc_connection *odbc_get_conn(HashTable *list, int count);
  234. void odbc_del_conn(HashTable *list, int ind);
  235. int odbc_bindcols(odbc_result *result TSRMLS_DC);
  236. #define ODBC_SQL_ERROR_PARAMS odbc_connection *conn_resource, ODBC_SQL_STMT_T stmt, char *func
  237. void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
  238. #if defined(ODBCVER) && (ODBCVER >= 0x0300)
  239. #define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR || x == SQL_WLONGVARCHAR)
  240. #define PHP_ODBC_SQLCOLATTRIBUTE SQLColAttribute
  241. #define PHP_ODBC_SQLALLOCSTMT(hdbc, phstmt) SQLAllocHandle(SQL_HANDLE_STMT, hdbc, phstmt)
  242. #define PHP_ODBC_SQL_DESC_NAME SQL_DESC_NAME
  243. #else
  244. #define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR)
  245. #define PHP_ODBC_SQLCOLATTRIBUTE SQLColAttributes
  246. #define PHP_ODBC_SQLALLOCSTMT SQLAllocStmt
  247. #define PHP_ODBC_SQL_DESC_NAME SQL_COLUMN_NAME
  248. #endif
  249. #define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
  250. #ifdef ZTS
  251. # define ODBCG(v) TSRMG(odbc_globals_id, zend_odbc_globals *, v)
  252. #else
  253. # define ODBCG(v) (odbc_globals.v)
  254. extern ZEND_API zend_odbc_globals odbc_globals;
  255. #endif
  256. #endif /* HAVE_UODBC */
  257. #endif /* PHP_ODBC_INCLUDES_H */
  258. /*
  259. * Local variables:
  260. * tab-width: 4
  261. * c-basic-offset: 4
  262. * End:
  263. */