[PHP-CVS] cvs: php4 /ext/mssql php_mssql.c php_mssql.h

2001-03-13 Thread Frank M. Kromann

fmk Tue Mar 13 08:33:39 2001 EDT

  Modified files:  
/php4/ext/mssql php_mssql.h php_mssql.c 
  Log:
  Changed email
  
Index: php4/ext/mssql/php_mssql.h
diff -u php4/ext/mssql/php_mssql.h:1.11 php4/ext/mssql/php_mssql.h:1.12
--- php4/ext/mssql/php_mssql.h:1.11 Fri Mar  9 15:37:56 2001
+++ php4/ext/mssql/php_mssql.h  Tue Mar 13 08:33:39 2001
@@ -12,12 +12,12 @@
| obtain it through the world-wide-web, please send a note to  |
| [EMAIL PROTECTED] so we can mail you a copy immediately.   |
+--+
-   | Authors: Frank M. Kromann [EMAIL PROTECTED]  |
+   | Authors: Frank M. Kromann [EMAIL PROTECTED]   |
+--+
  */
 
 
-/* $Id: php_mssql.h,v 1.11 2001/03/09 23:37:56 fmk Exp $ */
+/* $Id: php_mssql.h,v 1.12 2001/03/13 16:33:39 fmk Exp $ */
 
 #ifndef PHP_MSSQL_H
 #define PHP_MSSQL_H
Index: php4/ext/mssql/php_mssql.c
diff -u php4/ext/mssql/php_mssql.c:1.39 php4/ext/mssql/php_mssql.c:1.40
--- php4/ext/mssql/php_mssql.c:1.39 Fri Mar  9 15:37:56 2001
+++ php4/ext/mssql/php_mssql.c  Tue Mar 13 08:33:39 2001
@@ -1,5 +1,5 @@
 /*
-  +--+
+   +--+
| PHP version 4.0  |
+--+
| Copyright (c) 1997-2001 The PHP Group|
@@ -12,11 +12,11 @@
| obtain it through the world-wide-web, please send a note to  |
| [EMAIL PROTECTED] so we can mail you a copy immediately.   |
+--+
-   | Authors: Frank M. Kromann [EMAIL PROTECTED]  |
+   | Authors: Frank M. Kromann [EMAIL PROTECTED]   |
+--+
  */
 
-/* $Id: php_mssql.c,v 1.39 2001/03/09 23:37:56 fmk Exp $ */
+/* $Id: php_mssql.c,v 1.40 2001/03/13 16:33:39 fmk Exp $ */
 
 #ifdef COMPILE_DL_MSSQL
 #define HAVE_MSSQL 1



-- 
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]




[PHP-CVS] cvs: php4 /ext/mssql php_mssql.c php_mssql.h

2001-03-09 Thread Frank M. Kromann

fmk Fri Mar  9 15:37:56 2001 EDT

  Modified files:  
/php4/ext/mssql php_mssql.h php_mssql.c 
  Log:
  Adding a new function mssql_next_result() allowing the query to return more than one 
result.
  This can be done with a stored procedure or by sending more than one select to the 
server.
  

Index: php4/ext/mssql/php_mssql.h
diff -u php4/ext/mssql/php_mssql.h:1.10 php4/ext/mssql/php_mssql.h:1.11
--- php4/ext/mssql/php_mssql.h:1.10 Sun Feb 25 22:07:03 2001
+++ php4/ext/mssql/php_mssql.h  Fri Mar  9 15:37:56 2001
@@ -17,7 +17,7 @@
  */
 
 
-/* $Id: php_mssql.h,v 1.10 2001/02/26 06:07:03 andi Exp $ */
+/* $Id: php_mssql.h,v 1.11 2001/03/09 23:37:56 fmk Exp $ */
 
 #ifndef PHP_MSSQL_H
 #define PHP_MSSQL_H
@@ -77,6 +77,7 @@
 PHP_FUNCTION(mssql_data_seek);
 PHP_FUNCTION(mssql_field_seek);
 PHP_FUNCTION(mssql_result);
+PHP_FUNCTION(mssql_next_result);
 PHP_FUNCTION(mssql_min_error_severity);
 PHP_FUNCTION(mssql_min_message_severity);
 
