Hi Frank!

In the attached patches I fixed a bug when using the mssql extension with FreeTDS and deactivated datetimeconvert. FreeTDS returns the month starting with 0 (=jan), but the MSoft-lib starts with 1.

I added another php.ini switch (datetimemsec) for adding milliseconds to datetime-values when datetimeconvert is deactivated. This was a user request, because he has otherwise no chance to get the milliseconds back from the db.

I hope that these patches are good enough for a commit,

thanx,
bye,
--
------------------------------- -------------------------------------
Michael Bretterklieber        - [EMAIL PROTECTED]
JAWA Management Software GmbH - http://www.jawa.at
Liebenauer Hauptstr. 200        -------------- privat ---------------
A-8041 GRAZ                     GSM: ++43-(0)676-93 96 698
Tel: ++43-(0)316-403274-12      E-mail:   [EMAIL PROTECTED]
Fax: ++43-(0)316-403274-10      http://www.bretterklieber.com
------------------------------- -------------------------------------
"...the number of UNIX installations has grown to 10, with more
expected..." - Dennis Ritchie and Ken Thompson, June 1972
Index: php_mssql.c
===================================================================
RCS file: /repository/php4/ext/mssql/php_mssql.c,v
retrieving revision 1.86.2.15
diff -u -r1.86.2.15 php_mssql.c
--- php_mssql.c 11 Feb 2003 01:23:49 -0000      1.86.2.15
+++ php_mssql.c 2 Mar 2003 14:28:56 -0000
@@ -137,6 +137,7 @@
        STD_PHP_INI_ENTRY_EX("mssql.textlimit",                         "-1",   
PHP_INI_ALL,    OnUpdateInt,    textlimit,                                      
zend_mssql_globals,             mssql_globals,  display_text_size)
        STD_PHP_INI_ENTRY_EX("mssql.batchsize",                         "0",    
PHP_INI_ALL,    OnUpdateInt,    batchsize,                                      
zend_mssql_globals,             mssql_globals,  display_link_numbers)
        STD_PHP_INI_BOOLEAN("mssql.datetimeconvert",            "1",    PHP_INI_ALL,   
 OnUpdateBool,   datetimeconvert,                        zend_mssql_globals,           
  mssql_globals)
+       STD_PHP_INI_BOOLEAN("mssql.datetimemsec",                       "0",    
PHP_INI_ALL,    OnUpdateBool,   datetimemsec,                           
zend_mssql_globals,             mssql_globals)
        STD_PHP_INI_BOOLEAN("mssql.secure_connection",          "0",    
PHP_INI_SYSTEM, OnUpdateBool,   secure_connection,                      
zend_mssql_globals,             mssql_globals)
        STD_PHP_INI_ENTRY_EX("mssql.max_procs",                         "25",   
PHP_INI_ALL,    OnUpdateInt,    max_procs,                                      
zend_mssql_globals,             mssql_globals,  display_link_numbers)
 PHP_INI_END()
@@ -839,11 +840,17 @@
                                                dbdatecrack(mssql_ptr->link, 
&dateinfo, (DBDATETIME *) dbdata(mssql_ptr->link,offset));
                                        }
                        
-                                       res_length = 19;
-                                       res_buf = (unsigned char *) 
emalloc(res_length+1);
+                                       res_buf = (unsigned char *) emalloc(30);
+#if HAVE_FREETDS
+                                       dateinfo.month++;
+#endif
                                        sprintf(res_buf, "%d-%02d-%02d %02d:%02d:%02d" 
, dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, 
dateinfo.second);
+                                       if (MS_SQL_G(datetimemsec)) {
+                                               sprintf(&res_buf[strlen(res_buf)],  
".%03d", dateinfo.millisecond);
+                                       }
+                                       res_length = strlen(res_buf);
                                }
-               
+
                                Z_STRVAL_P(result) = res_buf;
                                Z_STRLEN_P(result) = res_length;
                                Z_TYPE_P(result) = IS_STRING;
@@ -900,9 +907,16 @@
                                dbdatecrack(mssql_ptr->link, &dateinfo, (DBDATETIME *) 
dbdata(mssql_ptr->link,offset));
                        }
                        
-                       res_length = 19;
-                       res_buf = (unsigned char *) emalloc(res_length+1);
+                       res_length = 30;
+                       res_buf = (unsigned char *) emalloc(res_length);
+#if HAVE_FREETDS
+                       dateinfo.month++;
+#endif
                        sprintf(res_buf, "%d-%02d-%02d %02d:%02d:%02d" , 
dateinfo.year, dateinfo.month, dateinfo.day, dateinfo.hour, dateinfo.minute, 
dateinfo.second);
+                       if (MS_SQL_G(datetimemsec)) {
+                               sprintf(&res_buf[strlen(res_buf)],  ".%03d", 
dateinfo.millisecond);
+                       }
+                       res_length = strlen(res_buf);
                }
 
                Z_STRVAL_P(result) = res_buf;
Index: php_mssql.h
===================================================================
RCS file: /repository/php4/ext/mssql/php_mssql.h,v
retrieving revision 1.23.4.7
diff -u -r1.23.4.7 php_mssql.h
--- php_mssql.h 9 Feb 2003 07:49:34 -0000       1.23.4.7
+++ php_mssql.h 2 Mar 2003 14:28:57 -0000
@@ -160,7 +160,7 @@
        zend_bool compatability_mode;
        void (*get_column_content)(mssql_link *mssql_ptr,int offset,pval *result,int 
column_type  TSRMLS_DC);
        long textsize, textlimit, batchsize;
-       zend_bool datetimeconvert;
+       zend_bool datetimeconvert, datetimemsec;
        HashTable *resource_list, *resource_plist;
        zend_bool secure_connection;
        long max_procs;

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to