mysqli_priv.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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: php_mysqli_structs.h 302179 2010-08-13 09:57:04Z andrey $
  18. */
  19. #ifndef MYSQLI_PRIV_H
  20. #define MYSQLI_PRIV_H
  21. #ifdef PHP_MYSQL_UNIX_SOCK_ADDR
  22. #ifdef MYSQL_UNIX_ADDR
  23. #undef MYSQL_UNIX_ADDR
  24. #endif
  25. #define MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
  26. #endif
  27. /* character set support */
  28. #if defined(MYSQLND_VERSION_ID) || MYSQL_VERSION_ID > 50009
  29. #define HAVE_MYSQLI_GET_CHARSET
  30. #endif
  31. #if defined(MYSQLND_VERSION_ID) || (MYSQL_VERSION_ID > 40112 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID > 50005
  32. #define HAVE_MYSQLI_SET_CHARSET
  33. #endif
  34. extern const zend_function_entry mysqli_functions[];
  35. extern const zend_function_entry mysqli_link_methods[];
  36. extern const zend_function_entry mysqli_stmt_methods[];
  37. extern const zend_function_entry mysqli_result_methods[];
  38. extern const zend_function_entry mysqli_driver_methods[];
  39. extern const zend_function_entry mysqli_warning_methods[];
  40. extern const zend_function_entry mysqli_exception_methods[];
  41. extern const mysqli_property_entry mysqli_link_property_entries[];
  42. extern const mysqli_property_entry mysqli_result_property_entries[];
  43. extern const mysqli_property_entry mysqli_stmt_property_entries[];
  44. extern const mysqli_property_entry mysqli_driver_property_entries[];
  45. extern const mysqli_property_entry mysqli_warning_property_entries[];
  46. extern const zend_property_info mysqli_link_property_info_entries[];
  47. extern const zend_property_info mysqli_result_property_info_entries[];
  48. extern const zend_property_info mysqli_stmt_property_info_entries[];
  49. extern const zend_property_info mysqli_driver_property_info_entries[];
  50. extern const zend_property_info mysqli_warning_property_info_entries[];
  51. extern int php_le_pmysqli(void);
  52. extern void php_mysqli_dtor_p_elements(void *data);
  53. extern void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status TSRMLS_DC);
  54. extern void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flag, int into_object);
  55. extern void php_clear_stmt_bind(MY_STMT *stmt TSRMLS_DC);
  56. extern void php_clear_mysql(MY_MYSQL *);
  57. #ifdef MYSQLI_USE_MYSQLND
  58. extern MYSQLI_WARNING *php_get_warnings(MYSQLND_CONN_DATA * mysql TSRMLS_DC);
  59. #else
  60. extern MYSQLI_WARNING *php_get_warnings(MYSQL * mysql TSRMLS_DC);
  61. #endif
  62. extern void php_clear_warnings(MYSQLI_WARNING *w);
  63. extern void php_free_stmt_bind_buffer(BIND_BUFFER bbuf, int type);
  64. extern void php_mysqli_report_error(const char *sqlstate, int errorno, const char *error TSRMLS_DC);
  65. extern void php_mysqli_report_index(const char *query, unsigned int status TSRMLS_DC);
  66. extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno TSRMLS_DC, char *format, ...);
  67. #ifdef HAVE_SPL
  68. extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
  69. #endif
  70. #define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type
  71. PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry * TSRMLS_DC);
  72. #define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \
  73. mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \
  74. mysql->multi_query = 0; \
  75. }
  76. #define MYSQLI_ENABLE_MQ if (!mysql->multi_query) { \
  77. mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_ON); \
  78. mysql->multi_query = 1; \
  79. }
  80. #define MYSQLI_RETURN_LONG_LONG(__val) \
  81. { \
  82. if ((__val) < LONG_MAX) { \
  83. RETURN_LONG((long) (__val)); \
  84. } else { \
  85. char *ret; \
  86. /* always used with my_ulonglong -> %llu */ \
  87. int l = spprintf(&ret, 0, MYSQLI_LLU_SPEC, (__val)); \
  88. RETURN_STRINGL(ret, l, 0); \
  89. } \
  90. }
  91. #define MYSQLI_STORE_RESULT 0
  92. #define MYSQLI_USE_RESULT 1
  93. #ifdef MYSQLI_USE_MYSQLND
  94. #define MYSQLI_ASYNC 8
  95. #define MYSQLI_STORE_RESULT_COPY_DATA 16
  96. #else
  97. /* libmysql */
  98. #define MYSQLI_ASYNC 0
  99. #define MYSQLI_STORE_RESULT_COPY_DATA 0
  100. #endif
  101. /* for mysqli_fetch_assoc */
  102. #define MYSQLI_ASSOC 1
  103. #define MYSQLI_NUM 2
  104. #define MYSQLI_BOTH 3
  105. /* fetch types */
  106. #define FETCH_SIMPLE 1
  107. #define FETCH_RESULT 2
  108. /*** REPORT MODES ***/
  109. #define MYSQLI_REPORT_OFF 0
  110. #define MYSQLI_REPORT_ERROR 1
  111. #define MYSQLI_REPORT_STRICT 2
  112. #define MYSQLI_REPORT_INDEX 4
  113. #define MYSQLI_REPORT_CLOSE 8
  114. #define MYSQLI_REPORT_ALL 255
  115. #define MYSQLI_REPORT_MYSQL_ERROR(mysql) \
  116. if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_errno(mysql)) { \
  117. php_mysqli_report_error(mysql_sqlstate(mysql), mysql_errno(mysql), mysql_error(mysql) TSRMLS_CC); \
  118. }
  119. #define MYSQLI_REPORT_STMT_ERROR(stmt) \
  120. if ((MyG(report_mode) & MYSQLI_REPORT_ERROR) && mysql_stmt_errno(stmt)) { \
  121. php_mysqli_report_error(mysql_stmt_sqlstate(stmt), mysql_stmt_errno(stmt), mysql_stmt_error(stmt) TSRMLS_CC); \
  122. }
  123. void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_connect, zend_bool in_ctor);
  124. void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS);
  125. #endif /* MYSQLI_PRIV_H */