📄 php_pdo_driver.h
字号:
/* hook for bound params */enum pdo_param_event { PDO_PARAM_EVT_ALLOC, PDO_PARAM_EVT_FREE, PDO_PARAM_EVT_EXEC_PRE, PDO_PARAM_EVT_EXEC_POST, PDO_PARAM_EVT_FETCH_PRE, PDO_PARAM_EVT_FETCH_POST, PDO_PARAM_EVT_NORMALIZE};typedef int (*pdo_stmt_param_hook_func)(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo_param_event event_type TSRMLS_DC);/* setting of attributes */typedef int (*pdo_stmt_set_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC);/* fetching of attributes */typedef int (*pdo_stmt_get_attr_func)(pdo_stmt_t *stmt, long attr, zval *val TSRMLS_DC);/* retrieves meta data for a numbered column. * Returns SUCCESS/FAILURE. * On SUCCESS, fill in return_value with an array with the following fields. * If a particular field is not supported, then the driver simply does not add it to * the array, so that scripts can use isset() to check for it. * * ### this is just a rough first cut, and subject to change ### * * these are added by PDO itself, based on data from the describe handler: * name => the column name * len => the length/size of the column * precision => precision of the column * pdo_type => an integer, one of the PDO_PARAM_XXX values * * scale => the floating point scale * table => the table for that column * type => a string representation of the type, mapped to the PHP equivalent type name * native_type => a string representation of the type, native style, if different from * the mapped name. * flags => an array of flags including zero or more of the following: * primary_key, not_null, unique_key, multiple_key, unsigned, auto_increment, blob * * Any driver specific data should be returned using a prefixed key or value. * Eg: custom data for the mysql driver would use either * 'mysql:foobar' => 'some data' // to add a new key to the array * or * 'flags' => array('not_null', 'mysql:some_flag'); // to add data to an existing key */typedef int (*pdo_stmt_get_column_meta_func)(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC);/* advances the statement to the next rowset of the batch. * If it returns 1, PDO will tear down its idea of columns * and meta data. If it returns 0, PDO will indicate an error * to the caller. */typedef int (*pdo_stmt_next_rowset_func)(pdo_stmt_t *stmt TSRMLS_DC);/* closes the active cursor on a statement, leaving the prepared * statement ready for re-execution. Useful to explicitly state * that you are done with a given rowset, without having to explicitly * fetch all the rows. */typedef int (*pdo_stmt_cursor_closer_func)(pdo_stmt_t *stmt TSRMLS_DC);struct pdo_stmt_methods { pdo_stmt_dtor_func dtor; pdo_stmt_execute_func executer; pdo_stmt_fetch_func fetcher; pdo_stmt_describe_col_func describer; pdo_stmt_get_col_data_func get_col; pdo_stmt_param_hook_func param_hook; pdo_stmt_set_attr_func set_attribute; pdo_stmt_get_attr_func get_attribute; pdo_stmt_get_column_meta_func get_column_meta; pdo_stmt_next_rowset_func next_rowset; pdo_stmt_cursor_closer_func cursor_closer;};/* }}} */enum pdo_placeholder_support { PDO_PLACEHOLDER_NONE=0, PDO_PLACEHOLDER_NAMED=1, PDO_PLACEHOLDER_POSITIONAL=2};/* represents a connection to a database */struct _pdo_dbh_t { /* these items must appear in this order at the beginning of the struct so that this can be cast as a zend_object. we need this to allow the extending class to escape all the custom handlers that PDO declares. */ zend_class_entry *ce; HashTable *properties; unsigned int in_get:1; unsigned int in_set:1; /* driver specific methods */ struct pdo_dbh_methods *methods; /* driver specific data */ void *driver_data; /* credentials */ char *username, *password; /* if true, then data stored and pointed at by this handle must all be * persistently allocated */ unsigned is_persistent:1; /* if true, driver should act as though a COMMIT were executed between * each executed statement; otherwise, COMMIT must be carried out manually * */ unsigned auto_commit:1; /* if true, the handle has been closed and will not function anymore */ unsigned is_closed:1; /* if true, the driver requires that memory be allocated explicitly for * the columns that are returned */ unsigned alloc_own_columns:1; /* if true, commit or rollBack is allowed to be called */ unsigned in_txn:1; /* max length a single character can become after correct quoting */ unsigned max_escaped_char_length:3; /* oracle compat; see enum pdo_null_handling */ unsigned oracle_nulls:2; /* when set, convert int/floats to strings */ unsigned stringify:1; /* the sum of the number of bits here and the bit fields preceeding should * equal 32 */ unsigned _reserved_flags:21; /* data source string used to open this handle */ const char *data_source; unsigned long data_source_len; /* the global error code. */ pdo_error_type error_code; enum pdo_error_mode error_mode; enum pdo_case_conversion native_case, desired_case; /* persistent hash key associated with this handle */ const char *persistent_id; int persistent_id_len; unsigned int refcount; /* driver specific "class" methods for the dbh and stmt */ HashTable *cls_methods[PDO_DBH_DRIVER_METHOD_KIND__MAX]; pdo_driver_t *driver; zend_class_entry *def_stmt_ce; zval *def_stmt_ctor_args; /* when calling PDO::query(), we need to keep the error * context from the statement around until we next clear it. * This will allow us to report the correct error message * when PDO::query() fails */ pdo_stmt_t *query_stmt; zval query_stmt_zval;};/* describes a column */struct pdo_column_data { char *name; long namelen; unsigned long maxlen; enum pdo_param_type param_type; unsigned long precision; /* don't touch this unless your name is dbdo */ void *dbdo_data;};/* describes a bound parameter */struct pdo_bound_param_data { long paramno; /* if -1, then it has a name, and we don't know the index *yet* */ char *name; long namelen; long max_value_len; /* as a hint for pre-allocation */ zval *parameter; /* the variable itself */ enum pdo_param_type param_type; /* desired or suggested type */ zval *driver_params; /* optional parameter(s) for the driver */ void *driver_data; pdo_stmt_t *stmt; /* for convenience in dtor */ int is_param; /* parameter or column ? */};/* represents a prepared statement */struct _pdo_stmt_t { /* these items must appear in this order at the beginning of the struct so that this can be cast as a zend_object. we need this to allow the extending class to escape all the custom handlers that PDO declares. */ zend_class_entry *ce; HashTable *properties; unsigned int in_get:1; unsigned int in_set:1; /* driver specifics */ struct pdo_stmt_methods *methods; void *driver_data; /* if true, we've already successfully executed this statement at least * once */ unsigned executed:1; /* if true, the statement supports placeholders and can implement * bindParam() for its prepared statements, if false, PDO should * emulate prepare and bind on its behalf */ unsigned supports_placeholders:2; unsigned _reserved:29; /* the number of columns in the result set; not valid until after * the statement has been executed at least once. In some cases, might * not be valid until fetch (at the driver level) has been called at least once. * */ int column_count; struct pdo_column_data *columns; /* we want to keep the dbh alive while we live, so we own a reference */ zval database_object_handle; pdo_dbh_t *dbh; /* keep track of bound input parameters. Some drivers support * input/output parameters, but you can't rely on that working */ HashTable *bound_params; /* When rewriting from named to positional, this maps positions to names */ HashTable *bound_param_map; /* keep track of PHP variables bound to named (or positional) columns * in the result set */ HashTable *bound_columns; /* not always meaningful */ long row_count; /* used to hold the statement's current query */ char *query_string; int query_stringlen; /* the copy of the query with expanded binds ONLY for emulated-prepare drivers */ char *active_query_string; int active_query_stringlen; /* the cursor specific error code. */ pdo_error_type error_code; /* for lazy fetches, we always return the same lazy object handle. * Let's keep it here. */ zval lazy_object_ref; unsigned long refcount; /* defaults for fetches */ enum pdo_fetch_type default_fetch_type; union { int column; struct { zend_class_entry *ce; zval *ctor_args; /* freed */ zval *retval_ptr; zend_fcall_info fci; zend_fcall_info_cache fcc; } cls; struct { zval *function; zval *fetch_args; /* freed */ zval *object; zend_fcall_info fci; zend_fcall_info_cache fcc; zval **values; /* freed */ } func; zval *into; } fetch; /* used by the query parser for driver specific * parameter naming (see pgsql driver for example) */ const char *named_rewrite_template;};/* call this in MINIT to register your PDO driver */PDO_API int php_pdo_register_driver(pdo_driver_t *driver);/* call this in MSHUTDOWN to unregister your PDO driver */PDO_API void php_pdo_unregister_driver(pdo_driver_t *driver);/* For the convenience of drivers, this function will parse a data source * string, of the form "name=value; name2=value2" and populate variables * according to the data you pass in and array of pdo_data_src_parser structures */struct pdo_data_src_parser { const char *optname; char *optval; int freeme;};PDO_API int php_pdo_parse_data_source(const char *data_source, unsigned long data_source_len, struct pdo_data_src_parser *parsed, int nparams);PDO_API zend_class_entry *php_pdo_get_exception(void);PDO_API int pdo_parse_params(pdo_stmt_t *stmt, char *inquery, int inquery_len, char **outquery, int *outquery_len TSRMLS_DC);PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *sqlstate, const char *supp TSRMLS_DC);PDO_API void php_pdo_dbh_addref(pdo_dbh_t *dbh TSRMLS_DC);PDO_API void php_pdo_dbh_delref(pdo_dbh_t *dbh TSRMLS_DC);PDO_API void php_pdo_stmt_addref(pdo_stmt_t *stmt TSRMLS_DC);PDO_API void php_pdo_stmt_delref(pdo_stmt_t *stmt TSRMLS_DC);#endif /* PHP_PDO_DRIVER_H *//* * Local variables: * tab-width: 4 * c-basic-offset: 4 * End: * vim600: noet sw=4 ts=4 fdm=marker * vim<600: noet sw=4 ts=4 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -