1999-11-04 04:35:58 +08:00
|
|
|
/*
|
|
|
|
+----------------------------------------------------------------------+
|
2004-01-09 01:33:29 +08:00
|
|
|
| PHP Version 5 |
|
1999-11-04 04:35:58 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2004-01-09 01:33:29 +08:00
|
|
|
| Copyright (c) 1997-2004 The PHP Group |
|
1999-11-04 04:35:58 +08:00
|
|
|
+----------------------------------------------------------------------+
|
2003-06-11 04:04:29 +08:00
|
|
|
| This source file is subject to version 3.0 of the PHP license, |
|
1999-11-04 04:35:58 +08:00
|
|
|
| that is bundled with this package in the file LICENSE, and is |
|
2003-06-11 04:04:29 +08:00
|
|
|
| available through the world-wide-web at the following url: |
|
|
|
|
| http://www.php.net/license/3_0.txt. |
|
1999-11-04 04:35:58 +08:00
|
|
|
| If you did not receive a copy of the PHP license and are unable to |
|
|
|
|
| obtain it through the world-wide-web, please send a note to |
|
|
|
|
| license@php.net so we can mail you a copy immediately. |
|
|
|
|
+----------------------------------------------------------------------+
|
2003-06-14 11:35:16 +08:00
|
|
|
| Author: Frank M. Kromann <frank@kromann.info> |
|
1999-11-04 04:35:58 +08:00
|
|
|
+----------------------------------------------------------------------+
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2000-07-03 07:46:51 +08:00
|
|
|
#ifndef PHP_MSSQL_H
|
|
|
|
#define PHP_MSSQL_H
|
1999-11-04 04:35:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
#if HAVE_MSSQL
|
2002-12-17 06:26:49 +08:00
|
|
|
#define MSDBLIB
|
2000-02-14 03:06:51 +08:00
|
|
|
#ifdef PHP_WIN32
|
|
|
|
#define PHP_MSSQL_API __declspec(dllexport)
|
|
|
|
#else
|
|
|
|
#define PHP_MSSQL_API
|
|
|
|
#endif
|
|
|
|
|
2000-04-23 18:52:49 +08:00
|
|
|
|
1999-11-04 04:35:58 +08:00
|
|
|
#define MSSQL_VERSION "7.0"
|
2000-11-21 11:09:16 +08:00
|
|
|
#include "sqlfront.h"
|
|
|
|
#include "sqldb.h"
|
1999-11-04 04:35:58 +08:00
|
|
|
|
2002-12-17 06:26:49 +08:00
|
|
|
#if HAVE_FREETDS
|
2004-04-21 07:37:08 +08:00
|
|
|
#ifndef SHORT
|
|
|
|
typedef short SHORT;
|
|
|
|
#endif
|
2002-12-17 06:26:49 +08:00
|
|
|
#define SQLTEXT SYBTEXT
|
|
|
|
#define SQLCHAR SYBCHAR
|
|
|
|
#define SQLVARCHAR SYBVARCHAR
|
|
|
|
#define SQLINT1 SYBINT1
|
|
|
|
#define SQLINT2 SYBINT2
|
|
|
|
#define SQLINT4 SYBINT4
|
|
|
|
#define SQLINTN SYBINTN
|
|
|
|
#define SQLBIT SYBBIT
|
|
|
|
#define SQLFLT4 SYBREAL
|
|
|
|
#define SQLFLT8 SYBFLT8
|
|
|
|
#define SQLFLTN SYBFLTN
|
|
|
|
#define SQLDECIMAL SYBDECIMAL
|
|
|
|
#define SQLNUMERIC SYBNUMERIC
|
|
|
|
#define SQLDATETIME SYBDATETIME
|
|
|
|
#define SQLDATETIM4 SYBDATETIME4
|
|
|
|
#define SQLDATETIMN SYBDATETIMN
|
|
|
|
#define SQLMONEY SYBMONEY
|
|
|
|
#define SQLMONEY4 SYBMONEY4
|
|
|
|
#define SQLMONEYN SYBMONEYN
|
|
|
|
#define SQLIMAGE SYBIMAGE
|
|
|
|
#define SQLBINARY SYBBINARY
|
|
|
|
#define SQLVARBINARY SYBVARBINARY
|
2003-07-24 00:53:26 +08:00
|
|
|
#ifdef SQLUNIQUE /* FreeTSD 0.61+ */
|
|
|
|
#define SQLUNIQUE SYBUNIQUE
|
|
|
|
#endif
|
2002-12-17 06:26:49 +08:00
|
|
|
#define DBERRHANDLE(a, b) dberrhandle(b)
|
|
|
|
#define DBMSGHANDLE(a, b) dbmsghandle(b)
|
|
|
|
#define DBSETOPT(a, b, c) dbsetopt(a, b, c, -1)
|
|
|
|
#define NO_MORE_RPC_RESULTS 3
|
|
|
|
#define dbfreelogin dbloginfree
|
|
|
|
#define dbrpcexec dbrpcsend
|
2003-02-09 15:50:56 +08:00
|
|
|
typedef unsigned char *LPBYTE;
|
|
|
|
typedef float DBFLT4;
|
2002-12-17 06:26:49 +08:00
|
|
|
#else
|
|
|
|
#define DBERRHANDLE(a, b) dbprocerrhandle(a, b)
|
2002-12-17 06:44:08 +08:00
|
|
|
#define DBMSGHANDLE(a, b) dbprocmsghandle(a, b)
|
2002-12-17 06:26:49 +08:00
|
|
|
#define EHANDLEFUNC DBERRHANDLE_PROC
|
|
|
|
#define MHANDLEFUNC DBMSGHANDLE_PROC
|
|
|
|
#define DBSETOPT(a, b, c) dbsetopt(a, b, c)
|
|
|
|
#endif
|
|
|
|
|
1999-11-04 04:35:58 +08:00
|
|
|
#define coltype(j) dbcoltype(mssql_ptr->link,j)
|
|
|
|
#define intcol(i) ((int) *(DBINT *) dbdata(mssql_ptr->link,i))
|
|
|
|
#define smallintcol(i) ((int) *(DBSMALLINT *) dbdata(mssql_ptr->link,i))
|
|
|
|
#define tinyintcol(i) ((int) *(DBTINYINT *) dbdata(mssql_ptr->link,i))
|
|
|
|
#define anyintcol(j) (coltype(j)==SQLINT4?intcol(j):(coltype(j)==SQLINT2?smallintcol(j):tinyintcol(j)))
|
|
|
|
#define charcol(i) ((DBCHAR *) dbdata(mssql_ptr->link,i))
|
2003-02-09 15:18:02 +08:00
|
|
|
#define floatcol4(i) (*(DBFLT4 *) dbdata(mssql_ptr->link,i))
|
2002-12-17 06:26:49 +08:00
|
|
|
#define floatcol8(i) (*(DBFLT8 *) dbdata(mssql_ptr->link,i))
|
1999-11-04 04:35:58 +08:00
|
|
|
|
2000-11-30 06:06:47 +08:00
|
|
|
#ifdef ZTS
|
1999-11-04 04:35:58 +08:00
|
|
|
#include "TSRM.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern zend_module_entry mssql_module_entry;
|
|
|
|
#define mssql_module_ptr &mssql_module_entry
|
|
|
|
|
2001-07-30 09:56:43 +08:00
|
|
|
PHP_MINIT_FUNCTION(mssql);
|
|
|
|
PHP_MSHUTDOWN_FUNCTION(mssql);
|
|
|
|
PHP_RINIT_FUNCTION(mssql);
|
|
|
|
PHP_RSHUTDOWN_FUNCTION(mssql);
|
1999-11-04 04:35:58 +08:00
|
|
|
PHP_MINFO_FUNCTION(mssql);
|
|
|
|
|
|
|
|
PHP_FUNCTION(mssql_connect);
|
|
|
|
PHP_FUNCTION(mssql_pconnect);
|
|
|
|
PHP_FUNCTION(mssql_close);
|
|
|
|
PHP_FUNCTION(mssql_select_db);
|
|
|
|
PHP_FUNCTION(mssql_query);
|
2000-11-21 11:09:16 +08:00
|
|
|
PHP_FUNCTION(mssql_fetch_batch);
|
|
|
|
PHP_FUNCTION(mssql_rows_affected);
|
1999-11-04 04:35:58 +08:00
|
|
|
PHP_FUNCTION(mssql_free_result);
|
|
|
|
PHP_FUNCTION(mssql_get_last_message);
|
|
|
|
PHP_FUNCTION(mssql_num_rows);
|
|
|
|
PHP_FUNCTION(mssql_num_fields);
|
|
|
|
PHP_FUNCTION(mssql_fetch_field);
|
|
|
|
PHP_FUNCTION(mssql_fetch_row);
|
|
|
|
PHP_FUNCTION(mssql_fetch_array);
|
2001-12-03 05:10:15 +08:00
|
|
|
PHP_FUNCTION(mssql_fetch_assoc);
|
1999-11-04 04:35:58 +08:00
|
|
|
PHP_FUNCTION(mssql_fetch_object);
|
|
|
|
PHP_FUNCTION(mssql_field_length);
|
|
|
|
PHP_FUNCTION(mssql_field_name);
|
|
|
|
PHP_FUNCTION(mssql_field_type);
|
|
|
|
PHP_FUNCTION(mssql_data_seek);
|
|
|
|
PHP_FUNCTION(mssql_field_seek);
|
|
|
|
PHP_FUNCTION(mssql_result);
|
2001-03-10 07:37:56 +08:00
|
|
|
PHP_FUNCTION(mssql_next_result);
|
1999-11-04 04:35:58 +08:00
|
|
|
PHP_FUNCTION(mssql_min_error_severity);
|
|
|
|
PHP_FUNCTION(mssql_min_message_severity);
|
2001-06-06 05:09:50 +08:00
|
|
|
PHP_FUNCTION(mssql_init);
|
|
|
|
PHP_FUNCTION(mssql_bind);
|
|
|
|
PHP_FUNCTION(mssql_execute);
|
2003-01-09 16:00:07 +08:00
|
|
|
PHP_FUNCTION(mssql_free_statement);
|
2001-06-29 00:59:17 +08:00
|
|
|
PHP_FUNCTION(mssql_guid_string);
|
1999-11-04 04:35:58 +08:00
|
|
|
|
|
|
|
typedef struct mssql_link {
|
|
|
|
LOGINREC *login;
|
|
|
|
DBPROCESS *link;
|
|
|
|
int valid;
|
|
|
|
} mssql_link;
|
|
|
|
|
2001-06-06 05:09:50 +08:00
|
|
|
typedef struct mssql_statement {
|
|
|
|
int id;
|
|
|
|
mssql_link *link;
|
|
|
|
HashTable *binds;
|
|
|
|
int executed;
|
|
|
|
} mssql_statement;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
|
|
|
zval *zval;
|
|
|
|
/* TODO: more data for special types (BLOBS, NUMERIC...) */
|
|
|
|
} mssql_bind;
|
|
|
|
|
2000-11-30 06:06:47 +08:00
|
|
|
ZEND_BEGIN_MODULE_GLOBALS(mssql)
|
1999-11-04 04:35:58 +08:00
|
|
|
long default_link;
|
|
|
|
long num_links,num_persistent;
|
|
|
|
long max_links,max_persistent;
|
2003-01-09 07:19:54 +08:00
|
|
|
zend_bool allow_persistent;
|
1999-11-04 04:35:58 +08:00
|
|
|
char *appname;
|
|
|
|
char *server_message;
|
|
|
|
long min_error_severity, min_message_severity;
|
|
|
|
long cfg_min_error_severity, cfg_min_message_severity;
|
2003-01-09 07:19:54 +08:00
|
|
|
long connect_timeout, timeout;
|
|
|
|
zend_bool compatability_mode;
|
2001-10-24 00:34:52 +08:00
|
|
|
void (*get_column_content)(mssql_link *mssql_ptr,int offset,pval *result,int column_type TSRMLS_DC);
|
2000-11-21 11:09:16 +08:00
|
|
|
long textsize, textlimit, batchsize;
|
2003-01-09 07:19:54 +08:00
|
|
|
zend_bool datetimeconvert;
|
1999-11-04 04:35:58 +08:00
|
|
|
HashTable *resource_list, *resource_plist;
|
2003-01-09 07:19:54 +08:00
|
|
|
zend_bool secure_connection;
|
2002-06-11 03:31:29 +08:00
|
|
|
long max_procs;
|
2000-11-30 06:06:47 +08:00
|
|
|
ZEND_END_MODULE_GLOBALS(mssql)
|
1999-11-04 04:35:58 +08:00
|
|
|
|
|
|
|
#define MSSQL_ROWS_BLOCK 128
|
|
|
|
|
|
|
|
typedef struct mssql_field {
|
|
|
|
char *name,*column_source;
|
|
|
|
long max_length;
|
|
|
|
int numeric;
|
|
|
|
int type;
|
|
|
|
} mssql_field;
|
|
|
|
|
|
|
|
typedef struct mssql_result {
|
|
|
|
pval **data;
|
|
|
|
mssql_field *fields;
|
|
|
|
mssql_link *mssql_ptr;
|
2002-12-04 02:57:04 +08:00
|
|
|
mssql_statement * statement;
|
2000-11-21 11:09:16 +08:00
|
|
|
int batchsize;
|
|
|
|
int lastresult;
|
2001-03-10 07:37:56 +08:00
|
|
|
int blocks_initialized;
|
1999-11-04 04:35:58 +08:00
|
|
|
int cur_row,cur_field;
|
|
|
|
int num_rows,num_fields;
|
|
|
|
} mssql_result;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ZTS
|
2001-07-28 19:36:37 +08:00
|
|
|
# define MS_SQL_G(v) TSRMG(mssql_globals_id, zend_mssql_globals *, v)
|
1999-11-04 04:35:58 +08:00
|
|
|
#else
|
|
|
|
# define MS_SQL_G(v) (mssql_globals.v)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define mssql_module_ptr NULL
|
|
|
|
|
|
|
|
#endif /* HAVE_MSSQL */
|
|
|
|
|
|
|
|
#define phpext_mssql_ptr mssql_module_ptr
|
|
|
|
|
2000-07-03 07:46:51 +08:00
|
|
|
#endif /* PHP_MSSQL_H */
|