@@ -116,6 +117,7 @@
mssql_link *mssql_ptr;
int batchsize;
int lastresult;
+   int blocks_initialized;
int cur_row,cur_field;
int num_rows,num_fields;
 } mssql_result;
Index: php4/ext/mssql/php_mssql.c
diff -u php4/ext/mssql/php_mssql.c:1.38 php4/ext/mssql/php_mssql.c:1.39
--- php4/ext/mssql/php_mssql.c:1.38 Sun Feb 25 22:07:03 2001
+++ php4/ext/mssql/php_mssql.c  Fri Mar  9 15:37:56 2001
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_mssql.c,v 1.38 2001/02/26 06:07:03 andi Exp $ */
+/* $Id: php_mssql.c,v 1.39 2001/03/09 23:37:56 fmk Exp $ */
 
 #ifdef COMPILE_DL_MSSQL
 #define HAVE_MSSQL 1
@@ -59,12 +59,14 @@
PHP_FE(mssql_data_seek, NULL)
PHP_FE(mssql_field_seek,NULL)
PHP_FE(mssql_result,NULL)
+   PHP_FE(mssql_next_result,   NULL)
PHP_FE(mssql_min_error_severity,NULL)
PHP_FE(mssql_min_message_severity,  NULL)
{NULL, NULL, NULL}
 };
 
-zend_module_entry mssql_module_entry = {
+zend_module_entry mssql_module_entry = 
+{
"mssql", 
mssql_functions, 
PHP_MINIT(mssql), 
@@ -150,9 +152,8 @@
return 0;
 }
 
-static void _free_mssql_result(zend_rsrc_list_entry *rsrc)
+static void _free_result(mssql_result *result, int free_fields) 
 {
-   mssql_result *result = (mssql_result *)rsrc-ptr;
int i,j;
 
if (result-data) {
@@ -165,15 +166,23 @@
}
}
efree(result-data);
+   result-data = NULL;
+   result-blocks_initialized = 0;
}

-   if (result-fields) {
+   if (free_fields  result-fields) {
for (i=0; iresult-num_fields; i++) {
STR_FREE(result-fields[i].name);
STR_FREE(result-fields[i].column_source);
}
efree(result-fields);
}
+}
+
+static void _free_mssql_result(zend_rsrc_list_entry *rsrc)
+{
+   mssql_result *result = (mssql_result *)rsrc-ptr;
+   _free_result(result, 1);
efree(result);
 }
 
@@ -767,31 +776,80 @@
}
 }
 
-int _mssql_fetch_batch(mssql_link *mssql_ptr, mssql_result *result, int retvalue, int 
*column_types) {
-   int i, j;
-   int blocks_initialized=1;
+int _mssql_fetch_batch(mssql_link *mssql_ptr, mssql_result *result, int retvalue) 
+{
+   int i, j = 0;
+   int *column_types;
+   char computed_buf[16];
MSSQLLS_FETCH();
 
+   column_types = (int *) emalloc(sizeof(int) * result-num_fields);
+   for (i=0; iresult-num_fields; i++) {
+   char *fname = (char *)dbcolname(mssql_ptr-link,i+1);
+
+   if (*fname) {
+   result-fields[i].name = estrdup(fname);
+   } else {
+   if (j0) {
+   snprintf(computed_buf,16,"computed%d",j);
+   } else {
+   strcpy(computed_buf,"computed");
+   }
+   result-fields[i].name = estrdup(computed_buf);
+   j++;
+   }
+   result-fields[i].max_length = dbcollen(mssql_ptr-link,i+1);
+   result-fields[i].column_source = 
+estrdup(dbcolsource(mssql_ptr-link,i+1));
+   if (!result-fields[i].column_source) {
+   result-fields[i].column_source = empty_string;
+   }
+
+   column_types[i] = coltype(i+1);
+
+   result-fields[i].type = column_types[i];
+   /* set numeric flag */
+   switch (column_types[i]) {
+   case SQLINT1:
+   case SQLINT2:
+   case SQLINT4:
+   case SQLFLT8:
+   case SQLNUMERIC:
+