Back to index

php5  5.3.10
php_pdo_odbc_int.h
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.0 of the PHP license,       |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_0.txt.                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Author: Wez Furlong <wez@php.net>                                    |
00016   +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: php_pdo_odbc_int.h 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #ifdef PHP_WIN32
00022 # define PDO_ODBC_TYPE      "Win32"
00023 #endif
00024 
00025 #ifndef PDO_ODBC_TYPE
00026 # warning Please fix configure to give your ODBC libraries a name
00027 # define PDO_ODBC_TYPE      "Unknown"
00028 #endif
00029 
00030 /* {{{ Roll a dice, pick a header at random... */
00031 #if HAVE_SQLCLI1_H
00032 # include <sqlcli1.h>
00033 # if defined(DB268K) && HAVE_LIBRARYMANAGER_H
00034 #  include <LibraryManager.h>
00035 # endif
00036 #endif
00037 
00038 #if HAVE_ODBC_H
00039 # include <odbc.h>
00040 #endif
00041 
00042 #if HAVE_IODBC_H
00043 # include <iodbc.h>
00044 #endif
00045 
00046 #if HAVE_SQLUNIX_H && !defined(PHP_WIN32)
00047 # include <sqlunix.h>
00048 #endif
00049 
00050 #if HAVE_SQLTYPES_H
00051 # include <sqltypes.h>
00052 #endif
00053 
00054 #if HAVE_SQLUCODE_H
00055 # include <sqlucode.h>
00056 #endif
00057 
00058 #if HAVE_SQL_H
00059 # include <sql.h>
00060 #endif
00061 
00062 #if HAVE_ISQL_H
00063 # include <isql.h>
00064 #endif
00065 
00066 #if HAVE_SQLEXT_H
00067 # include <sqlext.h>
00068 #endif
00069 
00070 #if HAVE_ISQLEXT_H
00071 # include <isqlext.h>
00072 #endif
00073 
00074 #if HAVE_UDBCEXT_H
00075 # include <udbcext.h>
00076 #endif
00077 
00078 #if HAVE_CLI0CORE_H
00079 # include <cli0core.h>
00080 #endif
00081 
00082 #if HAVE_CLI0EXT1_H
00083 # include <cli0ext.h>
00084 #endif
00085 
00086 #if HAVE_CLI0CLI_H
00087 # include <cli0cli.h>
00088 #endif
00089 
00090 #if HAVE_CLI0DEFS_H
00091 # include <cli0defs.h>
00092 #endif
00093 
00094 #if HAVE_CLI0ENV_H
00095 # include <cli0env.h>
00096 #endif
00097 
00098 #if HAVE_ODBCSDK_H
00099 # include <odbcsdk.h>
00100 #endif
00101 
00102 /* }}} */
00103 
00104 /* {{{ Figure out the type for handles */
00105 #if !defined(HENV) && !defined(SQLHENV) && defined(SQLHANDLE)
00106 # define PDO_ODBC_HENV             SQLHANDLE
00107 # define PDO_ODBC_HDBC             SQLHANDLE
00108 # define PDO_ODBC_HSTMT            SQLHANDLE
00109 #elif !defined(HENV) && (defined(SQLHENV) || defined(DB2CLI_VER))
00110 # define PDO_ODBC_HENV             SQLHENV
00111 # define PDO_ODBC_HDBC             SQLHDBC
00112 # define PDO_ODBC_HSTMT            SQLHSTMT
00113 #else
00114 # define PDO_ODBC_HENV             HENV
00115 # define PDO_ODBC_HDBC             HDBC
00116 # define PDO_ODBC_HSTMT            HSTMT
00117 #endif
00118 /* }}} */
00119 
00120 typedef struct {
00121        char last_state[6];
00122        char last_err_msg[SQL_MAX_MESSAGE_LENGTH];
00123        SDWORD last_error;
00124        const char *file, *what;
00125        int line;
00126 } pdo_odbc_errinfo;
00127 
00128 typedef struct {
00129        PDO_ODBC_HENV env;
00130        PDO_ODBC_HDBC dbc;
00131        pdo_odbc_errinfo einfo;
00132        unsigned assume_utf8:1;
00133        unsigned _spare:31;
00134 } pdo_odbc_db_handle;
00135 
00136 typedef struct {
00137        char *data;
00138        unsigned long datalen;
00139        SQLLEN fetched_len;
00140        SWORD  coltype;
00141        char colname[128];
00142        unsigned is_long;
00143        unsigned is_unicode:1;
00144        unsigned _spare:31;
00145 } pdo_odbc_column;
00146 
00147 typedef struct {
00148        PDO_ODBC_HSTMT       stmt;
00149        pdo_odbc_column *cols;
00150        pdo_odbc_db_handle *H;
00151        pdo_odbc_errinfo einfo;
00152        char *convbuf;
00153        unsigned long convbufsize;
00154        unsigned going_long:1;
00155        unsigned assume_utf8:1;
00156        unsigned _spare:30;
00157 } pdo_odbc_stmt;
00158 
00159 typedef struct {
00160        SQLINTEGER len;
00161        SQLSMALLINT paramtype;
00162        char *outbuf;
00163        unsigned is_unicode:1;
00164        unsigned _spare:31;
00165 } pdo_odbc_param;
00166        
00167 extern pdo_driver_t pdo_odbc_driver;
00168 extern struct pdo_stmt_methods odbc_stmt_methods;
00169 
00170 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);
00171 #define pdo_odbc_drv_error(what)   pdo_odbc_error(dbh, NULL, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)
00172 #define pdo_odbc_stmt_error(what)  pdo_odbc_error(stmt->dbh, stmt, SQL_NULL_HSTMT, what, __FILE__, __LINE__ TSRMLS_CC)
00173 #define pdo_odbc_doer_error(what)  pdo_odbc_error(dbh, NULL, stmt, what, __FILE__, __LINE__ TSRMLS_CC)
00174 
00175 void pdo_odbc_init_error_table(void);
00176 void pdo_odbc_fini_error_table(void);
00177 
00178 #ifdef SQL_ATTR_CONNECTION_POOLING
00179 extern SQLUINTEGER pdo_odbc_pool_on;
00180 extern SQLUINTEGER pdo_odbc_pool_mode;
00181 #endif
00182 
00183 enum {
00184        PDO_ODBC_ATTR_USE_CURSOR_LIBRARY = PDO_ATTR_DRIVER_SPECIFIC,
00185        PDO_ODBC_ATTR_ASSUME_UTF8 /* assume that input strings are UTF-8 when feeding data to unicode columns */
00186 };
00187 
00188 /*
00189  * Local variables:
00190  * tab-width: 4
00191  * c-basic-offset: 4
00192  * End:
00193  * vim600: noet sw=4 ts=4 fdm=marker
00194  * vim<600: noet sw=4 ts=4
00195  */