Lines Matching refs:stmt

183 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
191 if (stmt->param.var_cnt) { in mysqli_stmt_bind_param_do_bind()
192 php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE); in mysqli_stmt_bind_param_do_bind()
195 stmt->param.is_null = ecalloc(num_vars, sizeof(char)); in mysqli_stmt_bind_param_do_bind()
211 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
221 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
232 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
242 rc = mysql_stmt_bind_param(stmt->stmt, bind); in mysqli_stmt_bind_param_do_bind()
246 efree(stmt->param.is_null); in mysqli_stmt_bind_param_do_bind()
248 stmt->param.var_cnt = num_vars; in mysqli_stmt_bind_param_do_bind()
249 stmt->param.vars = safe_emalloc(num_vars, sizeof(zval), 0); in mysqli_stmt_bind_param_do_bind()
252 ZVAL_COPY(&stmt->param.vars[i], &args[i+start]); in mysqli_stmt_bind_param_do_bind()
254 ZVAL_UNDEF(&stmt->param.vars[i]); in mysqli_stmt_bind_param_do_bind()
264 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
275 params = mysqlnd_stmt_alloc_param_bind(stmt->stmt); in mysqli_stmt_bind_param_do_bind()
302 mysqlnd_stmt_free_param_bind(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
308 ret = mysqlnd_stmt_bind_param(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
324 MY_STMT *stmt; in PHP_FUNCTION() local
341 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
361 if (types_len != mysql_stmt_param_count(stmt->stmt)) { in PHP_FUNCTION()
372 rc = mysqli_stmt_bind_param_do_bind(stmt, argc, num_vars, args, start, types); in PHP_FUNCTION()
373 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in PHP_FUNCTION()
388 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc) in mysqli_stmt_bind_result_do_bind() argument
397 if (stmt->result.var_cnt) { in mysqli_stmt_bind_result_do_bind()
398 php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT); in mysqli_stmt_bind_result_do_bind()
405 stmt->result.buf = (VAR_BUFFER *) p; in mysqli_stmt_bind_result_do_bind()
406 stmt->result.is_null = p + var_cnt * sizeof(VAR_BUFFER); in mysqli_stmt_bind_result_do_bind()
412 col_type = (stmt->stmt->fields) ? stmt->stmt->fields[ofs].type : MYSQL_TYPE_STRING; in mysqli_stmt_bind_result_do_bind()
416 stmt->result.buf[ofs].type = IS_DOUBLE; in mysqli_stmt_bind_result_do_bind()
417 stmt->result.buf[ofs].buflen = sizeof(float); in mysqli_stmt_bind_result_do_bind()
419 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(float)); in mysqli_stmt_bind_result_do_bind()
421 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
422 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
426 stmt->result.buf[ofs].type = IS_DOUBLE; in mysqli_stmt_bind_result_do_bind()
427 stmt->result.buf[ofs].buflen = sizeof(double); in mysqli_stmt_bind_result_do_bind()
430 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(double)); in mysqli_stmt_bind_result_do_bind()
432 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
433 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
437 stmt->result.buf[ofs].type = IS_NULL; in mysqli_stmt_bind_result_do_bind()
446 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
454 stmt->result.buf[ofs].type = IS_LONG; in mysqli_stmt_bind_result_do_bind()
456 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(int)); in mysqli_stmt_bind_result_do_bind()
458 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
459 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
460 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
467 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
468 stmt->result.buf[ofs].buflen = sizeof(my_ulonglong); in mysqli_stmt_bind_result_do_bind()
469 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
471 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
472 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
473 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
474 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
475 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
501 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
507 if (stmt->stmt->fields[ofs].max_length == 0 && in mysqli_stmt_bind_result_do_bind()
508 !mysql_stmt_attr_get(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp) && !tmp) in mysqli_stmt_bind_result_do_bind()
516 stmt->result.buf[ofs].buflen = in mysqli_stmt_bind_result_do_bind()
517 …(stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256:… in mysqli_stmt_bind_result_do_bind()
524 if (!(stmt->result.buf[ofs].buflen = stmt->stmt->fields[ofs].max_length)) in mysqli_stmt_bind_result_do_bind()
525 ++stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
527 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
529 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
530 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
531 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
532 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
541 rc = mysql_stmt_bind_result(stmt->stmt, bind); in mysqli_stmt_bind_result_do_bind()
542 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
547 if (stmt->result.buf[i].val) { in mysqli_stmt_bind_result_do_bind()
548 efree(stmt->result.buf[i].val); in mysqli_stmt_bind_result_do_bind()
552 efree(stmt->result.buf); in mysqli_stmt_bind_result_do_bind()
554 stmt->result.var_cnt = var_cnt; in mysqli_stmt_bind_result_do_bind()
555 stmt->result.vars = safe_emalloc((var_cnt), sizeof(zval), 0); in mysqli_stmt_bind_result_do_bind()
557 ZVAL_COPY(&stmt->result.vars[i], &args[i]); in mysqli_stmt_bind_result_do_bind()
566 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc) in mysqli_stmt_bind_result_do_bind() argument
569 MYSQLND_RESULT_BIND *params = mysqlnd_stmt_alloc_result_bind(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
574 return mysqlnd_stmt_bind_result(stmt->stmt, params); in mysqli_stmt_bind_result_do_bind()
588 MY_STMT *stmt; in PHP_FUNCTION() local
595 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
597 if ((uint32_t)argc != mysql_stmt_field_count(stmt->stmt)) { in PHP_FUNCTION()
602 rc = mysqli_stmt_bind_result_do_bind(stmt, args, argc); in PHP_FUNCTION()
861 MY_STMT *stmt; local
870 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
873 if (stmt->param.var_cnt) {
875 for (i = 0; i < stmt->param.var_cnt; i++) {
876 if (!Z_ISREF(stmt->param.vars[i])) {
879 for (j = i + 1; j < stmt->param.var_cnt; j++) {
881 if (Z_ISREF(stmt->param.vars[j]) &&
882 Z_REFVAL(stmt->param.vars[j]) == Z_REFVAL(stmt->param.vars[i])) {
884 Z_DELREF_P(&stmt->param.vars[j]);
885 ZVAL_COPY(&stmt->param.vars[j], Z_REFVAL(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));
1839 MY_STMT *stmt; local
1857 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1859 if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1860 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1867 last_errno = stmt->stmt->last_errno;
1868 memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
1876 mysqli_stmt_close(stmt->stmt, FALSE);
1877 stmt->stmt = NULL;
1893 if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1894 stmt->query = (char *)emalloc(query_len + 1);
1895 memcpy(stmt->query, query, query_len);
1896 stmt->query[query_len] = '\0';
1900 if (!stmt->stmt) {
1902 efree(stmt);
1906 ZVAL_COPY(&stmt->link_handle, mysql_link);
1910 mysqli_resource->ptr = (void *)stmt;
2014 MY_STMT *stmt; local
2023 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2029 if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
2040 MY_STMT *stmt; local
2047 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2049 rc = mysql_stmt_affected_rows(stmt->stmt);
2061 MY_STMT *stmt; local
2067 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2069 mysqli_stmt_close(stmt->stmt, FALSE);
2070 stmt->stmt = NULL;
2071 php_clear_stmt_bind(stmt);
2081 MY_STMT *stmt; local
2093 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2095 mysql_stmt_data_seek(stmt->stmt, offset);
2103 MY_STMT *stmt; local
2109 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2111 RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
2119 MY_STMT *stmt; local
2126 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2128 mysql_stmt_free_result(stmt->stmt);
2136 MY_STMT *stmt; local
2143 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2144 rc = mysql_stmt_insert_id(stmt->stmt);
2153 MY_STMT *stmt; local
2159 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2161 RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
2169 MY_STMT *stmt; local
2176 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2178 if (mysql_stmt_reset(stmt->stmt)) {
2189 MY_STMT *stmt; local
2197 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2199 rc = mysql_stmt_num_rows(stmt->stmt);
2328 MY_STMT *stmt; local
2341 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2361 if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2363 if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2375 MY_STMT *stmt; local
2384 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2386 if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2402 MY_STMT *stmt; local
2408 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2410 RETURN_LONG(mysql_stmt_errno(stmt->stmt));
2418 MY_STMT *stmt; local
2425 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2427 err = mysql_stmt_error(stmt->stmt);
2440 MY_STMT *stmt; local
2449 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
2451 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
2452 efree(stmt);
2456 ZVAL_COPY(&stmt->link_handle, mysql_link);
2461 mysqli_resource->ptr = (void *)stmt;
2471 MY_STMT *stmt; local
2479 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2481 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
2482 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2495 MY_STMT *stmt; local
2503 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2505 if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
2506 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2521 MY_STMT *stmt; local
2527 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2540 for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
2541 if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
2542 stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
2543 stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
2544 stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
2551 mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
2558 if (mysql_stmt_store_result(stmt->stmt)){
2559 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2570 MY_STMT *stmt; local
2577 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2579 state = mysql_stmt_sqlstate(stmt->stmt);