📄 apr_dbd.h
字号:
* * @param driver - the driver * @param pool - pool to allocate the result set * @param handle - the connection * @param res - pointer to result set pointer. May point to NULL on entry * @param statement - the SQL statement to execute * @param random - 1 to support random access to results (seek any row); * 0 to support only looping through results in order * (async access - faster) * @return 0 for success or error code */APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, const char *statement, int random);/** apr_dbd_num_cols: get the number of columns in a results set * * @param driver - the driver * @param res - result set. * @return number of columns */APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver, apr_dbd_results_t *res);/** apr_dbd_num_tuples: get the number of rows in a results set * of a synchronous select * * @param driver - the driver * @param res - result set. * @return number of rows, or -1 if the results are asynchronous */APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver, apr_dbd_results_t *res);/** apr_dbd_get_row: get a row from a result set * * @param driver - the driver * @param pool - pool to allocate the row * @param res - result set pointer * @param row - pointer to row pointer. May point to NULL on entry * @param rownum - row number (counting from 1), or -1 for "next row". * Ignored if random access is not supported. * @return 0 for success, -1 for rownum out of range or data finished */APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_results_t *res, apr_dbd_row_t **row, int rownum);/** apr_dbd_get_entry: get an entry from a row * * @param driver - the driver * @param row - row pointer * @param col - entry number * @return value from the row, or NULL if col is out of bounds. */APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver, apr_dbd_row_t *row, int col);/** apr_dbd_get_name: get an entry name from a result set * * @param driver - the driver * @param res - result set pointer * @param col - entry number * @return name of the entry, or NULL if col is out of bounds. */APU_DECLARE(const char*) apr_dbd_get_name(const apr_dbd_driver_t *driver, apr_dbd_results_t *res, int col);/** apr_dbd_error: get current error message (if any) * * @param driver - the driver * @param handle - the connection * @param errnum - error code from operation that returned an error * @return the database current error message, or message for errnum * (implementation-dependent whether errnum is ignored) */APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver, apr_dbd_t *handle, int errnum);/** apr_dbd_escape: escape a string so it is safe for use in query/select * * @param driver - the driver * @param pool - pool to alloc the result from * @param string - the string to escape * @param handle - the connection * @return the escaped, safe string */APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver, apr_pool_t *pool, const char *string, apr_dbd_t *handle);/** apr_dbd_prepare: prepare a statement * * @param driver - the driver * @param pool - pool to alloc the result from * @param handle - the connection * @param query - the SQL query * @param label - A label for the prepared statement. * use NULL for temporary prepared statements * (eg within a Request in httpd) * @param statement - statement to prepare. May point to null on entry. * @return 0 for success or error code * @remarks To specify parameters of the prepared query, use \%s, \%d etc. * (see below for full list) in place of database specific parameter syntax * (e.g. for PostgreSQL, this would be $1, $2, for SQLite3 this would be ? * etc.). For instance: "SELECT name FROM customers WHERE name=%s" would be * a query that this function understands. * @remarks Here is the full list of format specifiers that this function * understands and what they map to in SQL: \%hhd (TINY INT), \%hhu (UNSIGNED * TINY INT), \%hd (SHORT), \%hu (UNSIGNED SHORT), \%d (INT), \%u (UNSIGNED * INT), \%ld (LONG), \%lu (UNSIGNED LONG), \%lld (LONG LONG), \%llu * (UNSIGNED LONG LONG), \%f (FLOAT, REAL), \%lf (DOUBLE PRECISION), \%s * (VARCHAR), \%pDt (TEXT), \%pDi (TIME), \%pDd (DATE), \%pDa (DATETIME), * \%pDs (TIMESTAMP), \%pDz (TIMESTAMP WITH TIME ZONE), \%pDb (BLOB), \%pDc * (CLOB) and \%pDn (NULL). Not all databases have support for all these * types, so the underlying driver will attempt the "best match" where * possible. A \% followed by any letter not in the above list will be * interpreted as VARCHAR (i.e. \%s). */APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, const char *query, const char *label, apr_dbd_prepared_t **statement);/** apr_dbd_pquery: query using a prepared statement + args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param nrows - number of rows affected. * @param statement - the prepared statement to execute * @param nargs - ignored (for backward compatibility only) * @param args - args to prepared statement * @return 0 for success or error code */APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement, int nargs, const char **args);/** apr_dbd_pselect: select using a prepared statement + args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param res - pointer to query results. May point to NULL on entry * @param statement - the prepared statement to execute * @param random - Whether to support random-access to results * @param nargs - ignored (for backward compatibility only) * @param args - args to prepared statement * @return 0 for success or error code */APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random, int nargs, const char **args);/** apr_dbd_pvquery: query using a prepared statement + args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param nrows - number of rows affected. * @param statement - the prepared statement to execute * @param ... - varargs list * @return 0 for success or error code */APU_DECLARE_NONSTD(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement, ...);/** apr_dbd_pvselect: select using a prepared statement + args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param res - pointer to query results. May point to NULL on entry * @param statement - the prepared statement to execute * @param random - Whether to support random-access to results * @param ... - varargs list * @return 0 for success or error code */APU_DECLARE_NONSTD(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random, ...);/** apr_dbd_pbquery: query using a prepared statement + binary args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param nrows - number of rows affected. * @param statement - the prepared statement to execute * @param args - binary args to prepared statement * @return 0 for success or error code */APU_DECLARE(int) apr_dbd_pbquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement, const void **args);/** apr_dbd_pbselect: select using a prepared statement + binary args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param res - pointer to query results. May point to NULL on entry * @param statement - the prepared statement to execute * @param random - Whether to support random-access to results * @param args - binary args to prepared statement * @return 0 for success or error code */APU_DECLARE(int) apr_dbd_pbselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random, const void **args);/** apr_dbd_pvbquery: query using a prepared statement + binary args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param nrows - number of rows affected. * @param statement - the prepared statement to execute * @param ... - varargs list of binary args * @return 0 for success or error code */APU_DECLARE_NONSTD(int) apr_dbd_pvbquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement, ...);/** apr_dbd_pvbselect: select using a prepared statement + binary args * * @param driver - the driver * @param pool - working pool * @param handle - the connection * @param res - pointer to query results. May point to NULL on entry * @param statement - the prepared statement to execute * @param random - Whether to support random-access to results * @param ... - varargs list of binary args * @return 0 for success or error code */APU_DECLARE_NONSTD(int) apr_dbd_pvbselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random, ...);/** apr_dbd_datum_get: get a binary entry from a row * * @param driver - the driver * @param row - row pointer * @param col - entry number * @param type - type of data to get * @param data - pointer to data, allocated by the caller * @return APR_SUCCESS on success, APR_ENOENT if data is NULL or APR_EGENERAL */APU_DECLARE(apr_status_t) apr_dbd_datum_get(const apr_dbd_driver_t *driver, apr_dbd_row_t *row, int col, apr_dbd_type_e type, void *data);/** @} */#ifdef __cplusplus}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -