You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
7.4 KiB

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