cvs: php4 /ext/dbx CREDITS Makefile.in dbx.c dbx.dsp dbx_sybasect.c dbx_sybasect.h /ext/dbx/tests 002.phpt 005.phpt 006.phpt dbx_test.p
| From: | Marc Boeren | Date: | Mon, 18 Feb 2002 09:21:51 +0000 |
| Subject: | cvs: php4 /ext/dbx CREDITS Makefile.in dbx.c dbx.dsp dbx_sybasect.c dbx_sybasect.h /ext/dbx/tests 002.phpt 005.phpt 006.phpt dbx_test.p | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-9391@lists.php.net to get a copy of this message | ||
mboeren Mon Feb 18 04:21:51 2002 EDT
Added files:
/php4/ext/dbx dbx_sybasect.c dbx_sybasect.h
Modified files:
/php4/ext/dbx CREDITS Makefile.in dbx.c dbx.dsp
/php4/ext/dbx/tests 002.phpt 005.phpt 006.phpt dbx_test.p
Log:
Added support for Sybase-CT to dbx module (Mc).
Index: php4/ext/dbx/CREDITS diff -u php4/ext/dbx/CREDITS:1.5 php4/ext/dbx/CREDITS:1.6 --- php4/ext/dbx/CREDITS:1.5 Fri Aug 17 08:54:23 2001 +++ php4/ext/dbx/CREDITS Mon Feb 18 04:21:51 2002 @@ -7,3 +7,4 @@ 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 Index: php4/ext/dbx/Makefile.in diff -u php4/ext/dbx/Makefile.in:1.5 php4/ext/dbx/Makefile.in:1.6 --- php4/ext/dbx/Makefile.in:1.5 Fri Aug 17 08:54:23 2001 +++ php4/ext/dbx/Makefile.in Mon Feb 18 04:21:51 2002 @@ -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 Index: php4/ext/dbx/dbx.c diff -u php4/ext/dbx/dbx.c:1.32 php4/ext/dbx/dbx.c:1.33 --- php4/ext/dbx/dbx.c:1.32 Tue Dec 11 10:29:04 2001 +++ php4/ext/dbx/dbx.c Mon Feb 18 04:21:51 2002 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dbx.c,v 1.32 2001/12/11 15:29:04 sebastian Exp $ */ +/* $Id: dbx.c,v 1.33 2002/02/18 09:21:51 mboeren Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; Index: php4/ext/dbx/dbx.dsp diff -u php4/ext/dbx/dbx.dsp:1.7 php4/ext/dbx/dbx.dsp:1.8 --- php4/ext/dbx/dbx.dsp:1.7 Fri Aug 17 09:00:46 2001 +++ php4/ext/dbx/dbx.dsp Mon Feb 18 04:21:51 2002 @@ -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_pgsql.c # End Source File +# Begin Source File + +SOURCE=.\dbx_sybasect.c +# End Source File # End Group # Begin Group "Header Files" @@ -151,6 +155,10 @@ # Begin Source File SOURCE=.\dbx_pgsql.h +# End Source File +# Begin Source File + +SOURCE=.\dbx_sybasect.h # End Source File # Begin Source File Index: php4/ext/dbx/tests/002.phpt diff -u php4/ext/dbx/tests/002.phpt:1.4 php4/ext/dbx/tests/002.phpt:1.5 --- php4/ext/dbx/tests/002.phpt:1.4 Fri Aug 17 08:54:24 2001 +++ php4/ext/dbx/tests/002.phpt Mon Feb 18 04:21:51 2002 @@ -12,6 +12,7 @@ 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'); Index: php4/ext/dbx/tests/005.phpt diff -u php4/ext/dbx/tests/005.phpt:1.2 php4/ext/dbx/tests/005.phpt:1.3 --- php4/ext/dbx/tests/005.phpt:1.2 Thu Jul 19 11:44:58 2001 +++ php4/ext/dbx/tests/005.phpt Mon Feb 18 04:21:51 2002 @@ -18,6 +18,9 @@ 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 @@ 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 Index: php4/ext/dbx/tests/006.phpt diff -u php4/ext/dbx/tests/006.phpt:1.2 php4/ext/dbx/tests/006.phpt:1.3 --- php4/ext/dbx/tests/006.phpt:1.2 Wed Jun 13 09:35:17 2001 +++ php4/ext/dbx/tests/006.phpt Mon Feb 18 04:21:51 2002 @@ -25,12 +25,12 @@ } 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 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 Index: php4/ext/dbx/tests/dbx_test.p diff -u php4/ext/dbx/tests/dbx_test.p:1.5 php4/ext/dbx/tests/dbx_test.p:1.6 --- php4/ext/dbx/tests/dbx_test.p:1.5 Fri Aug 17 08:54:24 2001 +++ php4/ext/dbx/tests/dbx_test.p Mon Feb 18 04:21:51 2002 @@ -1,5 +1,5 @@ <?php -$connection = DBX_MYSQL; +$connection = DBX_SYBASECT; switch ($connection) { case DBX_MYSQL: $module=DBX_MYSQL; @@ -48,6 +48,14 @@ $username="dbx_testuser"; $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; } Index: php4/ext/dbx/dbx_sybasect.c +++ php4/ext/dbx/dbx_sybasect.c /* +----------------------------------------------------------------------+ | 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: dbx_sybasect.c,v 1.1 2002/02/18 09:21:51 mboeren Exp $ */ #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: */ Index: php4/ext/dbx/dbx_sybasect.h +++ php4/ext/dbx/dbx_sybasect.h /* +----------------------------------------------------------------------+ | 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: dbx_sybasect.h,v 1.1 2002/02/18 09:21:51 mboeren Exp $ */ #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: */
Index: php4/ext/dbx/CREDITS diff -u php4/ext/dbx/CREDITS:1.5 php4/ext/dbx/CREDITS:1.6 --- php4/ext/dbx/CREDITS:1.5 Fri Aug 17 08:54:23 2001 +++ php4/ext/dbx/CREDITS Mon Feb 18 04:21:51 2002 @@ -7,3 +7,4 @@ 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 Index: php4/ext/dbx/Makefile.in diff -u php4/ext/dbx/Makefile.in:1.5 php4/ext/dbx/Makefile.in:1.6 --- php4/ext/dbx/Makefile.in:1.5 Fri Aug 17 08:54:23 2001 +++ php4/ext/dbx/Makefile.in Mon Feb 18 04:21:51 2002 @@ -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 Index: php4/ext/dbx/dbx.c diff -u php4/ext/dbx/dbx.c:1.32 php4/ext/dbx/dbx.c:1.33 --- php4/ext/dbx/dbx.c:1.32 Tue Dec 11 10:29:04 2001 +++ php4/ext/dbx/dbx.c Mon Feb 18 04:21:51 2002 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dbx.c,v 1.32 2001/12/11 15:29:04 sebastian Exp $ */ +/* $Id: dbx.c,v 1.33 2002/02/18 09:21:51 mboeren Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; Index: php4/ext/dbx/dbx.dsp diff -u php4/ext/dbx/dbx.dsp:1.7 php4/ext/dbx/dbx.dsp:1.8 --- php4/ext/dbx/dbx.dsp:1.7 Fri Aug 17 09:00:46 2001 +++ php4/ext/dbx/dbx.dsp Mon Feb 18 04:21:51 2002 @@ -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_pgsql.c # End Source File +# Begin Source File + +SOURCE=.\dbx_sybasect.c +# End Source File # End Group # Begin Group "Header Files" @@ -151,6 +155,10 @@ # Begin Source File SOURCE=.\dbx_pgsql.h +# End Source File +# Begin Source File + +SOURCE=.\dbx_sybasect.h # End Source File # Begin Source File Index: php4/ext/dbx/tests/002.phpt diff -u php4/ext/dbx/tests/002.phpt:1.4 php4/ext/dbx/tests/002.phpt:1.5 --- php4/ext/dbx/tests/002.phpt:1.4 Fri Aug 17 08:54:24 2001 +++ php4/ext/dbx/tests/002.phpt Mon Feb 18 04:21:51 2002 @@ -12,6 +12,7 @@ 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'); Index: php4/ext/dbx/tests/005.phpt diff -u php4/ext/dbx/tests/005.phpt:1.2 php4/ext/dbx/tests/005.phpt:1.3 --- php4/ext/dbx/tests/005.phpt:1.2 Thu Jul 19 11:44:58 2001 +++ php4/ext/dbx/tests/005.phpt Mon Feb 18 04:21:51 2002 @@ -18,6 +18,9 @@ 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 @@ 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 Index: php4/ext/dbx/tests/006.phpt diff -u php4/ext/dbx/tests/006.phpt:1.2 php4/ext/dbx/tests/006.phpt:1.3 --- php4/ext/dbx/tests/006.phpt:1.2 Wed Jun 13 09:35:17 2001 +++ php4/ext/dbx/tests/006.phpt Mon Feb 18 04:21:51 2002 @@ -25,12 +25,12 @@ } 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 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 Index: php4/ext/dbx/tests/dbx_test.p diff -u php4/ext/dbx/tests/dbx_test.p:1.5 php4/ext/dbx/tests/dbx_test.p:1.6 --- php4/ext/dbx/tests/dbx_test.p:1.5 Fri Aug 17 08:54:24 2001 +++ php4/ext/dbx/tests/dbx_test.p Mon Feb 18 04:21:51 2002 @@ -1,5 +1,5 @@ <?php -$connection = DBX_MYSQL; +$connection = DBX_SYBASECT; switch ($connection) { case DBX_MYSQL: $module=DBX_MYSQL; @@ -48,6 +48,14 @@ $username="dbx_testuser"; $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; } Index: php4/ext/dbx/dbx_sybasect.c +++ php4/ext/dbx/dbx_sybasect.c /* +----------------------------------------------------------------------+ | 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: dbx_sybasect.c,v 1.1 2002/02/18 09:21:51 mboeren Exp $ */ #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: */ Index: php4/ext/dbx/dbx_sybasect.h +++ php4/ext/dbx/dbx_sybasect.h /* +----------------------------------------------------------------------+ | 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: dbx_sybasect.h,v 1.1 2002/02/18 09:21:51 mboeren Exp $ */ #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: */