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 (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)) {
1622 MY_STMT *stmt; local
1628 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1630 RETURN_BOOL(mysqlnd_stmt_more_results(stmt->stmt));
1637 MY_STMT *stmt; local
1643 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1645 if (!mysqlnd_stmt_more_results(stmt->stmt)) {
1651 RETURN_BOOL(!mysql_stmt_next_result(stmt->stmt));
1846 MY_STMT *stmt; local
1864 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1866 if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1867 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1874 last_errno = stmt->stmt->last_errno;
1875 memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
1880 mysqli_stmt_close(stmt->stmt, FALSE);
1881 stmt->stmt = NULL;
1896 if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1897 stmt->query = (char *)emalloc(query_len + 1);
1898 memcpy(stmt->query, query, query_len);
1899 stmt->query[query_len] = '\0';
1903 if (!stmt->stmt) {
1905 efree(stmt);
1909 ZVAL_COPY(&stmt->link_handle, mysql_link);
1913 mysqli_resource->ptr = (void *)stmt;
2012 MY_STMT *stmt; local
2021 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2027 if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
2038 MY_STMT *stmt; local
2045 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2047 rc = mysql_stmt_affected_rows(stmt->stmt);
2059 MY_STMT *stmt; local
2065 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2067 mysqli_stmt_close(stmt->stmt, FALSE);
2068 stmt->stmt = NULL;
2069 php_clear_stmt_bind(stmt);
2079 MY_STMT *stmt; local
2091 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2093 mysql_stmt_data_seek(stmt->stmt, offset);
2101 MY_STMT *stmt; local
2107 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2109 RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
2117 MY_STMT *stmt; local
2124 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2126 mysql_stmt_free_result(stmt->stmt);
2134 MY_STMT *stmt; local
2141 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2142 rc = mysql_stmt_insert_id(stmt->stmt);
2151 MY_STMT *stmt; local
2157 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2159 RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
2167 MY_STMT *stmt; local
2174 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2176 if (mysql_stmt_reset(stmt->stmt)) {
2187 MY_STMT *stmt; local
2195 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2197 rc = mysql_stmt_num_rows(stmt->stmt);
2326 MY_STMT *stmt; local
2339 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2359 if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2361 if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2373 MY_STMT *stmt; local
2382 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2384 if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2400 MY_STMT *stmt; local
2406 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2408 RETURN_LONG(mysql_stmt_errno(stmt->stmt));
2416 MY_STMT *stmt; local
2423 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2425 err = mysql_stmt_error(stmt->stmt);
2438 MY_STMT *stmt; local
2447 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
2449 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
2450 efree(stmt);
2454 ZVAL_COPY(&stmt->link_handle, mysql_link);
2459 mysqli_resource->ptr = (void *)stmt;
2469 MY_STMT *stmt; local
2477 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2479 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
2480 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2493 MY_STMT *stmt; local
2501 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2503 if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
2504 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2519 MY_STMT *stmt; local
2525 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2538 for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
2539 if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
2540 stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
2541 stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
2542 stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
2549 mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
2556 if (mysql_stmt_store_result(stmt->stmt)){
2557 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2568 MY_STMT *stmt; local
2575 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2577 state = mysql_stmt_sqlstate(stmt->stmt);