php_pdo_error.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Wez Furlong <wez@php.net> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifndef PHP_PDO_ERROR_H
  17. #define PHP_PDO_ERROR_H
  18. #include "php_pdo_driver.h"
  19. PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt);
  20. #define PDO_DBH_CLEAR_ERR() do { \
  21. strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
  22. if (dbh->query_stmt) { \
  23. dbh->query_stmt = NULL; \
  24. zval_ptr_dtor(&dbh->query_stmt_zval); \
  25. } \
  26. } while (0)
  27. #define PDO_STMT_CLEAR_ERR() strcpy(stmt->error_code, PDO_ERR_NONE)
  28. #define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL); }
  29. #define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt); }
  30. #endif /* PHP_PDO_ERROR_H */