php_pdo_odbc_int.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.0 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_0.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. | Author: Wez Furlong <wez@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #ifdef PHP_WIN32
  20. # define PDO_ODBC_TYPE "Win32"
  21. #endif
  22. #ifndef PDO_ODBC_TYPE
  23. # warning Please fix configure to give your ODBC libraries a name
  24. # define PDO_ODBC_TYPE "Unknown"
  25. #endif
  26. /* {{{ Roll a dice, pick a header at random... */
  27. #if HAVE_SQLCLI1_H
  28. # include <sqlcli1.h>
  29. # if defined(DB268K) && HAVE_LIBRARYMANAGER_H
  30. # include <LibraryManager.h>
  31. # endif
  32. #endif
  33. #if HAVE_ODBC_H
  34. # include <odbc.h>
  35. #endif
  36. #if HAVE_IODBC_H
  37. # include <iodbc.h>
  38. #endif
  39. #if HAVE_SQLUNIX_H && !defined(PHP_WIN32)
  40. # include <sqlunix.h>
  41. #endif
  42. #if HAVE_SQLTYPES_H
  43. # include <sqltypes.h>
  44. #endif
  45. #if HAVE_SQLUCODE_H
  46. # include <sqlucode.h>
  47. #endif
  48. #if HAVE_SQL_H
  49. # include <sql.h>
  50. #endif
  51. #if HAVE_ISQL_H
  52. # include <isql.h>
  53. #endif
  54. #if HAVE_SQLEXT_H
  55. # include <sqlext.h>
  56. #endif
  57. #if HAVE_ISQLEXT_H
  58. # include <isqlext.h>
  59. #endif
  60. #if HAVE_UDBCEXT_H
  61. # include <udbcext.h>
  62. #endif
  63. #if HAVE_CLI0CORE_H
  64. # include <cli0core.h>
  65. #endif
  66. #if HAVE_CLI0EXT1_H
  67. # include <cli0ext.h>
  68. #endif
  69. #if HAVE_CLI0CLI_H
  70. # include <cli0cli.h>
  71. #endif
  72. #if HAVE_CLI0DEFS_H
  73. # include <cli0defs.h>
  74. #endif
  75. #if HAVE_CLI0ENV_H
  76. # include <cli0env.h>
  77. #endif
  78. #if HAVE_ODBCSDK_H
  79. # include <odbcsdk.h>
  80. #endif
  81. /* }}} */
  82. /* {{{ Figure out the type for handles */
  83. #if !defined(HENV) && !defined(SQLHENV) && defined(SQLHANDLE)
  84. # define PDO_ODBC_HENV SQLHANDLE
  85. # define PDO_ODBC_HDBC SQLHANDLE
  86. # define PDO_ODBC_HSTMT SQLHANDLE
  87. #elif !defined(HENV) && (defined(SQLHENV) || defined(DB2CLI_VER))
  88. # define PDO_ODBC_HENV SQLHENV
  89. # define PDO_ODBC_HDBC SQLHDBC
  90. # define PDO_ODBC_HSTMT SQLHSTMT
  91. #else
  92. # define PDO_ODBC_HENV HENV
  93. # define PDO_ODBC_HDBC HDBC
  94. # define PDO_ODBC_HSTMT HSTMT
  95. #endif
  96. /* }}} */
  97. typedef struct {
  98. char last_state[6];
  99. char last_err_msg[SQL_MAX_MESSAGE_LENGTH];
  100. SDWORD last_error;
  101. const char *file, *what;
  102. int line;
  103. } pdo_odbc_errinfo;
  104. typedef struct {
  105. PDO_ODBC_HENV env;
  106. PDO_ODBC_HDBC dbc;
  107. pdo_odbc_errinfo einfo;
  108. unsigned assume_utf8:1;
  109. unsigned _spare:31;
  110. } pdo_odbc_db_handle;
  111. typedef struct {
  112. char *data;
  113. unsigned long datalen;
  114. SQLLEN fetched_len;
  115. SWORD coltype;
  116. char colname[128];
  117. unsigned is_long;
  118. unsigned is_unicode:1;
  119. unsigned _spare:31;
  120. } pdo_odbc_column;
  121. typedef struct {
  122. PDO_ODBC_HSTMT stmt;
  123. pdo_odbc_column *cols;
  124. pdo_odbc_db_handle *H;
  125. pdo_odbc_errinfo einfo;
  126. char *convbuf;
  127. unsigned long convbufsize;
  128. unsigned going_long:1;
  129. unsigned assume_utf8:1;
  130. unsigned _spare:30;
  131. } pdo_odbc_stmt;
  132. typedef struct {
  133. SQLLEN len;
  134. SQLSMALLINT paramtype;
  135. char *outbuf;
  136. unsigned is_unicode:1;
  137. unsigned _spare:31;
  138. } pdo_odbc_param;
  139. extern pdo_driver_t pdo_odbc_driver;
  140. extern struct pdo_stmt_methods odbc_stmt_methods;
  141. void pdo_odbc_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, PDO_ODBC_HSTMT statement, char *what, const char *file, int line TSRMLS_DC);
  142. #define pdo_odbc_drv_error(what) pdo_odbc_error(dbh, NULL, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)
  143. #define pdo_odbc_stmt_error(what) pdo_odbc_error(stmt->dbh, stmt, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)
  144. #define pdo_odbc_doer_error(what) pdo_odbc_error(dbh, NULL, stmt, what, __FILE__, __LINE__ TSRMLS_CC)
  145. void pdo_odbc_init_error_table(void);
  146. void pdo_odbc_fini_error_table(void);
  147. #ifdef SQL_ATTR_CONNECTION_POOLING
  148. extern SQLUINTEGER pdo_odbc_pool_on;
  149. extern SQLUINTEGER pdo_odbc_pool_mode;
  150. #endif
  151. enum {
  152. PDO_ODBC_ATTR_USE_CURSOR_LIBRARY = PDO_ATTR_DRIVER_SPECIFIC,
  153. PDO_ODBC_ATTR_ASSUME_UTF8 /* assume that input strings are UTF-8 when feeding data to unicode columns */
  154. };
  155. /*
  156. * Local variables:
  157. * tab-width: 4
  158. * c-basic-offset: 4
  159. * End:
  160. * vim600: noet sw=4 ts=4 fdm=marker
  161. * vim<600: noet sw=4 ts=4
  162. */