]> granicus.if.org Git - php/commitdiff
support getting some more attributes
authorWez Furlong <wez@php.net>
Sun, 6 Feb 2005 17:49:48 +0000 (17:49 +0000)
committerWez Furlong <wez@php.net>
Sun, 6 Feb 2005 17:49:48 +0000 (17:49 +0000)
ext/pdo_odbc/odbc_driver.c
ext/pdo_odbc/odbc_stmt.c

index 1014ec92daf48d1fa8c223c551bfcc2241acd5b7..aa543360c86dead5b99df9d79b27677ad5716e39 100755 (executable)
@@ -209,7 +209,7 @@ out:
        return row_count;
 }
 
-static int odbc_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen  TSRMLS_DC)
+static int odbc_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen, enum pdo_param_type param_type  TSRMLS_DC)
 {
        pdo_odbc_db_handle *H = (pdo_odbc_db_handle *)dbh->driver_data;
 
@@ -256,7 +256,23 @@ static int odbc_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
        return 1;
 }
 
+static int odbc_handle_get_attr(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC)
+{
+       switch (attr) {
+               case PDO_ATTR_CLIENT_VERSION:
+                       ZVAL_STRING(val, "ODBC-" PDO_ODBC_TYPE, 1);
+                       return 1;
+
+               case PDO_ATTR_SERVER_VERSION:
+               case PDO_ATTR_PREFETCH:
+               case PDO_ATTR_TIMEOUT:
+               case PDO_ATTR_SERVER_INFO:
+               case PDO_ATTR_CONNECTION_STATUS:
+                       break;
 
+       }
+       return 0;
+}
 
 static struct pdo_dbh_methods odbc_methods = {
        odbc_handle_closer,
@@ -269,7 +285,7 @@ static struct pdo_dbh_methods odbc_methods = {
        NULL,   /* set attr */
        NULL,   /* last id */
        pdo_odbc_fetch_error_func,
-       NULL,   /* get attr */
+       odbc_handle_get_attr,   /* get attr */
        NULL,   /* check_liveness */
 };
 
index 93f2cdcd2e0326c1d5fa4b2ac2009de4694b72f3..d62ad3df34226f341647e766807ad5ea6cad39b5 100755 (executable)
@@ -265,6 +265,34 @@ static int odbc_stmt_set_param(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
        }
 }
 
+static int odbc_stmt_get_attr(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC)
+{
+       SQLRETURN rc;
+       pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
+
+       switch (attr) {
+               case PDO_ATTR_CURSOR_NAME:
+               {
+                       char buf[256];
+                       SQLSMALLINT len = 0;
+                       rc = SQLGetCursorName(S->stmt, buf, sizeof(buf), &len);
+
+                       if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) {
+                               ZVAL_STRINGL(val, buf, len, 1);
+                               return 1;
+                       }
+                       pdo_odbc_stmt_error("SQLGetCursorName");
+                       return 0;
+               }
+
+               default:
+                       strcpy(S->einfo.last_err_msg, "Unknown Attribute");
+                       S->einfo.what = "getAttribute";
+                       strcpy(S->einfo.last_state, "IM0001");
+                       return -1;
+       }
+}
+
 static int odbc_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC)
 {
        SQLRETURN rc;
@@ -295,7 +323,7 @@ struct pdo_stmt_methods odbc_stmt_methods = {
        odbc_stmt_get_col,
        odbc_stmt_param_hook,
        odbc_stmt_set_param,
-       NULL, /* get attr */
+       odbc_stmt_get_attr, /* get attr */
        NULL, /* get column meta */
        odbc_stmt_next_rowset
 };