php_pdo_error.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 5 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2016 The PHP Group |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 3.01 of the PHP license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at the following url: |
  10. | http://www.php.net/license/3_01.txt |
  11. | If you did not receive a copy of the PHP license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@php.net so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Author: Wez Furlong <wez@php.net> |
  16. +----------------------------------------------------------------------+
  17. */
  18. /* $Id$ */
  19. #ifndef PHP_PDO_ERROR_H
  20. #define PHP_PDO_ERROR_H
  21. #include "php_pdo_driver.h"
  22. PDO_API void pdo_handle_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt TSRMLS_DC);
  23. #define PDO_DBH_CLEAR_ERR() do { \
  24. strlcpy(dbh->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE)); \
  25. if (dbh->query_stmt) { \
  26. dbh->query_stmt = NULL; \
  27. zend_objects_store_del_ref(&dbh->query_stmt_zval TSRMLS_CC); \
  28. } \
  29. } while (0)
  30. #define PDO_STMT_CLEAR_ERR() strcpy(stmt->error_code, PDO_ERR_NONE)
  31. #define PDO_HANDLE_DBH_ERR() if (strcmp(dbh->error_code, PDO_ERR_NONE)) { pdo_handle_error(dbh, NULL TSRMLS_CC); }
  32. #define PDO_HANDLE_STMT_ERR() if (strcmp(stmt->error_code, PDO_ERR_NONE)) { pdo_handle_error(stmt->dbh, stmt TSRMLS_CC); }
  33. #endif /* PHP_PDO_ERROR_H */
  34. /*
  35. * Local variables:
  36. * tab-width: 4
  37. * c-basic-offset: 4
  38. * End:
  39. * vim600: noet sw=4 ts=4 fdm=marker
  40. * vim<600: noet sw=4 ts=4
  41. */