mirror of
https://github.com/php/php-src.git
synced 2025-01-06 10:53:39 +08:00
Added getAttribute() method.
This commit is contained in:
parent
b7b7bedabd
commit
e596466a1f
@ -323,6 +323,38 @@ fail:
|
|||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
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)
|
/* {{{ proto long PDO::exec(string query)
|
||||||
Execute a query that does not return a row set, returning the number of affected rows */
|
Execute a query that does not return a row set, returning the number of affected rows */
|
||||||
static PHP_METHOD(PDO, exec)
|
static PHP_METHOD(PDO, exec)
|
||||||
@ -414,6 +446,7 @@ function_entry pdo_dbh_functions[] = {
|
|||||||
PHP_ME(PDO, lastInsertId, NULL, ZEND_ACC_PUBLIC)
|
PHP_ME(PDO, lastInsertId, NULL, ZEND_ACC_PUBLIC)
|
||||||
PHP_ME(PDO, errorCode, NULL, ZEND_ACC_PUBLIC)
|
PHP_ME(PDO, errorCode, NULL, ZEND_ACC_PUBLIC)
|
||||||
PHP_ME(PDO, errorInfo, NULL, ZEND_ACC_PUBLIC)
|
PHP_ME(PDO, errorInfo, NULL, ZEND_ACC_PUBLIC)
|
||||||
|
PHP_ME(PDO, getAttribute, NULL, ZEND_ACC_PUBLIC)
|
||||||
|
|
||||||
{NULL, NULL, NULL}
|
{NULL, NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -59,6 +59,10 @@ enum pdo_attribute_type {
|
|||||||
PDO_ATTR_SCROLL, /* ask for a scrollable cursor (when you prepare()) */
|
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_PREFETCH, /* configure the prefetch size for drivers that support it */
|
||||||
PDO_ATTR_TIMEOUT, /* connection timeout in seconds */
|
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.
|
/* generic error code values.
|
||||||
@ -125,7 +129,7 @@ typedef int (*pdo_dbh_quote_func)(pdo_dbh_t *dbh, const char *unquoted, int unqu
|
|||||||
/* transaction related */
|
/* transaction related */
|
||||||
typedef int (*pdo_dbh_txn_func)(pdo_dbh_t *dbh TSRMLS_DC);
|
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);
|
typedef int (*pdo_dbh_set_attr_func)(pdo_dbh_t *dbh, long attr, zval *val TSRMLS_DC);
|
||||||
|
|
||||||
/* return last insert id */
|
/* return last insert id */
|
||||||
@ -139,6 +143,9 @@ typedef long (*pdo_dbh_last_id_func)(pdo_dbh_t *dbh TSRMLS_DC);
|
|||||||
* specific data ... */
|
* specific data ... */
|
||||||
typedef int (*pdo_dbh_fetch_error_func)(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC);
|
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 {
|
struct pdo_dbh_methods {
|
||||||
pdo_dbh_close_func closer;
|
pdo_dbh_close_func closer;
|
||||||
pdo_dbh_prepare_func preparer;
|
pdo_dbh_prepare_func preparer;
|
||||||
@ -150,6 +157,7 @@ struct pdo_dbh_methods {
|
|||||||
pdo_dbh_set_attr_func set_attribute;
|
pdo_dbh_set_attr_func set_attribute;
|
||||||
pdo_dbh_last_id_func last_id;
|
pdo_dbh_last_id_func last_id;
|
||||||
pdo_dbh_fetch_error_func fetch_err;
|
pdo_dbh_fetch_error_func fetch_err;
|
||||||
|
pdo_dbh_get_attr_func get_attribute;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
Loading…
Reference in New Issue
Block a user