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
/*/ 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[] = {
/*/
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);
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;
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;
\r
SOURCE=.\dbx_odbc.c\r
# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\dbx_pgsql.c\r
+# End Source File\r
# End Group\r
# Begin Group "Header Files"\r
\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\dbx_pgsql.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\php_dbx.h\r
# End Source File\r
# End Group\r
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];
/*/ 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 /*/
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];
/*/ 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 /*/
#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
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;
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;
}
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;
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);
/*/ 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 /*/
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).