mysqli_report.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: Georg Richter <georg@php.net> |
  16. +----------------------------------------------------------------------+
  17. $Id$
  18. */
  19. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include "php.h"
  23. #include "php_ini.h"
  24. #include "ext/standard/info.h"
  25. #include "php_mysqli_structs.h"
  26. extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...);
  27. /* {{{ proto bool mysqli_report(int flags)
  28. sets report level */
  29. PHP_FUNCTION(mysqli_report)
  30. {
  31. long flags;
  32. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &flags) == FAILURE) {
  33. return;
  34. }
  35. MyG(report_mode) = flags;
  36. RETURN_TRUE;
  37. }
  38. /* }}} */
  39. /* {{{ void php_mysqli_report_error(char *sqlstate, int errorno, char *error) */
  40. void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC)
  41. {
  42. php_mysqli_throw_sql_exception((char *)sqlstate, errorno TSRMLS_CC, "%s", error);
  43. }
  44. /* }}} */
  45. /* {{{ void php_mysqli_report_index() */
  46. void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC) {
  47. char index[15];
  48. if (status & SERVER_QUERY_NO_GOOD_INDEX_USED) {
  49. strcpy(index, "Bad index");
  50. } else if (status & SERVER_QUERY_NO_INDEX_USED) {
  51. strcpy(index, "No index");
  52. } else {
  53. return;
  54. }
  55. php_mysqli_throw_sql_exception("00000", 0 TSRMLS_CC, "%s used in query/prepared statement %s", index, query);
  56. }
  57. /* }}} */
  58. /*
  59. * Local variables:
  60. * tab-width: 4
  61. * c-basic-offset: 4
  62. * End:
  63. * vim600: noet sw=4 ts=4 fdm=marker
  64. * vim<600: noet sw=4 ts=4
  65. */