Skip to content

Commit

Permalink
Allow use of scrollable cursor for ODBC
Browse files Browse the repository at this point in the history
  • Loading branch information
wez committed May 25, 2004
1 parent 70bd032 commit 2e73bbf
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion ext/pdo_odbc/odbc_driver.c
Expand Up @@ -160,6 +160,7 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, p
RETCODE rc;
pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
pdo_odbc_stmt *S = ecalloc(1, sizeof(*S));
enum pdo_cursor_type cursor_type = PDO_CURSOR_FWDONLY;

S->H = H;

Expand All @@ -171,6 +172,25 @@ static int odbc_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, p
return 0;
}

cursor_type = pdo_attr_lval(driver_options, PDO_ATTR_CURSOR, PDO_CURSOR_FWDONLY TSRMLS_CC);
if (cursor_type != PDO_CURSOR_FWDONLY) {
SQLUINTEGER cursor;

switch (cursor_type) {
case PDO_CURSOR_SCROLL:
cursor = SQL_CURSOR_STATIC;
default:
;
}

rc = SQLSetStmtAttr(S->stmt, SQL_CURSOR_TYPE, (void*)cursor, SQL_IS_UINTEGER);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
pdo_odbc_stmt_error("SQLSetStmtOption: SQL_CURSOR_TYPE");
SQLFreeHandle(SQL_HANDLE_STMT, S->stmt);
return 0;
}
}

rc = SQLPrepare(S->stmt, (char*)sql, SQL_NTS);

if (rc != SQL_SUCCESS) {
Expand Down Expand Up @@ -263,7 +283,6 @@ static int odbc_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
}
}
return 1;

}


Expand Down Expand Up @@ -338,6 +357,7 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_D
return 0;
}


if (strchr(dbh->data_source, ';')) {
char dsnbuf[1024];
short dsnbuflen;
Expand Down

0 comments on commit 2e73bbf

Please sign in to comment.