mboeren Thu Mar 22 03:07:04 2001 EDT
Added files:
/php4/ext/dbx CREDITS INSTALL LICENSE Makefile.in config.m4 dbx.c
dbx.dsp dbx.h dbx_mysql.c dbx_mysql.h dbx_odbc.c
dbx_odbc.h php_dbx.h
Log:
Added dbx module (database abstraction) to the repositorty (/ext/dbx).
Compiles under Linux (--enable-dbx) and Windows.
Supports MySQL and ODBC modules (more to be added later).
@ Added dbx module (database abstraction) to the repository. (Marc)
Index: php4/ext/dbx/Makefile.in
+++ php4/ext/dbx/Makefile.in
LTLIBRARY_NAME = libdbx.la
LTLIBRARY_SOURCES = dbx.c dbx_mysql.c dbx_odbc.c
LTLIBRARY_SHARED_NAME = dbx.la
include $(top_srcdir)/build/dynlib.mk
Index: php4/ext/dbx/config.m4
+++ php4/ext/dbx/config.m4
PHP_ARG_ENABLE(dbx,whether to enable dbx support,
[ --enable-dbxEnable dbx])
if test "$PHP_DBX" != "no"; then
PHP_EXTENSION(dbx, $ext_shared)
fi
Index: php4/ext/dbx/dbx.c
+++ php4/ext/dbx/dbx.c
/*
+--+
| stentor module version 1.0 |
+--+
| Copyright (c) 2001 Guidance Rotterdam BV |
+--+
| This source file is subject to version 1.0 of the STENTOR license, |
| that is bundled with this package in the file LICENSE, and is|
| available through the world-wide-web at |
| http://www.guidance.nl/php/dbx/license/1_00.txt. |
| If you did not receive a copy of the STENTOR license and are unable |
| to obtain it through the world-wide-web, please send a note to |
| [EMAIL PROTECTED] so we can mail you a copy immediately. |
+--+
| Author : Marc Boeren [EMAIL PROTECTED] |
+--+
*/
#include "php.h"
#include "php_ini.h"
#include "php_config.h"
#include "php_dbx.h"
#include "ext/standard/info.h"
// defines for supported databases
#define DBX_UNKNOWN 0
#define DBX_MYSQL 1
#define DBX_ODBC 2
// includes for supported databases
#include "dbx.h"
#include "dbx_mysql.h"
#include "dbx_odbc.h"
// support routines
int module_exists(char * module_name) {
zend_module_entry * zme;
int r;
r = zend_hash_find(module_registry, module_name, strlen(module_name)+1, (void **)
zme);
return r==0?1:0;
}
int get_module_identifier(char * module_name) {
if (!strcmp("mysql", module_name)) return DBX_MYSQL;
if (!strcmp("odbc", module_name)) return DBX_ODBC;
return DBX_UNKNOWN;
}
int split_dbx_handle_object(zval ** dbx_object, zval *** pdbx_handle, zval ***
pdbx_module) {
convert_to_object_ex(dbx_object);
if (zend_hash_find((*dbx_object)-value.obj.properties, "handle", 7, (void **)
pdbx_handle)==FAILURE || zend_hash_find((*dbx_object)-value.obj.properties, "module",
7, (void **) pdbx_module)==FAILURE) {
return 0;
}
return 1;
}
// from dbx.h, to be used in support-files (dbx_mysql.c etc...)
void dbx_call_any_function(INTERNAL_FUNCTION_PARAMETERS, char * function_name, zval **
returnvalue, int number_of_arguments, zval *** params) {
zval * zval_function_name;
MAKE_STD_ZVAL(zval_function_name);
ZVAL_STRING(zval_function_name, function_name, 1);
if (call_user_function_ex(EG(function_table), NULL, zval_function_name,
returnvalue, number_of_arguments, params, 0, NULL) == FAILURE) {
zend_error(E_ERROR, "function '%s' not found",
zval_function_name-value.str.val);
}
zval_dtor(zval_function_name); // to free stringvalue memory
FREE_ZVAL(zval_function_name);
}
// switch_dbx functions declarations
// each must be supported in the x/dbx_module files as dbx_module_function,
// e.g. switch_dbx_connect expects a dbx_mysql_connect in de x/dbx_mysql files
// all params except the dbx_module param are passed on
// each must return the expected zval * 's in the rv parameter, which are passed on
unmodified
// do NOT use the return_value parameter from INTERNAL_FUNCTION_PARAMETERS
// you can additionally return 0 or 1 for failure or success which will also be
returned by the switches
int switch_dbx_connect(zval ** rv, zval ** host, zval ** db, zval ** username, zval **
password, INTERNAL_FUNCTION_PARAMETERS, zval ** dbx_module);
// returns connection handle as resource on success or 0 as long on failure
int switch_dbx_pconnect(zval ** rv, zval ** host, zval ** db, zval ** username, zval
** password, INTERNAL_FUNCTION_PARAMETERS, zval ** dbx_module);
// returns persistent connection handle as resource on success or 0 as long on
failure
int switch_dbx_close(zval ** rv,