diff options
author | Marc Boeren <mboeren@php.net> | 2002-02-18 09:21:51 +0000 |
---|---|---|
committer | Marc Boeren <mboeren@php.net> | 2002-02-18 09:21:51 +0000 |
commit | cb46dbb6ebe92c102636dd7018deab768a88f499 (patch) | |
tree | 6bfdc214b2f04d6820616a411a2f7eb6a5032631 /ext/dbx | |
parent | ede90c86fa795aebee29eb68807cb08a3f6193b2 (diff) | |
download | php-git-cb46dbb6ebe92c102636dd7018deab768a88f499.tar.gz |
Added support for Sybase-CT to dbx module (Mc).
Diffstat (limited to 'ext/dbx')
-rw-r--r-- | ext/dbx/CREDITS | 1 | ||||
-rw-r--r-- | ext/dbx/Makefile.in | 2 | ||||
-rw-r--r-- | ext/dbx/dbx.c | 16 | ||||
-rw-r--r-- | ext/dbx/dbx.dsp | 10 | ||||
-rw-r--r-- | ext/dbx/dbx_sybasect.c | 282 | ||||
-rw-r--r-- | ext/dbx/dbx_sybasect.h | 60 | ||||
-rw-r--r-- | ext/dbx/tests/002.phpt | 1 | ||||
-rw-r--r-- | ext/dbx/tests/005.phpt | 5 | ||||
-rw-r--r-- | ext/dbx/tests/006.phpt | 6 | ||||
-rw-r--r-- | ext/dbx/tests/dbx_test.p | 10 |
10 files changed, 385 insertions, 8 deletions
diff --git a/ext/dbx/CREDITS b/ext/dbx/CREDITS index 3bc82c5fd3..162f027c02 100644 --- a/ext/dbx/CREDITS +++ b/ext/dbx/CREDITS @@ -7,3 +7,4 @@ pgsql support: Rui Hirokawa (hirokawa@php.net) mssql support: Marc Boeren fbsql support: Frank M. Kromann (frank@frontbase.com) initial oci8 support: Marc Boeren +sybase-ct support: Marc Boeren
\ No newline at end of file diff --git a/ext/dbx/Makefile.in b/ext/dbx/Makefile.in index 07965d071f..db60a1fa8a 100644 --- a/ext/dbx/Makefile.in +++ b/ext/dbx/Makefile.in @@ -1,6 +1,6 @@ LTLIBRARY_NAME = libdbx.la -LTLIBRARY_SOURCES = dbx.c dbx_mysql.c dbx_odbc.c dbx_pgsql.c dbx_mssql.c dbx_fbsql.c dbx_oci8.c +LTLIBRARY_SOURCES = dbx.c dbx_mysql.c dbx_odbc.c dbx_pgsql.c dbx_mssql.c dbx_fbsql.c dbx_oci8.c dbx_sybasect.c LTLIBRARY_SHARED_NAME = dbx.la include $(top_srcdir)/build/dynlib.mk diff --git a/ext/dbx/dbx.c b/ext/dbx/dbx.c index 19b00f8ae6..3cd74ffae3 100644 --- a/ext/dbx/dbx.c +++ b/ext/dbx/dbx.c @@ -39,6 +39,7 @@ #define DBX_MSSQL 4 #define DBX_FBSQL 5 #define DBX_OCI8 6 +#define DBX_SYBASECT 7 /* includes for supported databases */ #include "dbx.h" #include "dbx_mysql.h" @@ -47,6 +48,7 @@ #include "dbx_mssql.h" #include "dbx_fbsql.h" #include "dbx_oci8.h" +#include "dbx_sybasect.h" /* support routines */ int module_exists(char *module_name) @@ -66,6 +68,7 @@ int module_identifier_exists(long module_identifier) case DBX_MSSQL: return module_exists("mssql"); case DBX_FBSQL: return module_exists("fbsql"); case DBX_OCI8: return module_exists("oci8"); + case DBX_SYBASECT: return module_exists("sybase_ct"); } return 0; } @@ -78,6 +81,7 @@ int get_module_identifier(char *module_name) if (!strcmp("mssql", module_name)) return DBX_MSSQL; if (!strcmp("fbsql", module_name)) return DBX_FBSQL; if (!strcmp("oci8", module_name)) return DBX_OCI8; + if (!strcmp("sybase_ct", module_name)) return DBX_SYBASECT; return DBX_UNKNOWN; } @@ -172,6 +176,7 @@ ZEND_MINIT_FUNCTION(dbx) REGISTER_LONG_CONSTANT("DBX_MSSQL", DBX_MSSQL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DBX_FBSQL", DBX_FBSQL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DBX_OCI8", DBX_OCI8, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("DBX_SYBASECT", DBX_SYBASECT, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DBX_PERSISTENT", DBX_PERSISTENT, CONST_CS | CONST_PERSISTENT); @@ -208,7 +213,7 @@ ZEND_MINFO_FUNCTION(dbx) php_info_print_table_start(); php_info_print_table_row(2, "dbx support", "enabled"); php_info_print_table_row(2, "dbx version", "1.0.0"); - php_info_print_table_row(2, "supported databases", "MySQL<br />ODBC<br />PostgreSQL<br />Microsoft SQL Server<br />FrontBase<br />Oracle 8"); + php_info_print_table_row(2, "supported databases", "MySQL<br />ODBC<br />PostgreSQL<br />Microsoft SQL Server<br />FrontBase<br />Oracle 8 (not really)<br />Sybase-CT"); php_info_print_table_end(); } @@ -671,6 +676,7 @@ int switch_dbx_connect(zval **rv, zval **host, zval **db, zval **username, zval case DBX_FBSQL: return dbx_fbsql_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: zend_error(E_WARNING, "dbx_connect: OCI8 extension is still highly experimental!"); return dbx_oci8_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_connect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_connect: not supported in this module"); return 0; @@ -687,6 +693,7 @@ int switch_dbx_pconnect(zval **rv, zval **host, zval **db, zval **username, zval case DBX_FBSQL: return dbx_fbsql_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: zend_error(E_WARNING, "dbx_pconnect: OCI8 extension is still highly experimental!"); return dbx_oci8_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_pconnect(rv, host, db, username, password, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_pconnect: not supported in this module"); return 0; @@ -702,6 +709,7 @@ int switch_dbx_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, case DBX_MSSQL: return dbx_mssql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_FBSQL: return dbx_fbsql_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: return dbx_oci8_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_close(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_close: not supported in this module"); return 0; @@ -717,6 +725,7 @@ int switch_dbx_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_st case DBX_MSSQL: return dbx_mssql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_FBSQL: return dbx_fbsql_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: return dbx_oci8_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_query(rv, dbx_handle, db_name, sql_statement, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_query: not supported in this module"); return 0; @@ -732,6 +741,7 @@ int switch_dbx_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION case DBX_MSSQL: return dbx_mssql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_FBSQL: return dbx_fbsql_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: return dbx_oci8_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_getcolumncount(rv, result_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_getcolumncount: not supported in this module"); return 0; @@ -747,6 +757,7 @@ int switch_dbx_getcolumnname(zval **rv, zval **result_handle, long column_index, case DBX_MSSQL: return dbx_mssql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_FBSQL: return dbx_fbsql_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: return dbx_oci8_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_getcolumnname(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_getcolumnname: not supported in this module"); return 0; @@ -762,6 +773,7 @@ int switch_dbx_getcolumntype(zval **rv, zval **result_handle, long column_index, case DBX_MSSQL: return dbx_mssql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_FBSQL: return dbx_fbsql_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: return dbx_oci8_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_getcolumntype(rv, result_handle, column_index, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_getcolumntype: not supported in this module"); return 0; @@ -777,6 +789,7 @@ int switch_dbx_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL case DBX_MSSQL: return dbx_mssql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_FBSQL: return dbx_fbsql_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: return dbx_oci8_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_getrow(rv, result_handle, row_number, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_getrow: not supported in this module"); return 0; @@ -792,6 +805,7 @@ int switch_dbx_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS, case DBX_MSSQL: return dbx_mssql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_FBSQL: return dbx_fbsql_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); case DBX_OCI8: return dbx_oci8_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); + case DBX_SYBASECT: return dbx_sybasect_error(rv, dbx_handle, INTERNAL_FUNCTION_PARAM_PASSTHRU); } zend_error(E_WARNING, "dbx_error: not supported in this module"); return 0; diff --git a/ext/dbx/dbx.dsp b/ext/dbx/dbx.dsp index bb2fa635b2..d4f5951490 100644 --- a/ext/dbx/dbx.dsp +++ b/ext/dbx/dbx.dsp @@ -1,6 +1,6 @@ # Microsoft Developer Studio Project File - Name="dbx" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# **DO NOT EDIT **
+# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
@@ -120,6 +120,10 @@ SOURCE=.\dbx_odbc.c SOURCE=.\dbx_pgsql.c
# End Source File
+# Begin Source File
+
+SOURCE=.\dbx_sybasect.c
+# End Source File
# End Group
# Begin Group "Header Files"
@@ -154,6 +158,10 @@ SOURCE=.\dbx_pgsql.h # End Source File
# Begin Source File
+SOURCE=.\dbx_sybasect.h
+# End Source File
+# Begin Source File
+
SOURCE=.\php_dbx.h
# End Source File
# End Group
diff --git a/ext/dbx/dbx_sybasect.c b/ext/dbx/dbx_sybasect.c new file mode 100644 index 0000000000..7c51c33ebb --- /dev/null +++ b/ext/dbx/dbx_sybasect.c @@ -0,0 +1,282 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2002 The PHP Group | + +----------------------------------------------------------------------+ + | dbx module version 1.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 2001 Guidance Rotterdam BV | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | 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. | + +----------------------------------------------------------------------+ + | Author : Marc Boeren <marc@guidance.nl> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#include "dbx.h" +#include "dbx_sybasect.h" + +#define MYSQL_ASSOC 1<<0 +#define MYSQL_NUM 1<<1 + +int dbx_sybasect_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns connection handle as resource on success or 0 as long on failure */ + int number_of_arguments=3; + zval **arguments[3]; + zval *returned_zval=NULL; + zval *select_db_zval=NULL; + + arguments[0]=host; + arguments[1]=username; + arguments[2]=password; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_connect", &returned_zval, number_of_arguments, arguments); + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_RESOURCE) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + return 0; + } + + number_of_arguments=2; + arguments[0]=db; + arguments[1]=&returned_zval; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_select_db", &select_db_zval, number_of_arguments, arguments); + if (!select_db_zval || (Z_TYPE_P(select_db_zval)==IS_BOOL && Z_LVAL_P(select_db_zval)==0) ) { + if (select_db_zval) zval_ptr_dtor(&select_db_zval); + /* also close connection */ + number_of_arguments=1; + arguments[0]=&returned_zval; + zend_list_addref(Z_LVAL_P(returned_zval)); + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_close", &select_db_zval, number_of_arguments, arguments); + if (select_db_zval) zval_ptr_dtor(&select_db_zval); + zval_ptr_dtor(&returned_zval); + return 0; + } + zval_ptr_dtor(&select_db_zval); + + MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns persistent connection handle as resource on success or 0 as long on failure */ + int number_of_arguments=3; + zval **arguments[3]; + zval *returned_zval=NULL; + zval *select_db_zval=NULL; + + arguments[0]=host; + arguments[1]=username; + arguments[2]=password; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_pconnect", &returned_zval, number_of_arguments, arguments); + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_RESOURCE) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + return 0; + } + + number_of_arguments=2; + arguments[0]=db; + arguments[1]=&returned_zval; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_select_db", &select_db_zval, number_of_arguments, arguments); + if (!select_db_zval || (Z_TYPE_P(select_db_zval)==IS_BOOL && Z_LVAL_P(select_db_zval)==0) ) { + if (select_db_zval) zval_ptr_dtor(&select_db_zval); + /* also close connection */ + number_of_arguments=1; + arguments[0]=&returned_zval; + zend_list_addref(Z_LVAL_P(returned_zval)); + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_close", &select_db_zval, number_of_arguments, arguments); + if (select_db_zval) zval_ptr_dtor(&select_db_zval); + zval_ptr_dtor(&returned_zval); + return 0; + } + zval_ptr_dtor(&select_db_zval); + + MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns 1 as long on success or 0 as long on failure */ + int number_of_arguments=1; + zval **arguments[1]; + zval *returned_zval=NULL; + + arguments[0]=dbx_handle; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_close", &returned_zval, number_of_arguments, arguments); + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_BOOL) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + return 0; + } + MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns 1 as long or a result identifier as resource on success or 0 as long on failure */ + int number_of_arguments=2; + zval **arguments[2]; + zval *returned_zval=NULL; + zval *select_db_zval=NULL; + + number_of_arguments=2; + arguments[0]=db_name; + arguments[1]=dbx_handle; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_select_db", &select_db_zval, number_of_arguments, arguments); + zval_ptr_dtor(&select_db_zval); + + number_of_arguments=2; + arguments[0]=sql_statement; + arguments[1]=dbx_handle; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_query", &returned_zval, number_of_arguments, arguments); + /* sybase_query returns a bool for success or failure, or a result_identifier for select statements */ + if (!returned_zval || (Z_TYPE_P(returned_zval)!=IS_BOOL && Z_TYPE_P(returned_zval)!=IS_RESOURCE)) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + return 0; + } + MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns column-count as long on success or 0 as long on failure */ + int number_of_arguments=1; + zval **arguments[1]; + zval *returned_zval=NULL; + + arguments[0]=result_handle; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_num_fields", &returned_zval, number_of_arguments, arguments); + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_LONG) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + return 0; + } + MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns column-name as string on success or 0 as long on failure */ + int number_of_arguments=2; + zval **arguments[2]; + zval *zval_column_index; + zval *returned_zval=NULL; + zval **zv_name=NULL; + + MAKE_STD_ZVAL(zval_column_index); + ZVAL_LONG(zval_column_index, column_index); + arguments[0]=result_handle; + arguments[1]=&zval_column_index; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_fetch_field", &returned_zval, number_of_arguments, arguments); + /* sybase_fetch_field returns an object */ + /* we need only the 'name' member here */ + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_OBJECT) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + FREE_ZVAL(zval_column_index); + return 0; + } + if (zend_hash_find(returned_zval->value.obj.properties, "name", 5, (void **) &zv_name)==FAILURE) { + zval_ptr_dtor(&returned_zval); + FREE_ZVAL(zval_column_index); + return 0; + } + + **rv = **zv_name; + zval_copy_ctor(*rv); + zval_ptr_dtor(&returned_zval); + zval_ptr_dtor(zv_name); + + FREE_ZVAL(zval_column_index); +// MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns column-type as string on success or 0 as long on failure */ + int number_of_arguments=2; + zval **arguments[2]; + zval *zval_column_index; + zval *returned_zval=NULL; + zval **zv_type=NULL; + + MAKE_STD_ZVAL(zval_column_index); + ZVAL_LONG(zval_column_index, column_index); + arguments[0]=result_handle; + arguments[1]=&zval_column_index; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_fetch_field", &returned_zval, number_of_arguments, arguments); + /* sybase_fetch_field returns an object */ + /* we need only the 'type' member here */ + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_OBJECT) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + FREE_ZVAL(zval_column_index); + return 0; + } + if (zend_hash_find(returned_zval->value.obj.properties, "type", 5, (void **) &zv_type)==FAILURE) { + zval_ptr_dtor(&returned_zval); + FREE_ZVAL(zval_column_index); + return 0; + } + + **rv = **zv_type; + zval_copy_ctor(*rv); + zval_ptr_dtor(&returned_zval); + zval_ptr_dtor(zv_type); + + FREE_ZVAL(zval_column_index); +// MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns array[0..columncount-1] as strings on success or 0 as long on failure */ + int number_of_arguments=1; + zval **arguments[1]; + zval *returned_zval=NULL; + + arguments[0]=result_handle; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_fetch_row", &returned_zval, number_of_arguments, arguments); + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_ARRAY) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + return 0; + } + MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +int dbx_sybasect_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS) +{ + /* returns string */ + int number_of_arguments=1; + zval **arguments[1]; + zval *returned_zval=NULL; + + arguments[0]=dbx_handle; + if (!dbx_handle) number_of_arguments=0; + dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "sybase_get_last_message", &returned_zval, number_of_arguments, arguments); + if (!returned_zval || Z_TYPE_P(returned_zval)!=IS_STRING) { + if (returned_zval) zval_ptr_dtor(&returned_zval); + return 0; + } + MOVE_RETURNED_TO_RV(rv, returned_zval); + return 1; +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ diff --git a/ext/dbx/dbx_sybasect.h b/ext/dbx/dbx_sybasect.h new file mode 100644 index 0000000000..6aacec8c32 --- /dev/null +++ b/ext/dbx/dbx_sybasect.h @@ -0,0 +1,60 @@ +/* + +----------------------------------------------------------------------+ + | PHP Version 4 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2002 The PHP Group | + +----------------------------------------------------------------------+ + | dbx module version 1.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 2001 Guidance Rotterdam BV | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | 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. | + +----------------------------------------------------------------------+ + | Author : Marc Boeren <marc@guidance.nl> | + +----------------------------------------------------------------------+ +*/ + +/* $Id$ */ + +#ifndef ZEND_DBX_MYSQL_H +#define ZEND_DBX_MYSQL_H + +#ifndef INIT_FUNC_ARGS +#include "zend_modules.h" +#endif + +#include "php.h" + +int dbx_sybasect_connect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS); + /* returns connection handle as resource on success or 0 as long on failure */ +int dbx_sybasect_pconnect(zval **rv, zval **host, zval **db, zval **username, zval **password, INTERNAL_FUNCTION_PARAMETERS); + /* returns persistent connection handle as resource on success or 0 as long on failure */ +int dbx_sybasect_close(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS); + /* returns 1 as long on success or 0 as long on failure */ +int dbx_sybasect_query(zval **rv, zval **dbx_handle, zval **db_name, zval **sql_statement, INTERNAL_FUNCTION_PARAMETERS); + /* returns 1 as long or a result identifier as resource on success or 0 as long on failure */ +int dbx_sybasect_getcolumncount(zval **rv, zval **result_handle, INTERNAL_FUNCTION_PARAMETERS); + /* returns column-count as long on success or 0 as long on failure */ +int dbx_sybasect_getcolumnname(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS); + /* returns column-name as string on success or 0 as long on failure */ +int dbx_sybasect_getcolumntype(zval **rv, zval **result_handle, long column_index, INTERNAL_FUNCTION_PARAMETERS); + /* returns column-type as string on success or 0 as long on failure */ +int dbx_sybasect_getrow(zval **rv, zval **result_handle, long row_number, INTERNAL_FUNCTION_PARAMETERS); + /* returns array[0..columncount-1] as strings on success or 0 as long on failure */ +int dbx_sybasect_error(zval **rv, zval **dbx_handle, INTERNAL_FUNCTION_PARAMETERS); + /* returns string */ + +#endif /* ZEND_DBX_MYSQL_H */ + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + */ diff --git a/ext/dbx/tests/002.phpt b/ext/dbx/tests/002.phpt index 78201a4ff6..f9dff86155 100644 --- a/ext/dbx/tests/002.phpt +++ b/ext/dbx/tests/002.phpt @@ -12,6 +12,7 @@ if (DBX_PGSQL=="DBX_PGSQL") print('!DBX_PGSQL'); if (DBX_MSSQL=="DBX_MSSQL") print('!DBX_MSSQL'); if (DBX_FBSQL=="DBX_FBSQL") print('!DBX_FBSQL'); if (DBX_OCI8=="DBX_OCI8") print('!DBX_OCI8'); +if (DBX_SYBASECT=="DBX_SYBASECT") print('!DBX_SYBASECT'); if (DBX_PERSISTENT=="DBX_PERSISTENT") print('!DBX_PERSISTENT'); if (DBX_RESULT_INFO=="DBX_RESULT_INFO") print('!DBX_RESULT_INFO'); if (DBX_RESULT_INDEX=="DBX_RESULT_INDEX") print('!DBX_RESULT_INDEX'); diff --git a/ext/dbx/tests/005.phpt b/ext/dbx/tests/005.phpt index 4ee7f7c5a7..447fb3625c 100644 --- a/ext/dbx/tests/005.phpt +++ b/ext/dbx/tests/005.phpt @@ -18,6 +18,9 @@ if (!$dlo) { print('this won\'t work'."\n"); } else { + // especially for sybase I need to set the textsize to >64 k, as one of the test-fields + // requires this (shouldn't this be a php.ini-entry??) + if ($connection === DBX_SYBASECT) @dbx_query($dlo, "set textsize 100000"); // select query if ($dro=dbx_query($dlo, $sql_statement)) { for ($i=0; $i<$dro->rows; ++$i) { @@ -87,4 +90,4 @@ delete-query: dbx_query works ok wrong dbx_link_object: query failure works ok wrong sql-statement: query failure works ok too many parameters: query failure works ok -too few parameters: query failure works ok
\ No newline at end of file +too few parameters: query failure works ok diff --git a/ext/dbx/tests/006.phpt b/ext/dbx/tests/006.phpt index cfe1e48b97..b4f29b51f8 100644 --- a/ext/dbx/tests/006.phpt +++ b/ext/dbx/tests/006.phpt @@ -25,12 +25,12 @@ if (!$dlo) { } else { @dbx_query($dlo, "select nonexistingfield from tbl"); - if (($module==DBX_MSSQL && dbx_error($dlo)!="Changed database context to '".$database."'.") + if ((($module==DBX_MSSQL || $module==DBX_SYBASECT) && dbx_error($dlo)!="Changed database context to '".$database."'.".($module==DBX_SYBASECT?"\n":"")) || strlen(dbx_error($dlo))) { print('query generated an error: dbx_error works ok'."\n"); } dbx_query($dlo, "select description from tbl"); - if (!strlen(dbx_error($dlo)) || ($module==DBX_MSSQL && dbx_error($dlo)=="Changed database context to '".$database."'.")) { + if (!strlen(dbx_error($dlo)) || (($module==DBX_MSSQL || $module==DBX_SYBASECT) && dbx_error($dlo)=="Changed database context to '".$database."'.".($module==DBX_SYBASECT?"\n":""))) { print('query is valid: dbx_error works ok'."\n"); } if (!@dbx_error(0)) { @@ -52,4 +52,4 @@ query generated an error: dbx_error works ok query is valid: dbx_error works ok wrong dbx_link_object: dbx_error failure works ok too many parameters: dbx_error failure works ok -too few parameters: dbx_error failure works ok
\ No newline at end of file +too few parameters: dbx_error failure works ok diff --git a/ext/dbx/tests/dbx_test.p b/ext/dbx/tests/dbx_test.p index b7a7bc5027..79418b20e0 100644 --- a/ext/dbx/tests/dbx_test.p +++ b/ext/dbx/tests/dbx_test.p @@ -1,5 +1,5 @@ <?php -$connection = DBX_MYSQL; +$connection = DBX_SYBASECT; switch ($connection) { case DBX_MYSQL: $module=DBX_MYSQL; @@ -49,6 +49,14 @@ switch ($connection) { $password="dbx_testpassword"; $module_name="oci8"; break; + case DBX_SYBASECT: + $module=DBX_SYBASECT; + $host="threesyb"; + $database="dbx_test"; + $username="dbx_testuser"; + $password="dbx_testpassword"; + $module_name="sybase_ct"; + break; } ?>
\ No newline at end of file |