}
/* }}} */
+static PHP_METHOD(PDO, getAttribute)
+{
+ pdo_dbh_t *dbh = zend_object_store_get_object(getThis() TSRMLS_CC);
+ long attr;
+
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &attr)) {
+ RETURN_FALSE;
+ }
+
+ if (!dbh->methods->set_attribute) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver doesn't support fetching attributes");
+ RETURN_FALSE;
+ }
+
+ PDO_DBH_CLEAR_ERR();
+ switch (dbh->methods->get_attribute(dbh, attr, return_value TSRMLS_CC)) {
+ case -1:
+ PDO_HANDLE_DBH_ERR();
+ RETURN_FALSE;
+ break;
+
+ case 0:
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "This driver doesn't support fetching %ld attribute", attr);
+ break;
+
+ default:
+ return;
+ break;
+ }
+}
+/* }}} */
+
/* {{{ proto long PDO::exec(string query)
Execute a query that does not return a row set, returning the number of affected rows */
static PHP_METHOD(PDO, exec)
PHP_ME(PDO, lastInsertId, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, errorCode, NULL, ZEND_ACC_PUBLIC)
PHP_ME(PDO, errorInfo, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(PDO, getAttribute, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
PDO_ATTR_SCROLL, /* ask for a scrollable cursor (when you prepare()) */
PDO_ATTR_PREFETCH, /* configure the prefetch size for drivers that support it */
PDO_ATTR_TIMEOUT, /* connection timeout in seconds */
+ PDO_ATTR_SERVER_VERSION, /* database server version */
+ PDO_ATTR_CLIENT_VERSION, /* client library version */
+ PDO_ATTR_SERVER_INFO, /* server information */
+ PDO_ATTR_CONNECTION_STATUS, /* connection status */
};
/* generic error code values.
/* transaction related */
typedef int (*pdo_dbh_txn_func)(pdo_dbh_t *dbh TSRMLS_DC);
-/* setting and getting of attributes */
+/* setting of attributes */
typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
/* return last insert id */
* specific data ... */
typedef int (*pdo_dbh_fetch_error_func)(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC);
+/* fetching of attributes */
+typedef int (*pdo_dbh_get_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
+
struct pdo_dbh_methods {
pdo_dbh_close_func closer;
pdo_dbh_prepare_func preparer;
pdo_dbh_set_attr_func set_attribute;
pdo_dbh_last_id_func last_id;
pdo_dbh_fetch_error_func fetch_err;
+ pdo_dbh_get_attr_func get_attribute;
};
/* }}} */