Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Crude PDO_ODBC patch for SQLGetData
diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c
index 040962d541..4c84967be2 100644
--- a/ext/pdo_odbc/odbc_stmt.c
+++ b/ext/pdo_odbc/odbc_stmt.c
@@ -26,6 +26,8 @@
#include "php_pdo_odbc.h"
#include "php_pdo_odbc_int.h"
+#define ODBC_DONT_BIND 1
+
enum pdo_odbc_conv_result {
PDO_ODBC_CONV_NOT_REQUIRED,
PDO_ODBC_CONV_OK,
@@ -603,6 +605,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno)
col->name = zend_string_init(S->cols[colno].colname, colnamelen, 0);
S->cols[colno].is_unicode = pdo_odbc_sqltype_is_unicode(S, S->cols[colno].coltype);
+#ifndef ODBC_DONT_BIND
/* tell ODBC to put it straight into our buffer, but only if it
* isn't "long" data, and only if we haven't already bound a long
* column. */
@@ -620,6 +623,11 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno)
return 0;
}
} else {
+#else
+ /* don't bind columns, SQLGetData them later. it'd be nice if we could
+ * have a bigger buffer here for that purpose. */
+ {
+#endif
/* allocate a smaller buffer to keep around for smaller
* "long" columns */
S->cols[colno].data = emalloc(256);
@@ -642,8 +650,13 @@ static int odbc_stmt_get_col(pdo_stmt_t *stmt, int colno, zval *result, enum pdo
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
pdo_odbc_column *C = &S->cols[colno];
+#ifndef ODBC_DONT_BIND
/* if it is a column containing "long" data, perform late binding now */
if (C->is_long) {
+#else
+ /* always use SQLGetData */
+ if (1) {
+#endif
SQLLEN orig_fetched_len = SQL_NULL_DATA;
RETCODE rc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment