Lines Matching refs:stmt
185 int mysqli_stmt_bind_param_do_bind(MY_STMT *stmt, unsigned int argc, unsigned int num_vars, in mysqli_stmt_bind_param_do_bind() argument
193 if (stmt->param.var_cnt) { in mysqli_stmt_bind_param_do_bind()
194 php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE); in mysqli_stmt_bind_param_do_bind()
197 stmt->param.is_null = ecalloc(num_vars, sizeof(char)); in mysqli_stmt_bind_param_do_bind()
213 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
223 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
234 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
244 rc = mysql_stmt_bind_param(stmt->stmt, bind); in mysqli_stmt_bind_param_do_bind()
248 efree(stmt->param.is_null); in mysqli_stmt_bind_param_do_bind()
250 stmt->param.var_cnt = num_vars; in mysqli_stmt_bind_param_do_bind()
251 stmt->param.vars = safe_emalloc(num_vars, sizeof(zval), 0); in mysqli_stmt_bind_param_do_bind()
254 ZVAL_COPY(&stmt->param.vars[i], &args[i+start]); in mysqli_stmt_bind_param_do_bind()
256 ZVAL_UNDEF(&stmt->param.vars[i]); in mysqli_stmt_bind_param_do_bind()
266 int mysqli_stmt_bind_param_do_bind(MY_STMT *stmt, unsigned int argc, unsigned int num_vars, in mysqli_stmt_bind_param_do_bind() argument
277 params = mysqlnd_stmt_alloc_param_bind(stmt->stmt); in mysqli_stmt_bind_param_do_bind()
304 mysqlnd_stmt_free_param_bind(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
310 ret = mysqlnd_stmt_bind_param(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
326 MY_STMT *stmt; in PHP_FUNCTION() local
343 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
363 if (types_len != mysql_stmt_param_count(stmt->stmt)) { in PHP_FUNCTION()
374 rc = mysqli_stmt_bind_param_do_bind(stmt, argc, num_vars, args, start, types); in PHP_FUNCTION()
375 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in PHP_FUNCTION()
390 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc) in mysqli_stmt_bind_result_do_bind() argument
399 if (stmt->result.var_cnt) { in mysqli_stmt_bind_result_do_bind()
400 php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT); in mysqli_stmt_bind_result_do_bind()
407 stmt->result.buf = (VAR_BUFFER *) p; in mysqli_stmt_bind_result_do_bind()
408 stmt->result.is_null = p + var_cnt * sizeof(VAR_BUFFER); in mysqli_stmt_bind_result_do_bind()
414 col_type = (stmt->stmt->fields) ? stmt->stmt->fields[ofs].type : MYSQL_TYPE_STRING; in mysqli_stmt_bind_result_do_bind()
418 stmt->result.buf[ofs].type = IS_DOUBLE; in mysqli_stmt_bind_result_do_bind()
419 stmt->result.buf[ofs].buflen = sizeof(float); in mysqli_stmt_bind_result_do_bind()
421 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(float)); in mysqli_stmt_bind_result_do_bind()
423 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
424 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
428 stmt->result.buf[ofs].type = IS_DOUBLE; in mysqli_stmt_bind_result_do_bind()
429 stmt->result.buf[ofs].buflen = sizeof(double); in mysqli_stmt_bind_result_do_bind()
432 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(double)); in mysqli_stmt_bind_result_do_bind()
434 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
435 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
439 stmt->result.buf[ofs].type = IS_NULL; in mysqli_stmt_bind_result_do_bind()
448 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
456 stmt->result.buf[ofs].type = IS_LONG; in mysqli_stmt_bind_result_do_bind()
458 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(int)); in mysqli_stmt_bind_result_do_bind()
460 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
461 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
462 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
469 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
470 stmt->result.buf[ofs].buflen = sizeof(my_ulonglong); in mysqli_stmt_bind_result_do_bind()
471 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
473 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
474 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
475 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
476 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
477 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
503 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
509 if (stmt->stmt->fields[ofs].max_length == 0 && in mysqli_stmt_bind_result_do_bind()
510 !mysql_stmt_attr_get(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp) && !tmp) in mysqli_stmt_bind_result_do_bind()
518 stmt->result.buf[ofs].buflen = in mysqli_stmt_bind_result_do_bind()
519 …(stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256:… in mysqli_stmt_bind_result_do_bind()
526 if (!(stmt->result.buf[ofs].buflen = stmt->stmt->fields[ofs].max_length)) in mysqli_stmt_bind_result_do_bind()
527 ++stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
529 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
531 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
532 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
533 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
534 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
543 rc = mysql_stmt_bind_result(stmt->stmt, bind); in mysqli_stmt_bind_result_do_bind()
544 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
549 if (stmt->result.buf[i].val) { in mysqli_stmt_bind_result_do_bind()
550 efree(stmt->result.buf[i].val); in mysqli_stmt_bind_result_do_bind()
554 efree(stmt->result.buf); in mysqli_stmt_bind_result_do_bind()
556 stmt->result.var_cnt = var_cnt; in mysqli_stmt_bind_result_do_bind()
557 stmt->result.vars = safe_emalloc((var_cnt), sizeof(zval), 0); in mysqli_stmt_bind_result_do_bind()
559 ZVAL_COPY(&stmt->result.vars[i], &args[i]); in mysqli_stmt_bind_result_do_bind()
568 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc) in mysqli_stmt_bind_result_do_bind() argument
571 MYSQLND_RESULT_BIND *params = mysqlnd_stmt_alloc_result_bind(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
576 return mysqlnd_stmt_bind_result(stmt->stmt, params); in mysqli_stmt_bind_result_do_bind()
590 MY_STMT *stmt; in PHP_FUNCTION() local
597 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
599 if ((uint32_t)argc != mysql_stmt_field_count(stmt->stmt)) { in PHP_FUNCTION()
604 rc = mysqli_stmt_bind_result_do_bind(stmt, args, argc); in PHP_FUNCTION()
863 MY_STMT *stmt; local
872 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
875 if (stmt->param.var_cnt) {
877 for (i = 0; i < stmt->param.var_cnt; i++) {
878 if (!Z_ISREF(stmt->param.vars[i])) {
881 for (j = i + 1; j < stmt->param.var_cnt; j++) {
883 if (Z_TYPE(stmt->param.vars[j]) == Z_TYPE(stmt->param.vars[i]) &&
884 Z_REFVAL(stmt->param.vars[j]) == Z_REFVAL(stmt->param.vars[i])) {
885 SEPARATE_ZVAL(&stmt->param.vars[j]);
891 for (i = 0; i < stmt->param.var_cnt; i++) {
892 if (!Z_ISUNDEF(stmt->param.vars[i])) {
894 if (Z_ISREF(stmt->param.vars[i])) {
895 param = Z_REFVAL(stmt->param.vars[i]);
897 param = &stmt->param.vars[i];
899 if (!(stmt->param.is_null[i] = (Z_ISNULL_P(param)))) {
900 switch (stmt->stmt->params[i].buffer_type) {
903 stmt->stmt->params[i].buffer = Z_STRVAL_P(param);
904 stmt->stmt->params[i].buffer_length = Z_STRLEN_P(param);
908 stmt->stmt->params[i].buffer = &Z_DVAL_P(param);
913 stmt->stmt->params[i].buffer = &Z_LVAL_P(param);
923 if (mysql_stmt_execute(stmt->stmt)) {
924 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
931 php_mysqli_report_index(stmt->query, mysqli_stmt_server_status(stmt->stmt));
941 MY_STMT *stmt; local
952 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
955 for (i = 0; i < stmt->result.var_cnt; i++) {
956 if (stmt->result.buf[i].type == IS_STRING) {
957 memset(stmt->result.buf[i].val, 0, stmt->result.buf[i].buflen);
960 ret = mysql_stmt_fetch(stmt->stmt);
966 for (i = 0; i < stmt->result.var_cnt; i++) {
969 if (Z_ISREF(stmt->result.vars[i])) {
970 result = Z_REFVAL(stmt->result.vars[i]);
972 result = &stmt->result.vars[i];
981 if (!stmt->result.is_null[i]) {
982 switch (stmt->result.buf[i].type) {
984 if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
985 && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
988 uval= *(unsigned int *) stmt->result.buf[i].val;
1007 if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) {
1008 ZVAL_LONG(result, *(unsigned int *)stmt->result.buf[i].val);
1010 ZVAL_LONG(result, *(int *)stmt->result.buf[i].val);
1016 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_FLOAT) {
1020 dval = mysql_float_to_double(*(float *)stmt->result.buf[i].val,
1021 (stmt->stmt->fields[i].decimals >= NOT_FIXED_DEC) ? -1 :
1022 stmt->stmt->fields[i].decimals);
1024 dval = *((double *)stmt->result.buf[i].val);
1031 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
1033 || stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT
1036 my_bool uns = (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? 1:0;
1038 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
1039 switch (stmt->result.buf[i].output_len) {
1040 case 8:llval = (my_ulonglong) bit_uint8korr(stmt->result.buf[i].val);break;
1041 case 7:llval = (my_ulonglong) bit_uint7korr(stmt->result.buf[i].val);break;
1042 case 6:llval = (my_ulonglong) bit_uint6korr(stmt->result.buf[i].val);break;
1043 case 5:llval = (my_ulonglong) bit_uint5korr(stmt->result.buf[i].val);break;
1044 case 4:llval = (my_ulonglong) bit_uint4korr(stmt->result.buf[i].val);break;
1045 case 3:llval = (my_ulonglong) bit_uint3korr(stmt->result.buf[i].val);break;
1046 case 2:llval = (my_ulonglong) bit_uint2korr(stmt->result.buf[i].val);break;
1047 case 1:llval = (my_ulonglong) uint1korr(stmt->result.buf[i].val);break;
1052 llval= *(my_ulonglong *) stmt->result.buf[i].val;
1067 …snprintf(tmp, sizeof(tmp), (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI…
1074 if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) {
1076 ZVAL_STRINGL(result, stmt->result.buf[i].val, stmt->stmt->bind[i].buffer_length);
1081 ZVAL_STRINGL(result, stmt->result.buf[i].val, stmt->result.buf[i].output_len);
1093 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
1120 MY_STMT *stmt; local
1127 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1129 if (FAIL == mysqlnd_stmt_fetch(stmt->stmt, &fetched_anything)) {
1626 MY_STMT *stmt; local
1632 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1634 RETURN_BOOL(mysqlnd_stmt_more_results(stmt->stmt));
1641 MY_STMT *stmt; local
1647 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1649 if (!mysqlnd_stmt_more_results(stmt->stmt)) {
1655 RETURN_BOOL(!mysql_stmt_next_result(stmt->stmt));
1842 MY_STMT *stmt; local
1860 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1862 if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1863 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1870 last_errno = stmt->stmt->last_errno;
1871 memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
1876 mysqli_stmt_close(stmt->stmt, FALSE);
1877 stmt->stmt = NULL;
1892 if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1893 stmt->query = (char *)emalloc(query_len + 1);
1894 memcpy(stmt->query, query, query_len);
1895 stmt->query[query_len] = '\0';
1899 if (!stmt->stmt) {
1901 efree(stmt);
1905 ZVAL_COPY(&stmt->link_handle, mysql_link);
1909 mysqli_resource->ptr = (void *)stmt;
2008 MY_STMT *stmt; local
2017 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2023 if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
2034 MY_STMT *stmt; local
2041 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2043 rc = mysql_stmt_affected_rows(stmt->stmt);
2055 MY_STMT *stmt; local
2061 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2063 mysqli_stmt_close(stmt->stmt, FALSE);
2064 stmt->stmt = NULL;
2065 php_clear_stmt_bind(stmt);
2075 MY_STMT *stmt; local
2087 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2089 mysql_stmt_data_seek(stmt->stmt, offset);
2097 MY_STMT *stmt; local
2103 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2105 RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
2113 MY_STMT *stmt; local
2120 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2122 mysql_stmt_free_result(stmt->stmt);
2130 MY_STMT *stmt; local
2137 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2138 rc = mysql_stmt_insert_id(stmt->stmt);
2147 MY_STMT *stmt; local
2153 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2155 RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
2163 MY_STMT *stmt; local
2170 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2172 if (mysql_stmt_reset(stmt->stmt)) {
2183 MY_STMT *stmt; local
2191 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2193 rc = mysql_stmt_num_rows(stmt->stmt);
2322 MY_STMT *stmt; local
2335 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2355 if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2357 if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2369 MY_STMT *stmt; local
2378 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2380 if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2396 MY_STMT *stmt; local
2402 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2404 RETURN_LONG(mysql_stmt_errno(stmt->stmt));
2412 MY_STMT *stmt; local
2419 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2421 err = mysql_stmt_error(stmt->stmt);
2434 MY_STMT *stmt; local
2443 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
2445 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
2446 efree(stmt);
2450 ZVAL_COPY(&stmt->link_handle, mysql_link);
2455 mysqli_resource->ptr = (void *)stmt;
2465 MY_STMT *stmt; local
2473 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2475 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
2476 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2489 MY_STMT *stmt; local
2497 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2499 if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
2500 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2515 MY_STMT *stmt; local
2521 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2534 for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
2535 if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
2536 stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
2537 stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
2538 stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
2545 mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
2552 if (mysql_stmt_store_result(stmt->stmt)){
2553 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2564 MY_STMT *stmt; local
2571 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2573 state = mysql_stmt_sqlstate(stmt->stmt);