]> granicus.if.org Git - php/commitdiff
Allow static build (better detection of PDO headers).
authorWez Furlong <wez@php.net>
Fri, 21 Jan 2005 04:43:06 +0000 (04:43 +0000)
committerWez Furlong <wez@php.net>
Fri, 21 Jan 2005 04:43:06 +0000 (04:43 +0000)
Copy error code into driver code, so PDO can handle it correctly.
Less leaks

ext/pdo_odbc/config.m4
ext/pdo_odbc/odbc_driver.c

index d6e7264c1ab997e3f5a903e95ce1ef779d5652ff..15aed2878763c9e7575967a7ee58ab2191ca8232 100755 (executable)
@@ -32,6 +32,19 @@ AC_DEFUN([PDO_ODBC_CHECK_HEADER],[
                                   
 AC_MSG_CHECKING(which ODBC flavour you want)
 if test "$PHP_PDO_ODBC" != "no" && test "$PHP_PDO_ODBC" != "yes" ; then
+
+  AC_MSG_CHECKING([for PDO includes])
+  if test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
+    pdo_inc_path=$prefix/include/php/ext
+  elif test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
+    pdo_inc_path=$abs_srcdir/ext
+  elif test -f ext/pdo/php_pdo_driver.h; then
+    pdo_inc_path=ext
+  else
+    AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
+  fi
+  AC_MSG_RESULT($pdo_inc_path)
+
   pdo_odbc_flavour=`echo $withval | cut -d, -f1`
   pdo_odbc_dir=`echo $withval | cut -d, -f2`
 
@@ -130,7 +143,7 @@ functions required for PDO support.
   PHP_EVAL_LIBLINE($PDO_ODBC_LIBS $PDO_ODBC_LFLAGS, [PDO_ODBC_SHARED_LIBADD])
   PHP_SUBST(PDO_ODBC_SHARED_LIBADD)
 
-  PHP_NEW_EXTENSION(pdo_odbc, pdo_odbc.c odbc_driver.c odbc_stmt.c, $ext_shared,,-I\$prefix/include/php/ext $PDO_ODBC_INCLUDE)
+  PHP_NEW_EXTENSION(pdo_odbc, pdo_odbc.c odbc_driver.c odbc_stmt.c, $ext_shared,,-I$pdo_inc_path $PDO_ODBC_INCLUDE)
   PHP_ADD_EXTENSION_DEP(pdo_odbc, pdo)
 else
   AC_MSG_ERROR(
index 780a9f111d8e3d87c2c5506dc04014169278e745..1014ec92daf48d1fa8c223c551bfcc2241acd5b7 100755 (executable)
@@ -29,6 +29,7 @@
 #include "pdo/php_pdo_driver.h"
 #include "php_pdo_odbc.h"
 #include "php_pdo_odbc_int.h"
+#include "zend_exceptions.h"
 
 static int pdo_odbc_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC)
 {
@@ -42,7 +43,7 @@ static int pdo_odbc_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *inf
                einfo = &S->einfo;
        }
 
-       spprintf(&message, 0, "%s (%s[%d] at %s:%d)",
+       spprintf(&message, 0, "%s (%s[%ld] at %s:%d)",
                                einfo->last_err_msg,
                                einfo->what, einfo->last_error,
                                einfo->file, einfo->line);
@@ -129,6 +130,8 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, p
                sql = nsql;
        } else if (ret == -1) {
                /* couldn't grok it */
+               strcpy(dbh->error_code, stmt->error_code);
+               efree(S);
                return 0;
        }