Back to index

php5  5.3.10
php_odbc_includes.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.01 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_01.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    | Authors: Stig Sæther Bakken <ssb@php.net>                            |
00016    |          Andreas Karajannis <Andreas.Karajannis@gmd.de>              |
00017    |         Kevin N. Shallow <kshallow@tampabay.rr.com> (Birdstep)      |
00018    +----------------------------------------------------------------------+
00019 */
00020 
00021 /* $Id: php_odbc_includes.h 321634 2012-01-01 13:15:04Z felipe $ */
00022 
00023 #ifndef PHP_ODBC_INCLUDES_H
00024 #define PHP_ODBC_INCLUDES_H
00025 
00026 #if HAVE_UODBC
00027 
00028 #define ODBCVER 0x0250
00029 /*#ifndef MSVC5
00030 #define FAR
00031 #endif
00032 */
00033 
00034 /* checking in the same order as in configure.in */
00035 
00036 #if defined(HAVE_SOLID) || defined(HAVE_SOLID_30) || defined(HAVE_SOLID_35) /* Solid Server */
00037 
00038 #define ODBC_TYPE "Solid"
00039 #if defined(HAVE_SOLID)
00040 # include <cli0core.h>
00041 # include <cli0ext1.h>
00042 # include <cli0env.h>
00043 #elif defined(HAVE_SOLID_30)
00044 # include <cli0cli.h>
00045 # include <cli0defs.h>
00046 # include <cli0env.h>
00047 #elif defined(HAVE_SOLID_35)
00048 # if !defined(PHP_WIN32)
00049 #  include <sqlunix.h>
00050 # endif              /* end: #if !defined(PHP_WIN32) */
00051 # include <sqltypes.h>
00052 # include <sqlucode.h>
00053 # include <sqlext.h>
00054 # include <sql.h>
00055 #endif /* end: #if defined(HAVE_SOLID) */
00056 #undef HAVE_SQL_EXTENDED_FETCH
00057 PHP_FUNCTION(solid_fetch_prev);
00058 #define SQLSMALLINT SWORD
00059 #define SQLUSMALLINT UWORD
00060 #ifndef SQL_SUCCEEDED
00061 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
00062 #endif
00063 
00064 #elif defined(HAVE_EMPRESS) /* Empress */
00065 
00066 #define ODBC_TYPE "Empress"
00067 #include <sql.h>
00068 #include <sqlext.h>
00069 #undef HAVE_SQL_EXTENDED_FETCH
00070 
00071 #elif defined(HAVE_ADABAS) /* Adabas D */
00072 
00073 #define ODBC_TYPE "Adabas D"
00074 #include <WINDOWS.H>
00075 #include <sql.h>
00076 #include <sqlext.h>
00077 #define HAVE_SQL_EXTENDED_FETCH 1
00078 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
00079 #define SQLINTEGER ULONG
00080 #define SQLUSMALLINT USHORT
00081 
00082 #elif defined(HAVE_SAPDB) /* SAP DB */
00083 
00084 #define ODBC_TYPE "SAP DB"
00085 #include <WINDOWS.H>
00086 #include <sql.h>
00087 #include <sqlext.h>
00088 #define HAVE_SQL_EXTENDED_FETCH 1
00089 #define SQL_SUCCEEDED(rc) (((rc)&(~1))==0)
00090 
00091 #elif defined(HAVE_IODBC) /* iODBC library */
00092 
00093 #ifdef CHAR
00094 #undef CHAR
00095 #endif
00096 
00097 #ifdef SQLCHAR
00098 #undef SQLCHAR
00099 #endif
00100 
00101 #define ODBC_TYPE "iODBC"
00102 #include <sql.h>
00103 #include <sqlext.h>
00104 #include <iodbcext.h>
00105 #define HAVE_SQL_EXTENDED_FETCH 1
00106 
00107 #elif defined(HAVE_UNIXODBC) /* unixODBC library */
00108 
00109 #ifdef CHAR
00110 #undef CHAR
00111 #endif
00112 
00113 #ifdef SQLCHAR
00114 #undef SQLCHAR
00115 #endif
00116 
00117 #define ODBC_TYPE "unixODBC"
00118 #include <sql.h>
00119 #include <sqlext.h>
00120 #define HAVE_SQL_EXTENDED_FETCH 1
00121 
00122 #elif defined(HAVE_ESOOB) /* Easysoft ODBC-ODBC Bridge library */
00123 
00124 #define ODBC_TYPE "ESOOB"
00125 #include <sql.h>
00126 #include <sqlext.h>
00127 #define HAVE_SQL_EXTENDED_FETCH 1
00128 
00129 #elif defined(HAVE_ODBC_ROUTER) /* ODBCRouter.com */
00130 
00131 #ifdef CHAR
00132 #undef CHAR
00133 #endif
00134 
00135 #ifdef SQLCHAR
00136 #undef SQLCHAR
00137 #endif
00138 
00139 #define ODBC_TYPE "ODBCRouter"
00140 #include <odbcsdk.h>
00141 #undef HAVE_SQL_EXTENDED_FETCH
00142 
00143 #elif defined(HAVE_OPENLINK) /* OpenLink ODBC drivers */
00144 
00145 #define ODBC_TYPE "Openlink"
00146 #include <iodbc.h>
00147 #include <isql.h>
00148 #include <isqlext.h>
00149 #include <udbcext.h>
00150 #define HAVE_SQL_EXTENDED_FETCH 1
00151 #ifndef SQLSMALLINT
00152 #define SQLSMALLINT SWORD
00153 #endif
00154 #ifndef SQLUSMALLINT
00155 #define SQLUSMALLINT UWORD
00156 #endif
00157 
00158 #elif defined(HAVE_BIRDSTEP) /* Raima Birdstep */
00159 
00160 #define ODBC_TYPE "Birdstep"
00161 #define UNIX
00162 /*
00163  * Extended Fetch in the Birdstep ODBC API is incapable of returning long varchar (memo) fields.
00164  * So the following line has been commented-out to accomadate. - KNS
00165  *
00166  * #define HAVE_SQL_EXTENDED_FETCH 1
00167  */
00168 #include <sql.h>
00169 #include <sqlext.h>
00170 #define SQLINTEGER SDWORD
00171 #define SQLSMALLINT SWORD
00172 #define SQLUSMALLINT UWORD
00173 
00174 
00175 #elif defined(HAVE_DBMAKER) /* DBMaker */
00176 
00177 #define ODBC_TYPE "DBMaker"
00178 #undef ODBCVER
00179 #define ODBCVER 0x0300
00180 #define HAVE_SQL_EXTENDED_FETCH 1
00181 #include <odbc.h>
00182 
00183 
00184 #elif defined(HAVE_CODBC) /* Custom ODBC */
00185 
00186 #define ODBC_TYPE "Custom ODBC"
00187 #define HAVE_SQL_EXTENDED_FETCH 1
00188 #include <odbc.h>
00189 
00190 #elif defined(HAVE_IBMDB2) /* DB2 CLI */
00191 
00192 #define ODBC_TYPE "IBM DB2 CLI"
00193 #define HAVE_SQL_EXTENDED_FETCH 1
00194 #include <sqlcli1.h>
00195 #ifdef DB268K
00196 /* Need to include ASLM for 68K applications */
00197 #include <LibraryManager.h>
00198 #endif
00199 
00200 #else /* MS ODBC */
00201 
00202 #define HAVE_SQL_EXTENDED_FETCH 1
00203 #include <WINDOWS.H>
00204 #include <sql.h>
00205 #include <sqlext.h>
00206 #endif
00207 
00208 
00209 /* Common defines */
00210 
00211 #if defined( HAVE_IBMDB2 ) || defined( HAVE_UNIXODBC ) || defined (HAVE_IODBC)
00212 #define ODBC_SQL_ENV_T SQLHANDLE
00213 #define ODBC_SQL_CONN_T SQLHANDLE
00214 #define ODBC_SQL_STMT_T SQLHANDLE
00215 #elif defined( HAVE_SOLID_35 ) || defined( HAVE_SAPDB ) || defined ( HAVE_EMPRESS )
00216 #define ODBC_SQL_ENV_T SQLHENV
00217 #define ODBC_SQL_CONN_T SQLHDBC
00218 #define ODBC_SQL_STMT_T SQLHSTMT
00219 #else
00220 #define ODBC_SQL_ENV_T HENV
00221 #define ODBC_SQL_CONN_T HDBC
00222 #define ODBC_SQL_STMT_T HSTMT
00223 #endif
00224 
00225 typedef struct odbc_connection {
00226     ODBC_SQL_ENV_T henv;
00227     ODBC_SQL_CONN_T hdbc;
00228     char laststate[6];
00229     char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
00230        int id;
00231        int persistent;
00232 } odbc_connection;
00233 
00234 typedef struct odbc_result_value {
00235        char name[32];
00236        char *value;
00237        SQLLEN vallen;
00238        SQLLEN coltype;
00239 } odbc_result_value;
00240 
00241 typedef struct odbc_result {
00242        ODBC_SQL_STMT_T stmt;
00243        odbc_result_value *values;
00244        SQLSMALLINT numcols;
00245        SQLSMALLINT numparams;
00246 # if HAVE_SQL_EXTENDED_FETCH
00247        int fetch_abs;
00248 # endif
00249        long longreadlen;
00250        int binmode;
00251        int fetched;
00252        odbc_connection *conn_ptr;
00253 } odbc_result;
00254 
00255 ZEND_BEGIN_MODULE_GLOBALS(odbc)
00256        char *defDB;
00257        char *defUser;
00258        char *defPW;
00259        long allow_persistent;
00260        long check_persistent;
00261        long max_persistent;
00262        long max_links;
00263        long num_persistent;
00264        long num_links;
00265        int defConn;
00266     long defaultlrl;
00267     long defaultbinmode;
00268     long default_cursortype;
00269     char laststate[6];
00270     char lasterrormsg[SQL_MAX_MESSAGE_LENGTH];
00271        HashTable *resource_list;
00272        HashTable *resource_plist;
00273 ZEND_END_MODULE_GLOBALS(odbc)
00274 
00275 int odbc_add_result(HashTable *list, odbc_result *result);
00276 odbc_result *odbc_get_result(HashTable *list, int count);
00277 void odbc_del_result(HashTable *list, int count);
00278 int odbc_add_conn(HashTable *list, HDBC conn);
00279 odbc_connection *odbc_get_conn(HashTable *list, int count);
00280 void odbc_del_conn(HashTable *list, int ind);
00281 int odbc_bindcols(odbc_result *result TSRMLS_DC);
00282 
00283 #define ODBC_SQL_ERROR_PARAMS odbc_connection *conn_resource, ODBC_SQL_STMT_T stmt, char *func
00284 
00285 void odbc_sql_error(ODBC_SQL_ERROR_PARAMS);
00286 
00287 #define IS_SQL_LONG(x) (x == SQL_LONGVARBINARY || x == SQL_LONGVARCHAR)
00288 #define IS_SQL_BINARY(x) (x == SQL_BINARY || x == SQL_VARBINARY || x == SQL_LONGVARBINARY)
00289 
00290 #ifdef ZTS
00291 # define ODBCG(v) TSRMG(odbc_globals_id, zend_odbc_globals *, v)
00292 #else
00293 # define ODBCG(v) (odbc_globals.v)
00294 extern ZEND_API zend_odbc_globals odbc_globals;
00295 #endif
00296 
00297 #endif /* HAVE_UODBC */
00298 #endif /* PHP_ODBC_INCLUDES_H */
00299 
00300 /*
00301  * Local variables:
00302  * tab-width: 4
00303  * c-basic-offset: 4
00304  * End:
00305  */