mboeren Fri Mar 23 06:50:17 2001 EDT
Modified files:
/php4/ext/dbx Makefile.in dbx.c dbx.dsp dbx_mysql.c dbx_mysql.h
dbx_odbc.c dbx_odbc.h dbx_pgsql.c dbx_pgsql.h
php_dbx.h
Log:
Fixed compile errors for PostgreSQL support (Mc)
Removed globals that Rui put in, and changed the dbx_get_row
to include a row_number (which PostgreSQL expects) (Mc)
Added source files to Makefile.in and dbx.dsp (Mc)
#Could someone please check if the PostgreSQL support works?
#And please, check your work _before_ you commit anything!
Index: php4/ext/dbx/Makefile.in
diff -u php4/ext/dbx/Makefile.in:1.1 php4/ext/dbx/Makefile.in:1.2
--- php4/ext/dbx/Makefile.in:1.1 Thu Mar 22 03:07:04 2001
+++ php4/ext/dbx/Makefile.in Fri Mar 23 06:50:16 2001
@@ -1,6 +1,6 @@
LTLIBRARY_NAME = libdbx.la
-LTLIBRARY_SOURCES = dbx.c dbx_mysql.c dbx_odbc.c
+LTLIBRARY_SOURCES = dbx.c dbx_mysql.c dbx_odbc.c dbx_pgsql.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.4 php4/ext/dbx/dbx.c:1.5
--- php4/ext/dbx/dbx.c:1.4 Fri Mar 23 03:50:04 2001
+++ php4/ext/dbx/dbx.c Fri Mar 23 06:50:16 2001
@@ -96,27 +96,30 @@
/*/ returns column-name as string on success or 0 as long on failure /*/
int switch_dbx_getcolumntype(zval ** rv, zval ** result_handle, long column_index,
INTERNAL_FUNCTION_PARAMETERS, zval ** dbx_module);
/*/ returns column-type as string on success or 0 as long on failure /*/
-int switch_dbx_getrow(zval ** rv, zval ** result_handle,
INTERNAL_FUNCTION_PARAMETERS, zval ** dbx_module);
+int switch_dbx_getrow(zval ** rv, zval ** result_handle, long row_number,
+INTERNAL_FUNCTION_PARAMETERS, zval ** dbx_module);
/*/ returns array[0..columncount-1] as strings on success or 0 as long on failure
/*/
int switch_dbx_error(zval ** rv, zval ** dbx_handle, INTERNAL_FUNCTION_PARAMETERS,
zval ** dbx_module);
/*/ returns string /*/
-
+/*
#ifdef ZTS
int dbx_globals_id;
#else
ZEND_DBX_API zend_dbx_globals dbx_globals;
#endif
+*/
/* If you declare any globals in php_dbx.h uncomment this: */
/* ZEND_DECLARE_MODULE_GLOBALS(dbx) */
/* True global resources - no need for thread safety here */
+/*
static int le_dbx;
-
+*/
+/*
static void zend_dbx_init_globals(PGLS_D)
{
DBXG(row_count) = 0;
DBXG(num_rows) = 0;
}
-
+*/
/* Every user visible function must have an entry in dbx_functions[].
*/
function_entry dbx_functions[] = {
@@ -155,13 +158,13 @@
/*/
ZEND_MINIT_FUNCTION(dbx)
{
-
+/*
#ifdef ZTS
dbx_globals_id = ts_allocate_id(sizeof(zend_dbx_globals), (ts_allocate_ctor)
zend_dbx_init_globals, NULL);
#else
zend_dbx_init_globals(DBXLS_C);
#endif
-
+*/
/*/ REGISTER_INI_ENTRIES(); /*/
REGISTER_LONG_CONSTANT("DBX_PERSISTENT", DBX_PERSISTENT, CONST_CS |
CONST_PERSISTENT);
@@ -455,7 +458,7 @@
while (result) {
zval * rv_row;
MAKE_STD_ZVAL(rv_row);
- result = switch_dbx_getrow(&rv_row, &rv_result_handle,
INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
+ result = switch_dbx_getrow(&rv_row, &rv_result_handle, row_count,
+INTERNAL_FUNCTION_PARAM_PASSTHRU, dbx_module);
if (result) {
/*/ if (row_count>=result_row_offset && (result_row_count==-1 ||
row_count<result_row_offset+result_row_count)) { /*/
zval ** row_ptr;
@@ -762,12 +765,12 @@
return 0;
}
-int switch_dbx_getrow(zval ** rv, zval ** result_handle,
INTERNAL_FUNCTION_PARAMETERS, zval ** dbx_module) {
+int switch_dbx_getrow(zval ** rv, zval ** result_handle, long row_number,
+INTERNAL_FUNCTION_PARAMETERS, zval ** dbx_module) {
/*/ returns array[0..columncount-1] as strings on success or 0 as long on failure
/*/
switch ((*dbx_module)->value.lval) {
- case DBX_MYSQL: return dbx_mysql_getrow(rv, result_handle,
INTERNAL_FUNCTION_PARAM_PASSTHRU);
- case DBX_ODBC: return dbx_odbc_getrow(rv, result_handle,
INTERNAL_FUNCTION_PARAM_PASSTHRU);
- case DBX_PGSQL: return dbx_pgsql_getrow(rv, result_handle,
INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ case DBX_MYSQL: return dbx_mysql_getrow(rv, result_handle, row_number,
+INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ case DBX_ODBC: return dbx_odbc_getrow(rv, result_handle, row_number,
+INTERNAL_FUNCTION_PARAM_PASSTHRU);
+ case DBX_PGSQL: return dbx_pgsql_getrow(rv, result_handle, row_number,
+INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
zend_error(E_WARNING, "dbx_getrow: not supported in this module");
return 0;
Index: php4/ext/dbx/dbx.dsp
diff -u php4/ext/dbx/dbx.dsp:1.2 php4/ext/dbx/dbx.dsp:1.3
--- php4/ext/dbx/dbx.dsp:1.2 Fri Mar 23 02:23:58 2001
+++ php4/ext/dbx/dbx.dsp Fri Mar 23 06:50:17 2001
@@ -104,6 +104,10 @@
SOURCE=.\dbx_odbc.c
# End Source File
+# Begin Source File
+
+SOURCE=.\dbx_pgsql.c
+# End Source File
# End Group
# Begin Group "Header Files"
@@ -119,6 +123,10 @@
# Begin Source File
SOURCE=.\dbx_odbc.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\dbx_pgsql.h
# End Source File
# Begin Source File
Index: php4/ext/dbx/dbx_mysql.c
diff -u php4/ext/dbx/dbx_mysql.c:1.3 php4/ext/dbx/dbx_mysql.c:1.4
--- php4/ext/dbx/dbx_mysql.c:1.3 Fri Mar 23 02:23:58 2001
+++ php4/ext/dbx/dbx_mysql.c Fri Mar 23 06:50:17 2001
@@ -174,7 +174,7 @@
return 1;
}
-int dbx_mysql_getrow(zval ** rv, zval ** result_handle, INTERNAL_FUNCTION_PARAMETERS)
{
+int dbx_mysql_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=2;
zval ** arguments[2];
Index: php4/ext/dbx/dbx_mysql.h
diff -u php4/ext/dbx/dbx_mysql.h:1.3 php4/ext/dbx/dbx_mysql.h:1.4
--- php4/ext/dbx/dbx_mysql.h:1.3 Fri Mar 23 02:23:58 2001
+++ php4/ext/dbx/dbx_mysql.h Fri Mar 23 06:50:17 2001
@@ -43,7 +43,7 @@
/*/ returns column-name as string on success or 0 as long on failure /*/
int dbx_mysql_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_mysql_getrow(zval ** rv, zval ** result_handle, INTERNAL_FUNCTION_PARAMETERS);
+int dbx_mysql_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_mysql_error(zval ** rv, zval ** dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
/*/ returns string /*/
Index: php4/ext/dbx/dbx_odbc.c
diff -u php4/ext/dbx/dbx_odbc.c:1.3 php4/ext/dbx/dbx_odbc.c:1.4
--- php4/ext/dbx/dbx_odbc.c:1.3 Fri Mar 23 02:23:58 2001
+++ php4/ext/dbx/dbx_odbc.c Fri Mar 23 06:50:17 2001
@@ -173,7 +173,7 @@
return 1;
}
-int dbx_odbc_getrow(zval ** rv, zval ** result_handle, INTERNAL_FUNCTION_PARAMETERS) {
+int dbx_odbc_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;
zval ** arguments[2];
Index: php4/ext/dbx/dbx_odbc.h
diff -u php4/ext/dbx/dbx_odbc.h:1.3 php4/ext/dbx/dbx_odbc.h:1.4
--- php4/ext/dbx/dbx_odbc.h:1.3 Fri Mar 23 02:23:58 2001
+++ php4/ext/dbx/dbx_odbc.h Fri Mar 23 06:50:17 2001
@@ -43,7 +43,7 @@
/*/ returns column-name as string on success or 0 as long on failure /*/
int dbx_odbc_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_odbc_getrow(zval ** rv, zval ** result_handle, INTERNAL_FUNCTION_PARAMETERS);
+int dbx_odbc_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_odbc_error(zval ** rv, zval ** dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
/*/ returns string /*/
Index: php4/ext/dbx/dbx_pgsql.c
diff -u php4/ext/dbx/dbx_pgsql.c:1.2 php4/ext/dbx/dbx_pgsql.c:1.3
--- php4/ext/dbx/dbx_pgsql.c:1.2 Fri Mar 23 05:40:12 2001
+++ php4/ext/dbx/dbx_pgsql.c Fri Mar 23 06:50:17 2001
@@ -20,13 +20,13 @@
#include "php_dbx.h"
#include "dbx_pgsql.h"
#include <string.h>
-
+/*
#ifdef ZTS
extern int dbx_globals_id;
#else
extern ZEND_DBX_API zend_dbx_globals dbx_globals;
#endif
-
+*/
#define PGSQL_ASSOC 1<<0
#define PGSQL_NUM 1<<1
@@ -153,7 +153,7 @@
return 0;
}
MOVE_RETURNED_TO_RV(rv, returned_zval);
-
+/*
if(strstr(Z_STRVAL_PP(sql_statement), "SELECT") ||
strstr(Z_STRVAL_PP(sql_statement), "select")){
DBXG(row_count) = 0;
@@ -163,7 +163,7 @@
dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_numrows",
&num_rows_zval, nargs, args);
DBXG(num_rows) = Z_LVAL_P(num_rows_zval);
}
-
+*/
return 1;
}
@@ -229,7 +229,7 @@
return 1;
}
-int dbx_pgsql_getrow(zval ** rv, zval ** result_handle, INTERNAL_FUNCTION_PARAMETERS)
{
+int dbx_pgsql_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=2;
@@ -238,13 +238,15 @@
zval * returned_zval=NULL;
MAKE_STD_ZVAL(zval_row);
- ZVAL_LONG(zval_row, DBXG(row_count));
+ ZVAL_LONG(zval_row, row_number);
arguments[0]=result_handle;
arguments[1]=&zval_row;
+/*
DBXG(row_count)++;
if (DBXG(row_count)>DBXG(num_rows)){
return 0;
}
+*/
dbx_call_any_function(INTERNAL_FUNCTION_PARAM_PASSTHRU, "pg_fetch_array",
&returned_zval, number_of_arguments, arguments);
if (!returned_zval || returned_zval->type!=IS_ARRAY) {
if (returned_zval) zval_ptr_dtor(&returned_zval);
Index: php4/ext/dbx/dbx_pgsql.h
diff -u php4/ext/dbx/dbx_pgsql.h:1.2 php4/ext/dbx/dbx_pgsql.h:1.3
--- php4/ext/dbx/dbx_pgsql.h:1.2 Fri Mar 23 05:40:12 2001
+++ php4/ext/dbx/dbx_pgsql.h Fri Mar 23 06:50:17 2001
@@ -39,7 +39,7 @@
/*/ returns column-name as string on success or 0 as long on failure /*/
int dbx_pgsql_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_pgsql_getrow(zval ** rv, zval ** result_handle, INTERNAL_FUNCTION_PARAMETERS);
+int dbx_pgsql_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_pgsql_error(zval ** rv, zval ** dbx_handle, INTERNAL_FUNCTION_PARAMETERS);
/*/ returns string /*/
Index: php4/ext/dbx/php_dbx.h
diff -u php4/ext/dbx/php_dbx.h:1.4 php4/ext/dbx/php_dbx.h:1.5
--- php4/ext/dbx/php_dbx.h:1.4 Fri Mar 23 03:50:04 2001
+++ php4/ext/dbx/php_dbx.h Fri Mar 23 06:50:17 2001
@@ -58,11 +58,12 @@
Declare any global variables you may need between the BEGIN
and END macros here:
*/
+/*
ZEND_BEGIN_MODULE_GLOBALS(dbx)
int row_count;
int num_rows;
ZEND_END_MODULE_GLOBALS(dbx)
-
+*/
/* In every function that needs to use variables in php_dbx_globals,
do call dbxLS_FETCH(); after declaring other variables used by
that function, and always refer to them as dbxG(variable).
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]