mysqli_driver.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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: Georg Richter <georg@php.net> |
  14. +----------------------------------------------------------------------+
  15. */
  16. #ifdef HAVE_CONFIG_H
  17. #include "config.h"
  18. #endif
  19. #include <signal.h>
  20. #include "php.h"
  21. #include "php_ini.h"
  22. #include "ext/standard/info.h"
  23. #include "php_mysqli_structs.h"
  24. #include "zend_exceptions.h"
  25. /* {{{ property driver_reconnect_read */
  26. static int driver_reconnect_read(mysqli_object *obj, zval *retval, bool quiet)
  27. {
  28. ZVAL_BOOL(retval, MyG(reconnect));
  29. return SUCCESS;
  30. }
  31. /* }}} */
  32. /* {{{ property driver_reconnect_write */
  33. static int driver_reconnect_write(mysqli_object *obj, zval *value)
  34. {
  35. ZEND_ASSERT(Z_TYPE_P(value) == IS_TRUE || Z_TYPE_P(value) == IS_FALSE);
  36. MyG(reconnect) = Z_TYPE_P(value) == IS_TRUE;
  37. return SUCCESS;
  38. }
  39. /* }}} */
  40. /* {{{ property driver_report_read */
  41. static int driver_report_read(mysqli_object *obj, zval *retval, bool quiet)
  42. {
  43. ZVAL_LONG(retval, MyG(report_mode));
  44. return SUCCESS;
  45. }
  46. /* }}} */
  47. /* {{{ property driver_report_write */
  48. static int driver_report_write(mysqli_object *obj, zval *value)
  49. {
  50. ZEND_ASSERT(Z_TYPE_P(value) == IS_LONG);
  51. MyG(report_mode) = Z_LVAL_P(value);
  52. return SUCCESS;
  53. }
  54. /* }}} */
  55. /* {{{ property driver_client_version_read */
  56. static int driver_client_version_read(mysqli_object *obj, zval *retval, bool quiet)
  57. {
  58. ZVAL_LONG(retval, mysql_get_client_version());
  59. return SUCCESS;
  60. }
  61. /* }}} */
  62. /* {{{ property driver_client_info_read */
  63. static int driver_client_info_read(mysqli_object *obj, zval *retval, bool quiet)
  64. {
  65. ZVAL_STRING(retval, (char *)mysql_get_client_info());
  66. return SUCCESS;
  67. }
  68. /* }}} */
  69. /* {{{ property driver_driver_version_read */
  70. static int driver_driver_version_read(mysqli_object *obj, zval *retval, bool quiet)
  71. {
  72. if (quiet) {
  73. return FAILURE;
  74. }
  75. zend_error(E_DEPRECATED, "The driver_version property is deprecated");
  76. ZVAL_LONG(retval, MYSQLI_VERSION_ID);
  77. return SUCCESS;
  78. }
  79. /* }}} */
  80. const mysqli_property_entry mysqli_driver_property_entries[] = {
  81. {"client_info", sizeof("client_info") - 1, driver_client_info_read, NULL},
  82. {"client_version", sizeof("client_version") - 1, driver_client_version_read, NULL},
  83. {"driver_version", sizeof("driver_version") - 1, driver_driver_version_read, NULL},
  84. {"reconnect", sizeof("reconnect") - 1, driver_reconnect_read, driver_reconnect_write},
  85. {"report_mode", sizeof("report_mode") - 1, driver_report_read, driver_report_write},
  86. {NULL, 0, NULL, NULL}
  87. };