summaryrefslogtreecommitdiff
path: root/ext/dbx
diff options
context:
space:
mode:
authorMarc Boeren <mboeren@php.net>2001-03-23 14:50:17 +0000
committerMarc Boeren <mboeren@php.net>2001-03-23 14:50:17 +0000
commit1a842c4ae667ba185f0166d58068678121ed6bdb (patch)
tree573d1f3533b371a061c8970987e3aab098acca6c /ext/dbx
parent2b2484dd3d7afad942308ebc6f1cfecc80dee045 (diff)
downloadphp-git-1a842c4ae667ba185f0166d58068678121ed6bdb.tar.gz
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!
Diffstat (limited to 'ext/dbx')
-rw-r--r--ext/dbx/Makefile.in2
-rw-r--r--ext/dbx/dbx.c25
-rw-r--r--ext/dbx/dbx.dsp8
-rw-r--r--ext/dbx/dbx_mysql.c2
-rw-r--r--ext/dbx/dbx_mysql.h2
-rw-r--r--ext/dbx/dbx_odbc.c2
-rw-r--r--ext/dbx/dbx_odbc.h2
-rw-r--r--ext/dbx/dbx_pgsql.c14
-rw-r--r--ext/dbx/dbx_pgsql.h2
-rw-r--r--ext/dbx/php_dbx.h3
10 files changed, 38 insertions, 24 deletions
diff --git a/ext/dbx/Makefile.in b/ext/dbx/Makefile.in
index 8f40151240..1c750f570b 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
+LTLIBRARY_SOURCES = dbx.c dbx_mysql.c dbx_odbc.c dbx_pgsql.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 2bb49a9829..df728b21cd 100644
--- a/ext/dbx/dbx.c
+++ b/ext/dbx/dbx.c
@@ -96,27 +96,30 @@ int switch_dbx_getcolumnname(zval ** rv, zval ** result_handle, long column_inde
/*/ 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_GET_MODULE(dbx)
/*/
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 @@ ZEND_FUNCTION(dbx_query)
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 @@ int switch_dbx_getcolumntype(zval ** rv, zval ** result_handle, long column_inde
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;
diff --git a/ext/dbx/dbx.dsp b/ext/dbx/dbx.dsp
index 3a964642a4..bf067f77cf 100644
--- a/ext/dbx/dbx.dsp
+++ b/ext/dbx/dbx.dsp
@@ -104,6 +104,10 @@ SOURCE=.\dbx_mysql.c
SOURCE=.\dbx_odbc.c
# End Source File
+# Begin Source File
+
+SOURCE=.\dbx_pgsql.c
+# End Source File
# End Group
# Begin Group "Header Files"
@@ -122,6 +126,10 @@ SOURCE=.\dbx_odbc.h
# End Source File
# Begin Source File
+SOURCE=.\dbx_pgsql.h
+# End Source File
+# Begin Source File
+
SOURCE=.\php_dbx.h
# End Source File
# End Group
diff --git a/ext/dbx/dbx_mysql.c b/ext/dbx/dbx_mysql.c
index 1a4354dfe9..0d2d300424 100644
--- a/ext/dbx/dbx_mysql.c
+++ b/ext/dbx/dbx_mysql.c
@@ -174,7 +174,7 @@ int dbx_mysql_getcolumntype(zval ** rv, zval ** result_handle, long column_index
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];
diff --git a/ext/dbx/dbx_mysql.h b/ext/dbx/dbx_mysql.h
index e68f66d30f..1f36383cfe 100644
--- a/ext/dbx/dbx_mysql.h
+++ b/ext/dbx/dbx_mysql.h
@@ -43,7 +43,7 @@ int dbx_mysql_getcolumnname(zval ** rv, zval ** result_handle, long column_index
/*/ 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 /*/
diff --git a/ext/dbx/dbx_odbc.c b/ext/dbx/dbx_odbc.c
index dd39b54b12..290ea08821 100644
--- a/ext/dbx/dbx_odbc.c
+++ b/ext/dbx/dbx_odbc.c
@@ -173,7 +173,7 @@ int dbx_odbc_getcolumntype(zval ** rv, zval ** result_handle, long column_index,
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];
diff --git a/ext/dbx/dbx_odbc.h b/ext/dbx/dbx_odbc.h
index c08832776f..ffa20f4b8b 100644
--- a/ext/dbx/dbx_odbc.h
+++ b/ext/dbx/dbx_odbc.h
@@ -43,7 +43,7 @@ int dbx_odbc_getcolumnname(zval ** rv, zval ** result_handle, long column_index,
/*/ 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 /*/
diff --git a/ext/dbx/dbx_pgsql.c b/ext/dbx/dbx_pgsql.c
index b94b176616..bc0bbd6214 100644
--- a/ext/dbx/dbx_pgsql.c
+++ b/ext/dbx/dbx_pgsql.c
@@ -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 @@ int dbx_pgsql_query(zval ** rv, zval ** dbx_handle, zval ** sql_statement, INTER
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 @@ int dbx_pgsql_query(zval ** rv, zval ** dbx_handle, zval ** sql_statement, INTER
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 @@ int dbx_pgsql_getcolumntype(zval ** rv, zval ** result_handle, long column_index
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 @@ int dbx_pgsql_getrow(zval ** rv, zval ** result_handle, INTERNAL_FUNCTION_PARAME
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);
diff --git a/ext/dbx/dbx_pgsql.h b/ext/dbx/dbx_pgsql.h
index 70c342fa15..6c267fa219 100644
--- a/ext/dbx/dbx_pgsql.h
+++ b/ext/dbx/dbx_pgsql.h
@@ -39,7 +39,7 @@ int dbx_pgsql_getcolumnname(zval ** rv, zval ** result_handle, long column_index
/*/ 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 /*/
diff --git a/ext/dbx/php_dbx.h b/ext/dbx/php_dbx.h
index cb6a8acdcc..6240b953fc 100644
--- a/ext/dbx/php_dbx.h
+++ b/ext/dbx/php_dbx.h
@@ -58,11 +58,12 @@ ZEND_FUNCTION(dbx_test);
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).