lwe             Tue Oct 30 18:06:02 2007 UTC

  Modified files:              
    /php-src/ext/pdo_firebird   firebird_driver.c 
  Log:
  - Added 3 firebird specific attributes to firebird_handle_set_attribute()
  - function. They control formatting of date/timestamp columns.
  - pdo_firebird_handle_factory() now throwing an execption if unable to attach
  - database (bug reports 39822 and 41522)
  - Fixed bug #39822 (new PDO() doesn't work with firebird)
  - Fixed bug #41522 (PDO firebird driver returns null if it fails to connect)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_firebird/firebird_driver.c?r1=1.22&r2=1.23&diff_format=u
Index: php-src/ext/pdo_firebird/firebird_driver.c
diff -u php-src/ext/pdo_firebird/firebird_driver.c:1.22 
php-src/ext/pdo_firebird/firebird_driver.c:1.23
--- php-src/ext/pdo_firebird/firebird_driver.c:1.22     Thu Jan 18 15:54:45 2007
+++ php-src/ext/pdo_firebird/firebird_driver.c  Tue Oct 30 18:06:02 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: firebird_driver.c,v 1.22 2007/01/18 15:54:45 tony2001 Exp $ */
+/* $Id: firebird_driver.c,v 1.23 2007/10/30 18:06:02 lwe Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -114,6 +114,16 @@
                RECORD_ERROR(dbh);
        }
 
+       if (H->date_format) {
+               efree(H->date_format);
+       }
+       if (H->time_format) {
+               efree(H->time_format);
+       }
+       if (H->timestamp_format) {
+               efree(H->timestamp_format);
+       }
+       
        pefree(H, dbh->is_persistent);
 
        return 0;
@@ -482,6 +492,30 @@
                                dbh->auto_commit = Z_BVAL_P(val);
                        }
                        return 1;
+
+               case PDO_FB_ATTR_DATE_FORMAT:
+                       convert_to_string(val);
+                       if (H->date_format) {
+                               efree(H->date_format);
+                       }
+                       spprintf(&H->date_format, 0, "%s", Z_STRVAL_P(val)); 
+                       return 1;
+
+               case PDO_FB_ATTR_TIME_FORMAT:
+                       convert_to_string(val);
+                       if (H->time_format) {
+                               efree(H->time_format);
+                       }
+                       spprintf(&H->time_format, 0, "%s", Z_STRVAL_P(val)); 
+                       return 1;
+
+               case PDO_FB_ATTR_TIMESTAMP_FORMAT:
+                       convert_to_string(val);
+                       if (H->timestamp_format) {
+                               efree(H->timestamp_format);
+                       }
+                       spprintf(&H->timestamp_format, 0, "%s", 
Z_STRVAL_P(val)); 
+                       return 1;
        }
        return 0;
 }
@@ -500,7 +534,7 @@
 /* }}} */
 
 /* called by PDO to get a driver-specific dbh attribute */
-static int firebird_handle_get_attribute(pdo_dbh_t const *dbh, long attr, zval 
*val TSRMLS_DC) /* {{{ */
+static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val 
TSRMLS_DC) /* {{{ */
 {
        pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
 
@@ -615,11 +649,11 @@
                char dpb_buffer[256] = { isc_dpb_version1 }, *dpb;
                
                dpb = dpb_buffer + 1; 
-               
+
                /* loop through all the provided arguments and set dpb fields 
accordingly */
                for (i = 0; i < sizeof(dpb_flags); ++i) {
                        if (dpb_values[i] && buf_len > 0) {
-                               dpb_len = snprintf(dpb, buf_len, "%c%c%s", 
dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
+                               dpb_len = slprintf(dpb, buf_len, "%c%c%s", 
dpb_flags[i], (unsigned char)strlen(dpb_values[i]),
                                        dpb_values[i]);
                                dpb += dpb_len;
                                buf_len -= dpb_len;
@@ -627,8 +661,7 @@
                }
                
                /* fire it up baby! */
-               if (isc_attach_database(H->isc_status, 0, vars[0].optval, 
&H->db,(short)(dpb-dpb_buffer),
-                               dpb_buffer)) {
+               if (isc_attach_database(H->isc_status, 0, vars[0].optval, 
&H->db,(short)(dpb-dpb_buffer), dpb_buffer)) {
                        break;
                }
                
@@ -646,6 +679,14 @@
                }
        }
 
+       if (!dbh->methods) {
+               char errmsg[512];
+               ISC_STATUS *s = H->isc_status;
+               isc_interprete(errmsg, &s);
+               zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, 
"SQLSTATE[%s] [%d] %s",
+                               "HY000", H->isc_status[1], errmsg);
+       }
+
        if (!ret) {
                firebird_handle_closer(dbh TSRMLS_CC);
        }
@@ -654,6 +695,7 @@
 }
 /* }}} */
 
+
 pdo_driver_t pdo_firebird_driver = { /* {{{ */
        PDO_DRIVER_HEADER(firebird),
        pdo_firebird_handle_factory

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to