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