Back to index

php5  5.3.10
php_mssql.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    | Author: Frank M. Kromann <frank@kromann.info>                        |
00016    +----------------------------------------------------------------------+
00017  */
00018 
00019 
00020 /* $Id: php_mssql.h 321634 2012-01-01 13:15:04Z felipe $ */
00021 
00022 #ifndef PHP_MSSQL_H
00023 #define PHP_MSSQL_H
00024 
00025 
00026 #if HAVE_MSSQL
00027 #define MSDBLIB
00028 
00029 /* FreeTDS checks for PHP_MSSQL_API for avoid type redefinition */
00030 #ifdef HAVE_FREETDS
00031 #define PHP_MSSQL_API
00032 #endif
00033 
00034 #include <sqlfront.h>
00035 #include <sqldb.h>
00036 
00037 typedef short TDS_SHORT;
00038 #ifdef HAVE_FREETDS
00039 #define MSSQL_VERSION "FreeTDS"
00040 #define SQLTEXT SYBTEXT
00041 #define SQLCHAR SYBCHAR
00042 #define SQLVARCHAR SYBVARCHAR
00043 #define SQLINT1 SYBINT1
00044 #define SQLINT2 SYBINT2
00045 #define SQLINT4 SYBINT4
00046 #define SQLINTN SYBINTN
00047 #define SQLBIT SYBBIT
00048 #define SQLFLT4 SYBREAL
00049 #define SQLFLT8 SYBFLT8
00050 #define SQLFLTN SYBFLTN
00051 #define SQLDECIMAL SYBDECIMAL
00052 #define SQLNUMERIC SYBNUMERIC
00053 #define SQLDATETIME SYBDATETIME
00054 #define SQLDATETIM4 SYBDATETIME4
00055 #define SQLDATETIMN SYBDATETIMN
00056 #define SQLMONEY SYBMONEY
00057 #define SQLMONEY4 SYBMONEY4
00058 #define SQLMONEYN SYBMONEYN
00059 #define SQLIMAGE SYBIMAGE
00060 #define SQLBINARY SYBBINARY
00061 #define SQLVARBINARY SYBVARBINARY
00062 #ifdef SQLUNIQUE /* FreeTSD 0.61+ */
00063 #define SQLUNIQUE SYBUNIQUE
00064 #endif
00065 #define DBERRHANDLE(a, b) dberrhandle(b)
00066 #define DBMSGHANDLE(a, b) dbmsghandle(b)
00067 #define DBSETOPT(a, b, c) dbsetopt(a, b, c, -1)
00068 #define NO_MORE_RPC_RESULTS 3
00069 #ifndef dbfreelogin
00070 #define dbfreelogin dbloginfree
00071 #endif
00072 #define dbrpcexec dbrpcsend
00073 typedef unsigned char       *LPBYTE;
00074 typedef float           DBFLT4;
00075 #else
00076 #define MSSQL_VERSION "7.0"
00077 #define DBERRHANDLE(a, b) dbprocerrhandle(a, b)
00078 #define DBMSGHANDLE(a, b) dbprocmsghandle(a, b)
00079 #define EHANDLEFUNC DBERRHANDLE_PROC
00080 #define MHANDLEFUNC DBMSGHANDLE_PROC
00081 #define DBSETOPT(a, b, c) dbsetopt(a, b, c)
00082 #endif
00083 
00084 #define coltype(j) dbcoltype(mssql_ptr->link,j)
00085 #define intcol(i) ((int) *(DBINT *) dbdata(mssql_ptr->link,i))
00086 #define smallintcol(i) ((int) *(DBSMALLINT *) dbdata(mssql_ptr->link,i))
00087 #define tinyintcol(i) ((int) *(DBTINYINT *) dbdata(mssql_ptr->link,i))
00088 #define anyintcol(j) (coltype(j)==SQLINT4?intcol(j):(coltype(j)==SQLINT2?smallintcol(j):tinyintcol(j)))
00089 #define charcol(i) ((DBCHAR *) dbdata(mssql_ptr->link,i))
00090 #define floatcol4(i) (*(DBFLT4 *) dbdata(mssql_ptr->link,i))
00091 #define floatcol8(i) (*(DBFLT8 *) dbdata(mssql_ptr->link,i))
00092 
00093 #ifdef ZTS
00094 #include "TSRM.h"
00095 #endif
00096 
00097 extern zend_module_entry mssql_module_entry;
00098 #define mssql_module_ptr &mssql_module_entry
00099 
00100 PHP_MINIT_FUNCTION(mssql);
00101 PHP_MSHUTDOWN_FUNCTION(mssql);
00102 PHP_RINIT_FUNCTION(mssql);
00103 PHP_RSHUTDOWN_FUNCTION(mssql);
00104 PHP_MINFO_FUNCTION(mssql);
00105 
00106 PHP_FUNCTION(mssql_connect);
00107 PHP_FUNCTION(mssql_pconnect);
00108 PHP_FUNCTION(mssql_close);
00109 PHP_FUNCTION(mssql_select_db);
00110 PHP_FUNCTION(mssql_query);
00111 PHP_FUNCTION(mssql_fetch_batch);
00112 PHP_FUNCTION(mssql_rows_affected);
00113 PHP_FUNCTION(mssql_free_result);
00114 PHP_FUNCTION(mssql_get_last_message);
00115 PHP_FUNCTION(mssql_num_rows);
00116 PHP_FUNCTION(mssql_num_fields);
00117 PHP_FUNCTION(mssql_fetch_field);
00118 PHP_FUNCTION(mssql_fetch_row);
00119 PHP_FUNCTION(mssql_fetch_array);
00120 PHP_FUNCTION(mssql_fetch_assoc);
00121 PHP_FUNCTION(mssql_fetch_object);
00122 PHP_FUNCTION(mssql_field_length);
00123 PHP_FUNCTION(mssql_field_name);
00124 PHP_FUNCTION(mssql_field_type);
00125 PHP_FUNCTION(mssql_data_seek);
00126 PHP_FUNCTION(mssql_field_seek);
00127 PHP_FUNCTION(mssql_result);
00128 PHP_FUNCTION(mssql_next_result);
00129 PHP_FUNCTION(mssql_min_error_severity);
00130 PHP_FUNCTION(mssql_min_message_severity);
00131 PHP_FUNCTION(mssql_init);
00132 PHP_FUNCTION(mssql_bind);
00133 PHP_FUNCTION(mssql_execute);
00134 PHP_FUNCTION(mssql_free_statement);
00135 PHP_FUNCTION(mssql_guid_string);
00136 
00137 typedef struct mssql_link {
00138        LOGINREC *login;
00139        DBPROCESS *link;
00140        int valid;
00141 } mssql_link;
00142 
00143 typedef struct mssql_statement {
00144        int id;
00145        mssql_link *link;
00146        HashTable *binds;
00147        int executed;
00148 } mssql_statement;
00149 
00150 typedef struct {
00151        
00152        zval *zval;
00153        /* TODO: more data for special types (BLOBS, NUMERIC...) */
00154 } mssql_bind;
00155 
00156 ZEND_BEGIN_MODULE_GLOBALS(mssql)
00157        long default_link;
00158        long num_links,num_persistent;
00159        long max_links,max_persistent;
00160        zend_bool allow_persistent;
00161        char *appname;
00162        char *server_message;
00163 #ifdef HAVE_FREETDS
00164        char *charset;
00165 #endif
00166        long min_error_severity, min_message_severity;
00167        long cfg_min_error_severity, cfg_min_message_severity;
00168        long connect_timeout, timeout;
00169        zend_bool compatability_mode;
00170        void (*get_column_content)(mssql_link *mssql_ptr,int offset,zval *result,int column_type  TSRMLS_DC);
00171        long textsize, textlimit, batchsize;
00172        zend_bool datetimeconvert;
00173        HashTable *resource_list, *resource_plist;
00174        zend_bool secure_connection;
00175        long max_procs;
00176 ZEND_END_MODULE_GLOBALS(mssql)
00177 
00178 #define MSSQL_ROWS_BLOCK 128
00179 
00180 typedef struct mssql_field {
00181        char *name,*column_source;
00182        long max_length; 
00183        int numeric;
00184        int type;
00185 } mssql_field;
00186 
00187 typedef struct mssql_result {
00188        zval **data;
00189        mssql_field *fields;
00190        mssql_link *mssql_ptr;
00191        mssql_statement * statement;
00192        int batchsize;
00193        int lastresult;
00194        int blocks_initialized;
00195        int cur_row,cur_field;
00196        int num_rows,num_fields,have_fields;
00197 } mssql_result;
00198 
00199 
00200 #ifdef ZTS
00201 # define MS_SQL_G(v) TSRMG(mssql_globals_id, zend_mssql_globals *, v)
00202 #else
00203 # define MS_SQL_G(v) (mssql_globals.v)
00204 #endif
00205 
00206 #else
00207 
00208 #define mssql_module_ptr NULL
00209 
00210 #endif /* HAVE_MSSQL */
00211 
00212 #define phpext_mssql_ptr mssql_module_ptr
00213 
00214 #endif /* PHP_MSSQL_H */