php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
mysqli_api.c
Go to the documentation of this file.
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 | Authors: Georg Richter <georg@php.net> |
14 | Andrey Hristov <andrey@php.net> |
15 | Ulf Wendel <uw@php.net> |
16 +----------------------------------------------------------------------+
17*/
18
19#ifdef HAVE_CONFIG_H
20#include <config.h>
21#endif
22
23#include <signal.h>
24
25#include "php.h"
26#include "zend_smart_str.h"
27#include "php_mysqli_structs.h"
28#include "mysqli_priv.h"
30
31#define ERROR_ARG_POS(arg_num) (hasThis() ? (arg_num-1) : (arg_num))
32
33/* {{{ Get number of affected rows in previous MySQL operation */
35{
36 MY_MYSQL *mysql;
37 zval *mysql_link;
38 my_ulonglong rc;
39
42 }
43
45
46 rc = mysql_affected_rows(mysql->mysql);
47 if (rc == (my_ulonglong) -1) {
48 RETURN_LONG(-1);
49 }
51}
52/* }}} */
53
54/* {{{ Turn auto commit on or of */
56{
57 MY_MYSQL *mysql;
58 zval *mysql_link;
59 bool automode;
60
61 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &mysql_link, mysqli_link_class_entry, &automode) == FAILURE) {
63 }
65
66 if (mysql_autocommit(mysql->mysql, (my_bool)automode)) {
69 }
71}
72/* }}} */
73
74/* {{{ mysqli_stmt_bind_param_do_bind */
75static enum_func_status mysqli_stmt_bind_param_do_bind(MY_STMT *stmt, uint32_t num_vars, zval *args, const char * const types, unsigned int arg_num)
76{
77 MYSQLND_PARAM_BIND *params;
79
80 /* If no params -> skip binding and return directly */
81 if (num_vars == 0) {
82 return PASS;
83 }
84 params = mysqlnd_stmt_alloc_param_bind(stmt->stmt);
85 if (!params) {
86 goto end;
87 }
88 for (uint32_t i = 0; i < num_vars; i++) {
89 uint8_t type;
90 switch (types[i]) {
91 case 'd': /* Double */
93 break;
94 case 'i': /* Integer */
95#if SIZEOF_ZEND_LONG==8
97#elif SIZEOF_ZEND_LONG==4
99#endif
100 break;
101 case 'b': /* Blob (send data) */
103 break;
104 case 's': /* string */
106 break;
107 default:
108 zend_argument_value_error(arg_num, "must only contain the \"b\", \"d\", \"i\", \"s\" type specifiers");
109 ret = FAIL;
110 mysqlnd_stmt_free_param_bind(stmt->stmt, params);
111 goto end;
112 }
113 ZVAL_COPY_VALUE(&params[i].zv, &args[i]);
114 params[i].type = type;
115 }
116 ret = mysqlnd_stmt_bind_param(stmt->stmt, params);
117
118end:
119 return ret;
120}
121/* }}} */
122
123/* {{{ Bind variables to a prepared statement as parameters */
125{
126 zval *args;
127 uint32_t argc;
128 MY_STMT *stmt;
129 zval *mysql_stmt;
130 char *types;
131 size_t types_len;
132
133 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os*", &mysql_stmt, mysqli_stmt_class_entry, &types, &types_len, &args, &argc) == FAILURE) {
135 }
136
138
139 if (!types_len) {
142 }
143
144 if (types_len != (size_t) argc) {
145 /* number of bind variables doesn't match number of elements in type definition string */
146 zend_argument_count_error("The number of elements in the type definition string must match the number of bind variables");
148 }
149
150 if (types_len != mysql_stmt_param_count(stmt->stmt)) {
151 zend_argument_count_error("The number of variables must match the number of parameters in the prepared statement");
153 }
154
155 RETVAL_BOOL(mysqli_stmt_bind_param_do_bind(stmt, argc, args, types, ERROR_ARG_POS(2)) == PASS);
157}
158/* }}} */
159
160/* {{{ mysqli_stmt_bind_result_do_bind */
161static enum_func_status mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, uint32_t argc)
162{
164 if (params) {
165 for (uint32_t i = 0; i < argc; i++) {
166 ZVAL_COPY_VALUE(&params[i].zv, &args[i]);
167 }
168 return mysqlnd_stmt_bind_result(stmt->stmt, params);
169 }
170 return FAIL;
171}
172/* }}} */
173
174/* {{{ Bind variables to a prepared statement for result storage */
176{
177 zval *args;
178 uint32_t argc;
179 MY_STMT *stmt;
180 zval *mysql_stmt;
181
182 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O+", &mysql_stmt, mysqli_stmt_class_entry, &args, &argc) == FAILURE) {
184 }
185
187
188 if (argc != mysql_stmt_field_count(stmt->stmt)) {
189 zend_argument_count_error("Number of bind variables doesn't match number of fields in prepared statement");
191 }
192
193 enum_func_status rc = mysqli_stmt_bind_result_do_bind(stmt, args, argc);
194 RETURN_BOOL(rc == PASS);
195}
196/* }}} */
197
198/* {{{ Change logged-in user of the active connection */
200{
201 MY_MYSQL *mysql;
202 zval *mysql_link = NULL;
203 char *user, *password, *dbname;
204 size_t user_len, password_len, dbname_len;
205
206 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Osss!", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) {
208 }
210
211 enum_func_status rc = mysqlnd_change_user_ex(mysql->mysql, user, password, dbname, false, (size_t) password_len);
213
214 RETURN_BOOL(rc == PASS);
215}
216/* }}} */
217
218/* {{{ Returns the name of the character set used for this connection */
220{
221 MY_MYSQL *mysql;
222 zval *mysql_link;
223
226 }
227
230}
231/* }}} */
232
233/* {{{ php_mysqli_close */
234void php_mysqli_close(MY_MYSQL * mysql, int close_type, int resource_status)
235{
236 if (resource_status > MYSQLI_STATUS_INITIALIZED) {
237 MyG(num_links)--;
238 }
239
240 if (!mysql->persistent) {
241 mysqli_close(mysql->mysql, close_type);
242 } else {
243 zend_resource *le;
244 if ((le = zend_hash_find_ptr(&EG(persistent_list), mysql->hash_key)) != NULL) {
245 if (le->type == php_le_pmysqli()) {
248
251 {
252 mysqli_close(mysql->mysql, close_type);
253 } else {
254 zend_ptr_stack_push(&plist->free_links, mysql->mysql);
256 }
258 }
259 }
260 mysql->persistent = false;
261 }
262 mysql->mysql = NULL;
263
264 php_clear_mysql(mysql);
265}
266/* }}} */
267
268/* {{{ Close connection */
270{
271 zval *mysql_link;
272 MY_MYSQL *mysql;
273
276 }
277
279
281 ((MYSQLI_RESOURCE *)(Z_MYSQLI_P(mysql_link))->ptr)->status = MYSQLI_STATUS_UNKNOWN;
282
283 MYSQLI_CLEAR_RESOURCE(mysql_link);
284 efree(mysql);
286}
287/* }}} */
288
289/* {{{ Commit outstanding actions and close transaction */
291{
292 MY_MYSQL *mysql;
293 zval *mysql_link;
295 char * name = NULL;
296 size_t name_len;
297
298 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls!", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
300 }
302
303 if (FAIL == mysqlnd_commit(mysql->mysql, flags, name)) {
306 }
308}
309/* }}} */
310
311/* {{{ Move internal result pointer */
313{
315 zval *mysql_result;
317
320 }
321
322 if (offset < 0) {
323 zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0");
325 }
326
327 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
328
330 if (getThis()) {
331 zend_throw_error(NULL, "mysqli_result::data_seek() cannot be used in MYSQLI_USE_RESULT mode");
332 } else {
333 zend_throw_error(NULL, "mysqli_data_seek() cannot be used in MYSQLI_USE_RESULT mode");
334 }
336 }
337
338 if ((uint64_t)offset >= mysql_num_rows(result)) {
340 }
341
344}
345/* }}} */
346
347/* {{{ */
349{
350 char *debug;
351 size_t debug_len;
352
353 if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &debug, &debug_len) == FAILURE) {
355 }
356
359}
360/* }}} */
361
362/* {{{ */
364{
365 MY_MYSQL *mysql;
366 zval *mysql_link;
367
370 }
372
374}
375/* }}} */
376
377/* {{{ Returns the numerical value of the error message from previous MySQL operation */
379{
380 MY_MYSQL *mysql;
381 zval *mysql_link;
382
385 }
388}
389/* }}} */
390
391/* {{{ Returns the text of the error message from previous MySQL operation */
393{
394 MY_MYSQL *mysql;
395 zval *mysql_link;
396
399 }
402}
403/* }}} */
404
405/* {{{ Execute a prepared statement */
407{
408 MY_STMT *stmt;
409 zval *mysql_stmt;
410 HashTable *input_params = NULL;
411
412 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|h!", &mysql_stmt, mysqli_stmt_class_entry, &input_params) == FAILURE) {
414 }
416
417 // bind-in-execute
418 if (input_params) {
419 zval *tmp;
420 unsigned int index;
421 unsigned int hash_num_elements;
422 unsigned int param_count;
423 MYSQLND_PARAM_BIND *params;
424
425 if (!zend_array_is_list(input_params)) {
426 zend_argument_value_error(ERROR_ARG_POS(2), "must be a list array");
428 }
429
430 hash_num_elements = zend_hash_num_elements(input_params);
431 param_count = mysql_stmt_param_count(stmt->stmt);
432 if (hash_num_elements != param_count) {
433 zend_argument_value_error(ERROR_ARG_POS(2), "must consist of exactly %d elements, %d present", param_count, hash_num_elements);
435 }
436
437 params = mysqlnd_stmt_alloc_param_bind(stmt->stmt);
438 ZEND_ASSERT(params);
439
440 index = 0;
441 ZEND_HASH_FOREACH_VAL(input_params, tmp) {
442 ZVAL_COPY_VALUE(&params[index].zv, tmp);
443 params[index].type = MYSQL_TYPE_VAR_STRING;
444 index++;
446
447 if (mysqlnd_stmt_bind_param(stmt->stmt, params)) {
450 }
451 }
452
453 if (mysql_stmt_execute(stmt->stmt)) {
456 } else {
458 }
459
462 }
463}
464/* }}} */
465
467{
468 /* mysql_stmt_close() clears errors, so we have to store them temporarily */
469 MYSQLND_ERROR_INFO error_info = *stmt->stmt->data->error_info;
470 stmt->stmt->data->error_info->error_list.head = NULL;
471 stmt->stmt->data->error_info->error_list.tail = NULL;
472 stmt->stmt->data->error_info->error_list.count = 0;
473
474 /* we also remember affected_rows which gets cleared too */
475 uint64_t affected_rows = mysql->mysql->data->upsert_status->affected_rows;
476
477 mysqli_stmt_close(stmt->stmt, false);
478 stmt->stmt = NULL;
480
481 /* restore error messages, but into the mysql object */
482 zend_llist_clean(&mysql->mysql->data->error_info->error_list);
483 *mysql->mysql->data->error_info = error_info;
484 mysql->mysql->data->upsert_status->affected_rows = affected_rows;
485}
486
488{
489 MY_MYSQL *mysql;
490 MY_STMT *stmt;
491 char *query = NULL;
492 size_t query_len;
493 zval *mysql_link;
494 HashTable *input_params = NULL;
496 MYSQLI_RESOURCE *mysqli_resource;
497
498 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|h!", &mysql_link, mysqli_link_class_entry, &query, &query_len, &input_params) == FAILURE) {
500 }
502
503 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
504
505 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
507 efree(stmt);
509 }
510
511 if (FAIL == mysql_stmt_prepare(stmt->stmt, query, query_len)) {
513
514 close_stmt_and_copy_errors(stmt, mysql);
516 }
517
518 /* The bit below, which is copied from mysqli_prepare, is needed for bad index exceptions */
519 /* don't initialize stmt->query with NULL, we ecalloc()-ed the memory */
520 /* Get performance boost if reporting is switched off */
521 if (query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
522 stmt->query = estrdup(query);
523 }
524
525 // bind-in-execute
526 // It's very similar to the mysqli_stmt::execute, but it uses different error handling
527 if (input_params) {
528 zval *tmp;
529 unsigned int index;
530 unsigned int hash_num_elements;
531 unsigned int param_count;
532 MYSQLND_PARAM_BIND *params;
533
534 if (!zend_array_is_list(input_params)) {
535 mysqli_stmt_close(stmt->stmt, false);
536 stmt->stmt = NULL;
537 efree(stmt);
538 zend_argument_value_error(ERROR_ARG_POS(3), "must be a list array");
540 }
541
542 hash_num_elements = zend_hash_num_elements(input_params);
543 param_count = mysql_stmt_param_count(stmt->stmt);
544 if (hash_num_elements != param_count) {
545 mysqli_stmt_close(stmt->stmt, false);
546 stmt->stmt = NULL;
547 efree(stmt);
548 zend_argument_value_error(ERROR_ARG_POS(3), "must consist of exactly %d elements, %d present", param_count, hash_num_elements);
550 }
551
552 params = mysqlnd_stmt_alloc_param_bind(stmt->stmt);
553 ZEND_ASSERT(params);
554
555 index = 0;
556 ZEND_HASH_FOREACH_VAL(input_params, tmp) {
557 ZVAL_COPY_VALUE(&params[index].zv, tmp);
558 params[index].type = MYSQL_TYPE_VAR_STRING;
559 index++;
561
562 if (mysqlnd_stmt_bind_param(stmt->stmt, params)) {
563 close_stmt_and_copy_errors(stmt, mysql);
565 }
566
567 }
568
569 if (mysql_stmt_execute(stmt->stmt)) {
571
574 }
575
576 close_stmt_and_copy_errors(stmt, mysql);
578 }
579
580 if (!mysql_stmt_field_count(stmt->stmt)) {
581 /* no result set - not a SELECT */
582 close_stmt_and_copy_errors(stmt, mysql);
584 }
585
588 }
589
590 /* get result */
591 if (!(result = mysqlnd_stmt_get_result(stmt->stmt))) {
593
594 close_stmt_and_copy_errors(stmt, mysql);
596 }
597
598 mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
599 mysqli_resource->ptr = (void *)result;
600 mysqli_resource->status = MYSQLI_STATUS_VALID;
602
603 close_stmt_and_copy_errors(stmt, mysql);
604}
605
606/* {{{ mixed mysqli_stmt_fetch_mysqlnd */
608{
609 MY_STMT *stmt;
610 zval *mysql_stmt;
611 bool fetched_anything;
612
615 }
617
618 if (FAIL == mysqlnd_stmt_fetch(stmt->stmt, &fetched_anything)) {
621 } else if (fetched_anything) {
623 } else {
624 RETURN_NULL();
625 }
626}
627/* }}} */
628
629/* {{{ Fetch results from a prepared statement into the bound variables */
634/* }}} */
635
636/* {{{ php_add_field_properties */
637static void php_add_field_properties(zval *value, const MYSQL_FIELD *field)
638{
639 add_property_str(value, "name", zend_string_copy(field->sname));
640
641 add_property_stringl(value, "orgname", (field->org_name ? field->org_name : ""), field->org_name_length);
642 add_property_stringl(value, "table", (field->table ? field->table : ""), field->table_length);
643 add_property_stringl(value, "orgtable", (field->org_table ? field->org_table : ""), field->org_table_length);
644 add_property_stringl(value, "def", (field->def ? field->def : ""), field->def_length);
645 add_property_stringl(value, "db", (field->db ? field->db : ""), field->db_length);
646
647 /* FIXME: manually set the catalog to "def" due to bug in
648 * libmysqlclient which does not initialize field->catalog
649 * and in addition, the catalog is always be "def"
650 */
651 add_property_string(value, "catalog", "def");
652
653 add_property_long(value, "max_length", 0);
654 add_property_long(value, "length", field->length);
655 add_property_long(value, "charsetnr", field->charsetnr);
656 add_property_long(value, "flags", field->flags);
657 add_property_long(value, "type", field->type);
658 add_property_long(value, "decimals", field->decimals);
659}
660/* }}} */
661
662/* {{{ Get column information from a result and return as an object */
664{
666 zval *mysql_result;
667 const MYSQL_FIELD *field;
668
671 }
672
673 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
674
675 if (!(field = mysql_fetch_field(result))) {
677 }
678
680 php_add_field_properties(return_value, field);
681}
682/* }}} */
683
684/* {{{ Return array of objects containing field meta-data */
686{
688 zval *mysql_result;
689 zval obj;
690
691 unsigned int i, num_fields;
692
695 }
696
697 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
698
700 num_fields = mysql_num_fields(result);
701
702 for (i = 0; i < num_fields; i++) {
704
705 object_init(&obj);
706
707 php_add_field_properties(&obj, field);
708 add_index_zval(return_value, i, &obj);
709 }
710}
711/* }}} */
712
713/* {{{ Fetch meta-data for a single field */
715{
717 zval *mysql_result;
718 const MYSQL_FIELD *field;
720
723 }
724
725 if (offset < 0) {
726 zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0");
728 }
729
730 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
731
733 zend_argument_value_error(ERROR_ARG_POS(2), "must be less than the number of fields for this result set");
735 }
736
737 if (!(field = mysql_fetch_field_direct(result,offset))) {
739 }
740
742 php_add_field_properties(return_value, field);
743}
744/* }}} */
745
746/* {{{ Get the length of each output in a result */
748{
750 zval *mysql_result;
751 unsigned int i, num_fields;
752 const size_t *ret;
753
756 }
757
758 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
759
760 // TODO Warning?
761 if (!(ret = mysql_fetch_lengths(result))) {
763 }
764
766 num_fields = mysql_num_fields(result);
767
768 for (i = 0; i < num_fields; i++) {
770 }
771}
772/* }}} */
773
774/* {{{ Get a result row as an enumerated array */
779/* }}} */
780
781/* {{{ Fetch the number of fields returned by the last query for the given link */
783{
784 MY_MYSQL *mysql;
785 zval *mysql_link;
786
789 }
791
793}
794/* }}} */
795
796/* {{{ Set result pointer to a specified field offset */
798{
800 zval *mysql_result;
801 zend_long fieldnr;
802
803 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &mysql_result, mysqli_result_class_entry, &fieldnr) == FAILURE) {
805 }
806
807 if (fieldnr < 0) {
808 zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0");
810 }
811
812 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
813
814 if ((uint32_t)fieldnr >= mysql_num_fields(result)) {
815 zend_argument_value_error(ERROR_ARG_POS(2), "must be less than the number of fields for this result set");
817 }
818
819 mysql_field_seek(result, fieldnr);
821}
822/* }}} */
823
824/* {{{ Get current field offset of result pointer */
826{
828 zval *mysql_result;
829
832 }
833 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
834
836}
837/* }}} */
838
839/* {{{ Free query result memory for the given result handle */
841{
843 zval *mysql_result;
844
847 }
848 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
849
851 MYSQLI_CLEAR_RESOURCE(mysql_result);
852}
853/* }}} */
854
855/* {{{ Get MySQL client info */
857{
858 if (getThis()) {
861 }
862 } else {
863 zval *mysql_link;
864
867 }
868
869 if (ZEND_NUM_ARGS()) {
870 php_error_docref(NULL, E_DEPRECATED, "Passing connection object as an argument is deprecated");
871 }
872 }
873
875}
876/* }}} */
877
878/* {{{ Get MySQL client info */
887/* }}} */
888
889/* {{{ Get MySQL host info */
891{
892 MY_MYSQL *mysql;
893 zval *mysql_link = NULL;
894
897 }
899 RETURN_STRING((mysql->mysql->data->host_info) ? mysql->mysql->data->host_info : "");
900}
901/* }}} */
902
903/* {{{ Get MySQL protocol information */
905{
906 MY_MYSQL *mysql;
907 zval *mysql_link = NULL;
908
911 }
914}
915/* }}} */
916
917/* {{{ Get MySQL server info */
919{
920 MY_MYSQL *mysql;
921 zval *mysql_link = NULL;
922
925 }
927
929}
930/* }}} */
931
932/* {{{ Return the MySQL version for the server referenced by the given link */
934{
935 MY_MYSQL *mysql;
936 zval *mysql_link = NULL;
937
940 }
942
944}
945/* }}} */
946
947/* {{{ Get information about the most recent query */
949{
950 MY_MYSQL *mysql;
951 zval *mysql_link = NULL;
952 const char *info;
953
956 }
958
959 info = mysql_info(mysql->mysql);
960 if (info) {
961 RETURN_STRING(info);
962 }
963}
964/* }}} */
965
966/* {{{ php_mysqli_init() */
968{
969 MYSQLI_RESOURCE *mysqli_resource;
970 MY_MYSQL *mysql;
971
974 }
975
976 if (is_method && (Z_MYSQLI_P(getThis()))->ptr) {
977 return;
978 }
979
980 mysql = (MY_MYSQL *)ecalloc(1, sizeof(MY_MYSQL));
981
982 /*
983 We create always persistent, as if the user want to connect
984 to p:somehost, we can't convert the handle then
985 */
986 if (!(mysql->mysql = mysqlnd_init(MYSQLND_CLIENT_NO_FLAG, true)))
987 {
988 efree(mysql);
990 }
991
992 mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
993 mysqli_resource->ptr = (void *)mysql;
994 mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
995
996 if (!is_method) {
998 } else {
999 (Z_MYSQLI_P(getThis()))->ptr = mysqli_resource;
1000 }
1001}
1002/* }}} */
1003
1004/* {{{ Initialize mysqli and return a resource for use with mysql_real_connect */
1009/* }}} */
1010
1011/* {{{ Get the ID generated from the previous INSERT operation */
1013{
1014 MY_MYSQL *mysql;
1015 my_ulonglong rc;
1016 zval *mysql_link;
1017
1019 RETURN_THROWS();
1020 }
1022 rc = mysql_insert_id(mysql->mysql);
1024}
1025/* }}} */
1026
1027/* {{{ Kill a mysql process on the server */
1029{
1030 MY_MYSQL *mysql;
1031 zval *mysql_link;
1032 zend_long processid;
1033
1034 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &mysql_link, mysqli_link_class_entry, &processid) == FAILURE) {
1035 RETURN_THROWS();
1036 }
1037
1038 if (processid <= 0) {
1039 zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than 0");
1040 RETURN_THROWS();
1041 }
1042
1044
1045 if (mysql_kill(mysql->mysql, processid)) {
1048 }
1050}
1051/* }}} */
1052
1053/* {{{ check if there any more query results from a multi query */
1055{
1056 MY_MYSQL *mysql;
1057 zval *mysql_link;
1058
1060 RETURN_THROWS();
1061 }
1063
1065}
1066/* }}} */
1067
1068/* {{{ read next result from multi_query */
1070 MY_MYSQL *mysql;
1071 zval *mysql_link;
1072
1074 RETURN_THROWS();
1075 }
1077
1078 if (mysql_next_result(mysql->mysql)) {
1081 }
1083}
1084/* }}} */
1085
1086
1087/* {{{ check if there any more query results from a multi query */
1089{
1090 MY_STMT *stmt;
1091 zval *mysql_stmt;
1092
1094 RETURN_THROWS();
1095 }
1097
1099}
1100/* }}} */
1101
1102/* {{{ read next result from multi_query */
1104 MY_STMT *stmt;
1105 zval *mysql_stmt;
1106
1108 RETURN_THROWS();
1109 }
1111
1112 if (mysql_stmt_next_result(stmt->stmt)) {
1115 }
1117}
1118/* }}} */
1119
1120/* {{{ Get number of fields in result */
1122{
1124 zval *mysql_result;
1125
1127 RETURN_THROWS();
1128 }
1129 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
1130
1132}
1133/* }}} */
1134
1135/* {{{ Get number of rows in result */
1137{
1139 zval *mysql_result;
1140
1142 RETURN_THROWS();
1143 }
1144 MYSQLI_FETCH_RESOURCE(result, MYSQL_RES *, mysql_result, "mysqli_result", MYSQLI_STATUS_VALID);
1145
1147 zend_throw_error(NULL, "mysqli_num_rows() cannot be used in MYSQLI_USE_RESULT mode");
1148 RETURN_THROWS();
1149 }
1150
1152}
1153/* }}} */
1154
1155/* {{{ mysqli_options_get_option_zval_type */
1156static int mysqli_options_get_option_zval_type(int option)
1157{
1158 switch (option) {
1165 case MYSQL_OPT_PROTOCOL:
1169 case MYSQL_OPT_COMPRESS:
1171 return IS_LONG;
1172
1175 case MYSQL_INIT_COMMAND:
1179 return IS_STRING;
1180
1181 default:
1182 return IS_NULL;
1183 }
1184}
1185/* }}} */
1186
1187/* {{{ Set options */
1189{
1190 MY_MYSQL *mysql;
1191 zval *mysql_link = NULL;
1192 zval *mysql_value;
1193 zend_long mysql_option;
1194 unsigned int l_value;
1195 zend_long ret;
1196 int expected_type;
1197
1198 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz", &mysql_link, mysqli_link_class_entry, &mysql_option, &mysql_value) == FAILURE) {
1199 RETURN_THROWS();
1200 }
1202
1203 expected_type = mysqli_options_get_option_zval_type(mysql_option);
1204 if (expected_type != Z_TYPE_P(mysql_value)) {
1205 switch (expected_type) {
1206 case IS_STRING:
1207 if (!try_convert_to_string(mysql_value)) {
1208 RETURN_THROWS();
1209 }
1210 break;
1211 case IS_LONG:
1212 convert_to_long(mysql_value);
1213 break;
1214 default:
1215 break;
1216 }
1217 }
1218 switch (expected_type) {
1219 case IS_STRING:
1220 if ((ret = mysql_options(mysql->mysql, mysql_option, Z_STRVAL_P(mysql_value)))) {
1222 }
1223 break;
1224 case IS_LONG:
1225 l_value = Z_LVAL_P(mysql_value);
1226 if ((ret = mysql_options(mysql->mysql, mysql_option, (char *)&l_value))) {
1228 }
1229 break;
1230 default:
1231 ret = 1;
1232 break;
1233 }
1234
1235 RETURN_BOOL(!ret);
1236}
1237/* }}} */
1238
1239/* {{{ Ping a server connection or reconnect if there is no connection */
1241{
1242 MY_MYSQL *mysql;
1243 zval *mysql_link;
1244 zend_long rc;
1245
1247 RETURN_THROWS();
1248 }
1250 rc = mysql_ping(mysql->mysql);
1252
1253 RETURN_BOOL(!rc);
1254}
1255/* }}} */
1256
1257/* {{{ Prepare a SQL statement for execution */
1259{
1260 MY_MYSQL *mysql;
1261 MY_STMT *stmt;
1262 char *query = NULL;
1263 size_t query_len;
1264 zval *mysql_link;
1265 MYSQLI_RESOURCE *mysqli_resource;
1266
1267 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os",&mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
1268 RETURN_THROWS();
1269 }
1271
1272 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1273
1274 if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1275 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1276 /* mysql_stmt_close() clears errors, so we have to store them temporarily */
1277 MYSQLND_ERROR_INFO error_info = *mysql->mysql->data->error_info;
1278 mysql->mysql->data->error_info->error_list.head = NULL;
1279 mysql->mysql->data->error_info->error_list.tail = NULL;
1280 mysql->mysql->data->error_info->error_list.count = 0;
1281 mysqli_stmt_close(stmt->stmt, false);
1282 stmt->stmt = NULL;
1283
1284 /* restore error messages */
1285 zend_llist_clean(&mysql->mysql->data->error_info->error_list);
1286 *mysql->mysql->data->error_info = error_info;
1287 }
1288 }
1289
1290 /* don't initialize stmt->query with NULL, we ecalloc()-ed the memory */
1291 /* Get performance boost if reporting is switched off */
1292 if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1293 stmt->query = estrdup(query);
1294 }
1295
1296 /* don't join to the previous if because it won't work if mysql_stmt_prepare_fails */
1297 if (!stmt->stmt) {
1299 efree(stmt);
1301 }
1302
1303 mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
1304 mysqli_resource->ptr = (void *)stmt;
1305
1306 /* change status */
1307 mysqli_resource->status = MYSQLI_STATUS_VALID;
1309}
1310/* }}} */
1311
1312/* {{{ Open a connection to a mysql server */
1317/* }}} */
1318
1319/* {{{ Binary-safe version of mysql_query() */
1321{
1322 MY_MYSQL *mysql;
1323 zval *mysql_link;
1324 char *query = NULL;
1325 size_t query_len;
1326
1327 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &mysql_link, mysqli_link_class_entry, &query, &query_len) == FAILURE) {
1328 RETURN_THROWS();
1329 }
1331
1332 MYSQLI_DISABLE_MQ; /* disable multi statements/queries */
1333
1334 if (mysql_real_query(mysql->mysql, query, query_len)) {
1337 }
1338
1339 if (!mysql_field_count(mysql->mysql)) {
1342 }
1343 }
1344
1346}
1347/* }}} */
1348
1349# define mysql_real_escape_string_quote(mysql, to, from, length, quote) \
1350 mysql_real_escape_string(mysql, to, from, length)
1351
1353 MY_MYSQL *mysql;
1354 zval *mysql_link = NULL;
1355 char *escapestr;
1356 size_t escapestr_len;
1357 zend_string *newstr;
1358
1359 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &mysql_link, mysqli_link_class_entry, &escapestr, &escapestr_len) == FAILURE) {
1360 RETURN_THROWS();
1361 }
1363
1364 newstr = zend_string_safe_alloc(2, escapestr_len, 0, 0);
1365 ZSTR_LEN(newstr) = mysql_real_escape_string_quote(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len, '\'');
1366 newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0);
1367
1368 RETURN_NEW_STR(newstr);
1369}
1370
1371/* {{{ Undo actions from current transaction */
1373{
1374 MY_MYSQL *mysql;
1375 zval *mysql_link;
1377 char * name = NULL;
1378 size_t name_len = 0;
1379
1380 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|ls!", &mysql_link, mysqli_link_class_entry, &flags, &name, &name_len) == FAILURE) {
1381 RETURN_THROWS();
1382 }
1384
1385
1386 if (FAIL == mysqlnd_rollback(mysql->mysql, flags, name)) {
1389 }
1391}
1392/* }}} */
1393
1394/* {{{ */
1396{
1397 MY_STMT *stmt;
1398 zval *mysql_stmt;
1399 char *data;
1400 zend_long param_nr;
1401 size_t data_len;
1402
1403 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ols", &mysql_stmt, mysqli_stmt_class_entry, &param_nr, &data, &data_len) == FAILURE) {
1404 RETURN_THROWS();
1405 }
1406
1408
1409 if (param_nr < 0) {
1410 zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0");
1411 RETURN_THROWS();
1412 }
1413
1414 if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
1416 }
1418}
1419/* }}} */
1420
1421/* {{{ Return the number of rows affected in the last query for the given link. */
1423{
1424 MY_STMT *stmt;
1425 zval *mysql_stmt;
1426 my_ulonglong rc;
1427
1429 RETURN_THROWS();
1430 }
1432
1433 rc = mysql_stmt_affected_rows(stmt->stmt);
1434 if (rc == (my_ulonglong) -1) {
1435 RETURN_LONG(-1);
1436 }
1438}
1439/* }}} */
1440
1441/* {{{ Close statement */
1443{
1444 MY_STMT *stmt;
1445 zval *mysql_stmt;
1446
1448 RETURN_THROWS();
1449 }
1451
1452 mysqli_stmt_close(stmt->stmt, false);
1453 stmt->stmt = NULL;
1454 php_clear_stmt_bind(stmt);
1455 MYSQLI_CLEAR_RESOURCE(mysql_stmt);
1457}
1458/* }}} */
1459
1460/* {{{ Move internal result pointer */
1462{
1463 MY_STMT *stmt;
1464 zval *mysql_stmt;
1466
1468 RETURN_THROWS();
1469 }
1470
1471 if (offset < 0) {
1472 zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0");
1473 RETURN_THROWS();
1474 }
1475
1477
1479}
1480/* }}} */
1481
1482/* {{{ Return the number of result columns for the given statement */
1484{
1485 MY_STMT *stmt;
1486 zval *mysql_stmt;
1487
1489 RETURN_THROWS();
1490 }
1492
1494}
1495/* }}} */
1496
1497/* {{{ Free stored result memory for the given statement handle */
1499{
1500 MY_STMT *stmt;
1501 zval *mysql_stmt;
1502
1504 RETURN_THROWS();
1505 }
1506
1508
1510}
1511/* }}} */
1512
1513/* {{{ Get the ID generated from the previous INSERT operation */
1515{
1516 MY_STMT *stmt;
1517 my_ulonglong rc;
1518 zval *mysql_stmt;
1519
1521 RETURN_THROWS();
1522 }
1524 rc = mysql_stmt_insert_id(stmt->stmt);
1526}
1527/* }}} */
1528
1529/* {{{ Return the number of parameter for the given statement */
1531{
1532 MY_STMT *stmt;
1533 zval *mysql_stmt;
1534
1536 RETURN_THROWS();
1537 }
1539
1541}
1542/* }}} */
1543
1544/* {{{ reset a prepared statement */
1546{
1547 MY_STMT *stmt;
1548 zval *mysql_stmt;
1549
1551 RETURN_THROWS();
1552 }
1553
1555
1556 if (mysql_stmt_reset(stmt->stmt)) {
1558 }
1560}
1561/* }}} */
1562
1563/* {{{ Return the number of rows in statements result set */
1565{
1566 MY_STMT *stmt;
1567 zval *mysql_stmt;
1568 my_ulonglong rc;
1569
1571 RETURN_THROWS();
1572 }
1573
1575
1576 rc = mysql_stmt_num_rows(stmt->stmt);
1578}
1579/* }}} */
1580
1581/* {{{ Select a MySQL database */
1583{
1584 MY_MYSQL *mysql;
1585 zval *mysql_link;
1586 char *dbname;
1587 size_t dbname_len;
1588
1589 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &mysql_link, mysqli_link_class_entry, &dbname, &dbname_len) == FAILURE) {
1590 RETURN_THROWS();
1591 }
1593
1594 if (mysql_select_db(mysql->mysql, dbname)) {
1597 }
1599}
1600/* }}} */
1601
1602/* {{{ Returns the SQLSTATE error from previous MySQL operation */
1604{
1605 MY_MYSQL *mysql;
1606 zval *mysql_link;
1607
1609 RETURN_THROWS();
1610 }
1613}
1614/* }}} */
1615
1616/* {{{ */
1618{
1619 MY_MYSQL *mysql;
1620 zval *mysql_link;
1621 char *ssl_parm[5];
1622 size_t ssl_parm_len[5], i;
1623
1624 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os!s!s!s!s!", &mysql_link, mysqli_link_class_entry, &ssl_parm[0], &ssl_parm_len[0], &ssl_parm[1], &ssl_parm_len[1], &ssl_parm[2], &ssl_parm_len[2], &ssl_parm[3], &ssl_parm_len[3], &ssl_parm[4], &ssl_parm_len[4]) == FAILURE) {
1625 RETURN_THROWS();
1626 }
1628
1629 for (i = 0; i < 5; i++) {
1630 if (!ssl_parm_len[i]) {
1631 ssl_parm[i] = NULL;
1632 }
1633 }
1634
1635 mysql_ssl_set(mysql->mysql, ssl_parm[0], ssl_parm[1], ssl_parm[2], ssl_parm[3], ssl_parm[4]);
1636
1638}
1639/* }}} */
1640
1641/* {{{ Get current system status */
1643{
1644 MY_MYSQL *mysql;
1645 zval *mysql_link;
1647
1649 RETURN_THROWS();
1650 }
1652
1653 if (mysqlnd_stat(mysql->mysql, &stat) == PASS)
1654 {
1656 } else {
1658 }
1659}
1660
1661/* }}} */
1662
1663/* {{{ Flush tables or caches, or reset replication server information */
1665{
1666 MY_MYSQL *mysql;
1667 zval *mysql_link = NULL;
1669
1671 RETURN_THROWS();
1672 }
1674 RETURN_BOOL(!mysql_refresh(mysql->mysql, (uint8_t) options));
1675}
1676/* }}} */
1677
1678/* {{{ */
1680{
1681 MY_STMT *stmt;
1682 zval *mysql_stmt;
1683 zend_long mode_in;
1684 my_bool mode_b;
1685 unsigned long mode;
1687 void *mode_p;
1688
1689 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &mysql_stmt, mysqli_stmt_class_entry, &attr, &mode_in) == FAILURE) {
1690 RETURN_THROWS();
1691 }
1692
1694
1695 switch (attr) {
1697 if (mode_in != 0 && mode_in != 1) {
1698 zend_argument_value_error(ERROR_ARG_POS(3), "must be 0 or 1 for attribute MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH");
1699 RETURN_THROWS();
1700 }
1701 mode_b = (my_bool) mode_in;
1702 mode_p = &mode_b;
1703 break;
1705 switch (mode_in) {
1708 break;
1709 default:
1710 zend_argument_value_error(ERROR_ARG_POS(3), "must be one of the MYSQLI_CURSOR_TYPE_* constants "
1711 "for attribute MYSQLI_STMT_ATTR_CURSOR_TYPE");
1712 RETURN_THROWS();
1713 }
1714 mode = mode_in;
1715 mode_p = &mode;
1716 break;
1717 default:
1718 zend_argument_value_error(ERROR_ARG_POS(2), "must be either "
1719 "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or MYSQLI_STMT_ATTR_CURSOR_TYPE");
1720 RETURN_THROWS();
1721 }
1722
1723 if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
1726 }
1728}
1729/* }}} */
1730
1731/* {{{ */
1733{
1734 MY_STMT *stmt;
1735 zval *mysql_stmt;
1736 unsigned long value = 0;
1738 int rc;
1739
1741 RETURN_THROWS();
1742 }
1743
1745
1746 if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
1747 /* Success corresponds to 0 return value and a non-zero value
1748 * should only happen if the attr/option is unknown */
1749 zend_argument_value_error(ERROR_ARG_POS(2), "must be either "
1750 "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or MYSQLI_STMT_ATTR_CURSOR_TYPE");
1751 RETURN_THROWS();
1752 }
1753
1755 value = (my_bool)value;
1756
1757 RETURN_LONG((unsigned long)value);
1758}
1759/* }}} */
1760
1761/* {{{ */
1763{
1764 MY_STMT *stmt;
1765 zval *mysql_stmt;
1766
1768 RETURN_THROWS();
1769 }
1771
1773}
1774/* }}} */
1775
1776/* {{{ */
1778{
1779 MY_STMT *stmt;
1780 zval *mysql_stmt;
1781
1783 RETURN_THROWS();
1784 }
1786
1788}
1789/* }}} */
1790
1791/* {{{ Initialize statement object */
1793{
1794 MY_MYSQL *mysql;
1795 MY_STMT *stmt;
1796 zval *mysql_link;
1797 MYSQLI_RESOURCE *mysqli_resource;
1798
1800 RETURN_THROWS();
1801 }
1803
1804 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1805
1806 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1807 efree(stmt);
1809 }
1810
1811 mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
1812 mysqli_resource->status = MYSQLI_STATUS_INITIALIZED;
1813 mysqli_resource->ptr = (void *)stmt;
1815}
1816/* }}} */
1817
1818/* {{{ prepare server side statement with query */
1820{
1821 MY_STMT *stmt;
1822 zval *mysql_stmt;
1823 char *query;
1824 size_t query_len;
1825
1826 if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &mysql_stmt, mysqli_stmt_class_entry, &query, &query_len) == FAILURE) {
1827 RETURN_THROWS();
1828 }
1830
1831 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1834 }
1835 /* change status */
1838}
1839/* }}} */
1840
1841/* {{{ return result set from statement */
1843{
1844 MY_STMT *stmt;
1846 zval *mysql_stmt;
1847 MYSQLI_RESOURCE *mysqli_resource;
1848
1850 RETURN_THROWS();
1851 }
1853
1854 if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
1857 }
1858
1859 mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
1860 mysqli_resource->ptr = (void *)result;
1861 mysqli_resource->status = MYSQLI_STATUS_VALID;
1863}
1864/* }}} */
1865
1866/* {{{ */
1868{
1869 MY_STMT *stmt;
1870 zval *mysql_stmt;
1871
1873 RETURN_THROWS();
1874 }
1876
1877 if (mysql_stmt_store_result(stmt->stmt)){
1880 }
1882}
1883/* }}} */
1884
1885/* {{{ */
1887{
1888 MY_STMT *stmt;
1889 zval *mysql_stmt;
1890
1892 RETURN_THROWS();
1893 }
1895
1897}
1898/* }}} */
1899
1900/* {{{ Buffer result set on client */
1902{
1903 MY_MYSQL *mysql;
1905 zval *mysql_link;
1906 MYSQLI_RESOURCE *mysqli_resource;
1907 zend_long flags = 0;
1908
1909
1911 RETURN_THROWS();
1912 }
1913
1914 if ((hasThis() && ZEND_NUM_ARGS() == 1) || ZEND_NUM_ARGS() == 2) {
1915 zend_error(E_DEPRECATED, "Passing the $mode parameter is deprecated since 8.4, as it has been ignored since 8.1");
1916 if (UNEXPECTED(EG(exception))) {
1917 RETURN_THROWS();
1918 }
1919 }
1920
1923 if (!result) {
1926 }
1928 php_mysqli_report_index("from previous query", mysqli_server_status(mysql->mysql));
1929 }
1930
1931 mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
1932 mysqli_resource->ptr = (void *)result;
1933 mysqli_resource->status = MYSQLI_STATUS_VALID;
1935}
1936/* }}} */
1937
1938/* {{{ Return the current thread ID */
1940{
1941 MY_MYSQL *mysql;
1942 zval *mysql_link;
1943
1945 RETURN_THROWS();
1946 }
1948
1950}
1951/* }}} */
1952
1953/* {{{ Return whether thread safety is given or not */
1962/* }}} */
1963
1964/* {{{ Directly retrieve query results - do not buffer results on client side */
1966{
1967 MY_MYSQL *mysql;
1969 zval *mysql_link;
1970 MYSQLI_RESOURCE *mysqli_resource;
1971
1973 RETURN_THROWS();
1974 }
1976
1977 if (!(result = mysql_use_result(mysql->mysql))) {
1980 }
1981
1983 php_mysqli_report_index("from previous query", mysqli_server_status(mysql->mysql));
1984 }
1985 mysqli_resource = (MYSQLI_RESOURCE *)ecalloc (1, sizeof(MYSQLI_RESOURCE));
1986 mysqli_resource->ptr = (void *)result;
1987 mysqli_resource->status = MYSQLI_STATUS_VALID;
1989}
1990/* }}} */
1991
1992/* {{{ Return number of warnings from the last query for the given link */
1994{
1995 MY_MYSQL *mysql;
1996 zval *mysql_link;
1997
1999 RETURN_THROWS();
2000 }
2002
2004}
2005/* }}} */
bool exception
Definition assert.c:30
stat(string $filename)
DNS_STATUS status
Definition dns_win32.c:49
zend_ffi_type * type
Definition ffi.c:3812
zval * zv
Definition ffi.c:3975
void * ptr
Definition ffi.c:3814
new_type attr
Definition ffi.c:4364
zend_long offset
char * mode
#define NULL
Definition gdcache.h:45
#define PASS(tables)
Definition hash_gost.c:193
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
Definition main.c:1173
zend_class_entry * mysqli_result_class_entry
Definition mysqli.c:68
void php_mysqli_fetch_into_hash(INTERNAL_FUNCTION_PARAMETERS, int override_flags, int into_object)
Definition mysqli.c:746
void php_clear_stmt_bind(MY_STMT *stmt)
Definition mysqli.c:114
zend_class_entry * mysqli_stmt_class_entry
Definition mysqli.c:67
void php_clear_mysql(MY_MYSQL *mysql)
Definition mysqli.c:135
zend_class_entry * mysqli_link_class_entry
Definition mysqli.c:66
int php_le_pmysqli(void)
Definition mysqli.c:108
mysqli_stmt_free_result(mysqli_stmt $statement)
mysqli_num_fields(mysqli_result $result)
mysqli_get_client_info(?mysqli $mysql=null)
mysqli_stmt_insert_id(mysqli_stmt $statement)
mysqli_execute_query(mysqli $mysql, string $query, ?array $params=null)
mysqli_prepare(mysqli $mysql, string $query)
mysqli_change_user(mysqli $mysql, string $username, #[\SensitiveParameter] string $password, ?string $database)
mysqli_get_server_version(mysqli $mysql)
mysqli_num_rows(mysqli_result $result)
mysqli_error(mysqli $mysql)
mysqli_refresh(mysqli $mysql, int $flags)
mysqli_commit(mysqli $mysql, int $flags=0, ?string $name=null)
mysqli_stmt_affected_rows(mysqli_stmt $statement)
mysqli_get_server_info(mysqli $mysql)
mysqli_ssl_set(mysqli $mysql, ?string $key, ?string $certificate, ?string $ca_certificate, ?string $ca_path, ?string $cipher_algos)
mysqli_stmt_send_long_data(mysqli_stmt $statement, int $param_num, string $data)
mysqli_fetch_lengths(mysqli_result $result)
mysqli_stmt_sqlstate(mysqli_stmt $statement)
mysqli_stmt_data_seek(mysqli_stmt $statement, int $offset)
mysqli_stmt_reset(mysqli_stmt $statement)
mysqli_field_count(mysqli $mysql)
mysqli_field_seek(mysqli_result $result, int $index)
mysqli_get_client_version()
mysqli_next_result(mysqli $mysql)
mysqli_fetch_fields(mysqli_result $result)
mysqli_stmt_attr_get(mysqli_stmt $statement, int $attribute)
mysqli_init()
mysqli_affected_rows(mysqli $mysql)
mysqli_more_results(mysqli $mysql)
mysqli_ping(mysqli $mysql)
mysqli_stat(mysqli $mysql)
mysqli_stmt_param_count(mysqli_stmt $statement)
mysqli_stmt_next_result(mysqli_stmt $statement)
mysqli_errno(mysqli $mysql)
mysqli_store_result(mysqli $mysql, int $mode=0)
mysqli_stmt_store_result(mysqli_stmt $statement)
mysqli_fetch_field_direct(mysqli_result $result, int $index)
mysqli_stmt_bind_param(mysqli_stmt $statement, string $types, mixed &... $vars)
mysqli_autocommit(mysqli $mysql, bool $enable)
mysqli_rollback(mysqli $mysql, int $flags=0, ?string $name=null)
mysqli_kill(mysqli $mysql, int $process_id)
mysqli_fetch_field(mysqli_result $result)
mysqli_stmt_prepare(mysqli_stmt $statement, string $query)
mysqli_thread_id(mysqli $mysql)
mysqli_thread_safe()
mysqli_stmt_bind_result(mysqli_stmt $statement, mixed &... $vars)
mysqli_dump_debug_info(mysqli $mysql)
mysqli_debug(string $options)
mysqli_data_seek(mysqli_result $result, int $offset)
mysqli_options(mysqli $mysql, int $option, $value)
mysqli_field_tell(mysqli_result $result)
mysqli_stmt_execute(mysqli_stmt $statement, ?array $params=null)
mysqli_stmt_field_count(mysqli_stmt $statement)
mysqli_use_result(mysqli $mysql)
mysqli_stmt_error(mysqli_stmt $statement)
mysqli_insert_id(mysqli $mysql)
mysqli_stmt_init(mysqli $mysql)
mysqli_fetch_row(mysqli_result $result)
mysqli_get_proto_info(mysqli $mysql)
mysqli_real_connect(mysqli $mysql, ?string $hostname=null, ?string $username=null, #[\SensitiveParameter] ?string $password=null, ?string $database=null, ?int $port=null, ?string $socket=null, int $flags=0)
mysqli_real_query(mysqli $mysql, string $query)
mysqli_warning_count(mysqli $mysql)
mysqli_real_escape_string(mysqli $mysql, string $string)
mysqli_character_set_name(mysqli $mysql)
mysqli_get_host_info(mysqli $mysql)
mysqli_stmt_result_metadata(mysqli_stmt $statement)
mysqli_stmt_more_results(mysqli_stmt $statement)
mysqli_stmt_num_rows(mysqli_stmt $statement)
mysqli_sqlstate(mysqli $mysql)
mysqli_select_db(mysqli $mysql, string $database)
mysqli_info(mysqli $mysql)
mysqli_stmt_attr_set(mysqli_stmt $statement, int $attribute, int $value)
mysqli_stmt_errno(mysqli_stmt $statement)
mysqli_stmt_fetch(mysqli_stmt $statement)
#define mysql_real_escape_string_quote(mysql, to, from, length, quote)
void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS, bool is_method)
Definition mysqli_api.c:967
#define ERROR_ARG_POS(arg_num)
Definition mysqli_api.c:31
void mysqli_stmt_fetch_mysqlnd(INTERNAL_FUNCTION_PARAMETERS)
Definition mysqli_api.c:607
void close_stmt_and_copy_errors(MY_STMT *stmt, MY_MYSQL *mysql)
Definition mysqli_api.c:466
void php_mysqli_close(MY_MYSQL *mysql, int close_type, int resource_status)
Definition mysqli_api.c:234
#define mysqli_stmt_close(c, implicit)
#define MYSQLI_CLOSE_EXPLICIT
#define mysqli_result_is_unbuffered(r)
#define mysqli_server_status(c)
#define mysqli_free_result(r, implicit)
#define mysqli_close(c, how)
#define mysqli_result_is_unbuffered_and_not_everything_is_fetched(r)
#define mysqli_stmt_server_status(s)
void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, bool is_real_connect, bool in_ctor)
#define MYSQLI_REPORT_MYSQL_ERROR(mysql)
#define MYSQLI_RETURN_LONG_INT(__val)
Definition mysqli_priv.h:78
#define MYSQLI_REPORT_STMT_ERROR(stmt)
#define MYSQLI_DISABLE_MQ
Definition mysqli_priv.h:67
#define MYSQLI_REPORT_INDEX
#define MYSQLI_NUM
Definition mysqli_priv.h:95
void php_mysqli_report_index(const char *query, unsigned int status)
#define mysqlnd_init(flags, persistent)
Definition mysqlnd.h:81
#define mysqlnd_end_psession(conn)
Definition mysqlnd.h:72
#define mysqlnd_stmt_more_results(stmt)
Definition mysqlnd.h:218
#define mysqlnd_stmt_free_param_bind(stmt, bind)
Definition mysqlnd.h:225
#define mysqlnd_stmt_bind_param(stmt, bind)
Definition mysqlnd.h:226
#define mysqlnd_stat(conn, msg)
Definition mysqlnd.h:200
#define mysqlnd_stmt_fetch(stmt, fetched)
Definition mysqlnd.h:244
char * debug
Definition mysqlnd.h:298
#define mysqlnd_change_user_ex(conn, user, passwd, db, silent, passwd_len)
Definition mysqlnd.h:98
#define mysqlnd_rollback(conn, flags, name)
Definition mysqlnd.h:188
#define mysqlnd_stmt_alloc_result_bind(stmt)
Definition mysqlnd.h:229
#define mysqlnd_stmt_alloc_param_bind(stmt)
Definition mysqlnd.h:224
#define mysqlnd_stmt_bind_result(stmt, bind)
Definition mysqlnd.h:231
#define mysqlnd_stmt_get_result(stmt)
Definition mysqlnd.h:217
#define mysqlnd_commit(conn, flags, name)
Definition mysqlnd.h:187
@ MYSQL_OPT_CONNECT_TIMEOUT
@ MYSQL_OPT_COMPRESS
@ MYSQL_OPT_LOAD_DATA_LOCAL_DIR
@ MYSQL_OPT_PROTOCOL
@ MYSQLND_OPT_NET_CMD_BUFFER_SIZE
@ MYSQL_OPT_LOCAL_INFILE
@ MYSQL_SET_CHARSET_NAME
@ MYSQLND_OPT_INT_AND_FLOAT_NATIVE
@ MYSQL_SERVER_PUBLIC_KEY
@ MYSQL_OPT_READ_TIMEOUT
@ MYSQL_OPT_WRITE_TIMEOUT
@ MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
@ MYSQL_READ_DEFAULT_GROUP
@ MYSQL_OPT_SSL_VERIFY_SERVER_CERT
@ MYSQL_READ_DEFAULT_FILE
@ MYSQL_OPT_NAMED_PIPE
@ MYSQLND_OPT_NET_READ_BUFFER_SIZE
@ MYSQL_INIT_COMMAND
@ CURSOR_TYPE_NO_CURSOR
@ CURSOR_TYPE_READ_ONLY
@ STMT_ATTR_UPDATE_MAX_LENGTH
@ STMT_ATTR_CURSOR_TYPE
@ MYSQL_TYPE_LONGLONG
@ MYSQL_TYPE_LONG_BLOB
@ MYSQL_TYPE_VAR_STRING
@ MYSQL_TYPE_LONG
@ MYSQL_TYPE_DOUBLE
#define MYSQLND_CLIENT_NO_FLAG
enum func_status enum_func_status
#define TRANS_COR_NO_OPT
#define MYSQL_RES
#define mysql_stmt_store_result(s)
#define mysql_stmt_execute(s)
#define mysql_stmt_attr_set(s, a, v)
#define mysql_stmt_data_seek(s, r)
#define mysql_stmt_param_count(s)
#define mysql_info(r)
#define mysql_get_proto_info(r)
#define mysql_stmt_attr_get(s, a, v)
#define mysql_autocommit(r, m)
#define mysql_use_result(r)
#define my_ulonglong
#define mysql_ping(r)
#define mysql_insert_id(r)
#define mysql_stmt_error(s)
#define mysql_field_tell(r)
#define mysql_thread_id(r)
#define mysql_stmt_send_long_data(s, p, d, l)
#define mysql_warning_count(r)
#define mysql_get_client_version()
#define mysql_thread_safe()
#define mysql_sqlstate(r)
#define mysql_field_seek(r, o)
#define mysql_num_rows(r)
#define my_bool
#define mysql_refresh(conn, options)
#define mysql_field_count(r)
#define mysql_debug(x)
#define mysql_stmt_errno(s)
#define mysql_store_result(r)
#define mysql_more_results(r)
#define mysql_affected_rows(r)
#define mysql_ssl_set(c, key, cert, ca, capath, cipher)
#define mysql_fetch_field_direct(r, o)
#define mysql_kill(r, n)
#define mysql_character_set_name(c)
#define mysql_fetch_lengths(r)
#define mysql_stmt_free_result(s)
#define mysql_fetch_field(r)
#define MYSQL_FIELD
#define mysql_real_query(r, a, b)
#define mysql_options(c, a, v)
#define mysql_stmt_field_count(s)
#define mysql_stmt_sqlstate(s)
#define mysql_data_seek(r, o)
#define mysql_error(r)
#define mysql_errno(r)
#define mysql_select_db(r, a)
#define mysql_stmt_insert_id(s)
#define mysql_stmt_affected_rows(s)
#define mysql_stmt_prepare(s, q, l)
#define mysql_dump_debug_info(r)
#define mysql_get_client_info()
#define mysql_stmt_init(r)
#define mysql_stmt_reset(s)
#define mysql_stmt_num_rows(s)
#define mysql_next_result(r)
#define mysql_get_server_info(r)
#define mysql_num_fields(r)
#define mysql_stmt_result_metadata(s)
#define mysql_stmt_next_result(s)
#define mysql_get_server_version(r)
struct st_mysqlnd_param_bind MYSQLND_PARAM_BIND
struct st_mysqlnd_result_bind MYSQLND_RESULT_BIND
struct st_mysqlnd_error_info MYSQLND_ERROR_INFO
#define PHP_FUNCTION
Definition php.h:364
HashTable types
Definition php_ffi.h:36
unsigned const char * end
Definition php_ffi.h:51
PHP_JSON_API size_t int options
Definition php_json.h:102
zend_long num_links
Definition php_ldap.h:40
#define MYSQLI_RETVAL_RESOURCE(__ptr, __ce)
#define MYSQLI_CLEAR_RESOURCE(__id)
zend_long num_active_persistent
zend_long report_mode
#define MYSQLI_FETCH_RESOURCE_CONN(__ptr, __id, __check)
#define Z_MYSQLI_P(zv)
#define MYSQLI_FETCH_RESOURCE(__ptr, __type, __id, __name, __check)
zend_long num_inactive_persistent
#define MyG(v)
#define MYSQLI_SET_STATUS(__id, __value)
#define MYSQLI_FETCH_RESOURCE_STMT(__ptr, __id, __check)
bool rollback_on_cached_plink
@ MYSQLI_STATUS_UNKNOWN
@ MYSQLI_STATUS_VALID
@ MYSQLI_STATUS_INITIALIZED
zend_constant * data
#define FAIL(...)
enum mysqli_status status
zend_string * hash_key
MYSQL_STMT * stmt
zend_ptr_stack free_links
ZEND_API ZEND_COLD void zend_argument_count_error(const char *format,...)
Definition zend.c:1836
ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const char *format,...)
Definition zend.c:1772
ZEND_API ZEND_COLD void zend_error(int type, const char *format,...)
Definition zend.c:1666
#define INTERNAL_FUNCTION_PARAMETERS
Definition zend.h:49
#define INTERNAL_FUNCTION_PARAM_PASSTHRU
Definition zend.h:50
ZEND_API zend_result zend_parse_parameters(uint32_t num_args, const char *type_spec,...)
Definition zend_API.c:1300
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
Definition zend_API.c:443
ZEND_API zend_result zend_parse_method_parameters(uint32_t num_args, zval *this_ptr, const char *type_spec,...)
Definition zend_API.c:1314
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
Definition zend_API.c:433
ZEND_API void object_init(zval *arg)
Definition zend_API.c:1922
ZEND_API void add_index_long(zval *arg, zend_ulong index, zend_long n)
Definition zend_API.c:2033
#define ZEND_NUM_ARGS()
Definition zend_API.h:530
#define RETURN_STRING(s)
Definition zend_API.h:1043
#define RETURN_FALSE
Definition zend_API.h:1058
#define hasThis()
Definition zend_API.h:525
#define RETURN_NULL()
Definition zend_API.h:1036
#define zend_parse_parameters_none()
Definition zend_API.h:353
#define RETURN_LONG(l)
Definition zend_API.h:1037
#define RETURN_BOOL(b)
Definition zend_API.h:1035
#define RETURN_NEW_STR(s)
Definition zend_API.h:1041
#define RETURN_THROWS()
Definition zend_API.h:1060
#define RETVAL_TRUE
Definition zend_API.h:1033
#define RETURN_STR(s)
Definition zend_API.h:1039
#define RETVAL_BOOL(b)
Definition zend_API.h:1009
#define getThis()
Definition zend_API.h:526
#define RETVAL_FALSE
Definition zend_API.h:1032
#define RETURN_TRUE
Definition zend_API.h:1059
#define array_init(arg)
Definition zend_API.h:537
#define ecalloc(nmemb, size)
Definition zend_alloc.h:158
#define efree(ptr)
Definition zend_alloc.h:155
#define estrdup(s)
Definition zend_alloc.h:164
struct _zval_struct zval
zval * args
#define E_DEPRECATED
Definition zend_errors.h:37
#define EG(v)
#define ZEND_HASH_FOREACH_END()
Definition zend_hash.h:1086
#define ZEND_HASH_FOREACH_VAL(ht, _val)
Definition zend_hash.h:1102
ZEND_API void zend_llist_clean(zend_llist *l)
Definition zend_llist.c:121
int32_t zend_long
Definition zend_long.h:42
struct _zend_string zend_string
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op)
#define ZEND_ASSERT(c)
#define UNEXPECTED(condition)
#define ZSTR_VAL(zstr)
Definition zend_string.h:68
#define ZSTR_LEN(zstr)
Definition zend_string.h:69
#define Z_TYPE_P(zval_p)
Definition zend_types.h:660
#define Z_STRVAL_P(zval_p)
Definition zend_types.h:975
#define IS_STRING
Definition zend_types.h:606
struct _zend_resource zend_resource
Definition zend_types.h:99
struct _zend_array HashTable
Definition zend_types.h:386
#define IS_NULL
Definition zend_types.h:601
@ FAILURE
Definition zend_types.h:61
#define IS_LONG
Definition zend_types.h:604
#define Z_LVAL_P(zval_p)
Definition zend_types.h:966
#define ZVAL_COPY_VALUE(z, v)
zval * return_value
uint32_t arg_num
zend_string * name
bool result
zval * ret
value