Lines Matching refs:stmt

82 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
90 if (stmt->param.var_cnt) { in mysqli_stmt_bind_param_do_bind()
91 php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE); in mysqli_stmt_bind_param_do_bind()
94 stmt->param.is_null = ecalloc(num_vars, sizeof(char)); in mysqli_stmt_bind_param_do_bind()
105 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
115 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
126 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
136 rc = mysql_stmt_bind_param(stmt->stmt, bind); in mysqli_stmt_bind_param_do_bind()
140 efree(stmt->param.is_null); in mysqli_stmt_bind_param_do_bind()
142 stmt->param.var_cnt = num_vars; in mysqli_stmt_bind_param_do_bind()
143 stmt->param.vars = (zval **)safe_emalloc(num_vars, sizeof(zval), 0); in mysqli_stmt_bind_param_do_bind()
147 stmt->param.vars[i] = *args[i+start]; in mysqli_stmt_bind_param_do_bind()
149 stmt->param.vars[i] = NULL; in mysqli_stmt_bind_param_do_bind()
159 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
170 params = mysqlnd_stmt_alloc_param_bind(stmt->stmt); in mysqli_stmt_bind_param_do_bind()
197 mysqlnd_stmt_free_param_bind(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
203 ret = mysqlnd_stmt_bind_param(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
219 MY_STMT *stmt; in PHP_FUNCTION() local
236 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
256 if (types_len != mysql_stmt_param_count(stmt->stmt)) { in PHP_FUNCTION()
267 rc = mysqli_stmt_bind_param_do_bind(stmt, argc, num_vars, args, start, types TSRMLS_CC); in PHP_FUNCTION()
268 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in PHP_FUNCTION()
283 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc, unsigned int start … in mysqli_stmt_bind_result_do_bind() argument
292 if (stmt->result.var_cnt) { in mysqli_stmt_bind_result_do_bind()
293 php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT); in mysqli_stmt_bind_result_do_bind()
300 stmt->result.buf = (VAR_BUFFER *) p; in mysqli_stmt_bind_result_do_bind()
301 stmt->result.is_null = p + var_cnt * sizeof(VAR_BUFFER); in mysqli_stmt_bind_result_do_bind()
307 col_type = (stmt->stmt->fields) ? stmt->stmt->fields[ofs].type : MYSQL_TYPE_STRING; in mysqli_stmt_bind_result_do_bind()
313 stmt->result.buf[ofs].type = IS_DOUBLE; in mysqli_stmt_bind_result_do_bind()
314 stmt->result.buf[ofs].buflen = sizeof(double); in mysqli_stmt_bind_result_do_bind()
317 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(double)); in mysqli_stmt_bind_result_do_bind()
319 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
320 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
324 stmt->result.buf[ofs].type = IS_NULL; in mysqli_stmt_bind_result_do_bind()
333 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
342 stmt->result.buf[ofs].type = IS_LONG; in mysqli_stmt_bind_result_do_bind()
344 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(int)); in mysqli_stmt_bind_result_do_bind()
346 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
347 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
348 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
355 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
356 stmt->result.buf[ofs].buflen = sizeof(my_ulonglong); in mysqli_stmt_bind_result_do_bind()
357 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
359 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
360 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
361 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
362 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
363 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
389 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
395 if (stmt->stmt->fields[ofs].max_length == 0 && in mysqli_stmt_bind_result_do_bind()
396 !mysql_stmt_attr_get(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp) && !tmp) in mysqli_stmt_bind_result_do_bind()
404 stmt->result.buf[ofs].buflen = in mysqli_stmt_bind_result_do_bind()
405 …(stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256:… in mysqli_stmt_bind_result_do_bind()
412 if (!(stmt->result.buf[ofs].buflen = stmt->stmt->fields[ofs].max_length)) in mysqli_stmt_bind_result_do_bind()
413 ++stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
415 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
417 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
418 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
419 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
420 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
429 rc = mysql_stmt_bind_result(stmt->stmt, bind); in mysqli_stmt_bind_result_do_bind()
430 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
435 if (stmt->result.buf[i].val) { in mysqli_stmt_bind_result_do_bind()
436 efree(stmt->result.buf[i].val); in mysqli_stmt_bind_result_do_bind()
440 efree(stmt->result.buf); in mysqli_stmt_bind_result_do_bind()
442 stmt->result.var_cnt = var_cnt; in mysqli_stmt_bind_result_do_bind()
443 stmt->result.vars = (zval **)safe_emalloc((var_cnt), sizeof(zval), 0); in mysqli_stmt_bind_result_do_bind()
447 stmt->result.vars[ofs] = *args[i]; in mysqli_stmt_bind_result_do_bind()
456 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval ***args, unsigned int argc, unsigned int start … in mysqli_stmt_bind_result_do_bind() argument
459 MYSQLND_RESULT_BIND * params = mysqlnd_stmt_alloc_result_bind(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
464 return mysqlnd_stmt_bind_result(stmt->stmt, params); in mysqli_stmt_bind_result_do_bind()
479 MY_STMT *stmt; in PHP_FUNCTION() local
490 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
496 if ((argc - start) != mysql_stmt_field_count(stmt->stmt)) { in PHP_FUNCTION()
508 rc = mysqli_stmt_bind_result_do_bind(stmt, args, argc, start TSRMLS_CC); in PHP_FUNCTION()
760 MY_STMT *stmt; in PHP_FUNCTION() local
770 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
773 if (stmt->param.var_cnt) { in PHP_FUNCTION()
775 for (i = 0; i < stmt->param.var_cnt; i++) { in PHP_FUNCTION()
776 for (j = i + 1; j < stmt->param.var_cnt; j++) { in PHP_FUNCTION()
778 if (stmt->param.vars[j] == stmt->param.vars[i] && stmt->param.vars[i]) { in PHP_FUNCTION()
779 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
785 for (i = 0; i < stmt->param.var_cnt; i++) { in PHP_FUNCTION()
786 if (stmt->param.vars[i]) { in PHP_FUNCTION()
787 if ( !(stmt->param.is_null[i] = (stmt->param.vars[i]->type == IS_NULL)) ) { in PHP_FUNCTION()
788 zval *the_var = copies && copies[i]? copies[i]:stmt->param.vars[i]; in PHP_FUNCTION()
789 switch (stmt->stmt->params[i].buffer_type) { in PHP_FUNCTION()
791 if (the_var == stmt->param.vars[i] && Z_TYPE_P(stmt->param.vars[i]) != IS_STRING) { in PHP_FUNCTION()
792 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
796 stmt->stmt->params[i].buffer = Z_STRVAL_P(the_var); in PHP_FUNCTION()
797 stmt->stmt->params[i].buffer_length = Z_STRLEN_P(the_var); in PHP_FUNCTION()
800 if (the_var == stmt->param.vars[i] && Z_TYPE_P(stmt->param.vars[i]) != IS_DOUBLE) { in PHP_FUNCTION()
801 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
805 stmt->stmt->params[i].buffer = &Z_DVAL_P(the_var); in PHP_FUNCTION()
809 if (the_var == stmt->param.vars[i] && Z_TYPE_P(stmt->param.vars[i]) != IS_LONG) { in PHP_FUNCTION()
810 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
814 stmt->stmt->params[i].buffer = &Z_LVAL_P(the_var); in PHP_FUNCTION()
824 if (mysql_stmt_execute(stmt->stmt)) { in PHP_FUNCTION()
825 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in PHP_FUNCTION()
833 for (i = 0; i < stmt->param.var_cnt; i++) { in PHP_FUNCTION()
843 php_mysqli_report_index(stmt->query, mysqli_stmt_server_status(stmt->stmt) TSRMLS_CC); in PHP_FUNCTION()
853 MY_STMT *stmt; local
864 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
867 for (i = 0; i < stmt->result.var_cnt; i++) {
868 if (stmt->result.buf[i].type == IS_STRING) {
869 memset(stmt->result.buf[i].val, 0, stmt->result.buf[i].buflen);
872 ret = mysql_stmt_fetch(stmt->stmt);
878 for (i = 0; i < stmt->result.var_cnt; i++) {
885 if (Z_TYPE_P(stmt->result.vars[i]) == IS_STRING) {
886 efree(stmt->result.vars[i]->value.str.val);
888 if (!stmt->result.is_null[i]) {
889 switch (stmt->result.buf[i].type) {
891 if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
892 && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
895 uval= *(unsigned int *) stmt->result.buf[i].val;
908 ZVAL_STRINGL(stmt->result.vars[i], tmp, 10, 0);
913 if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) {
914 ZVAL_LONG(stmt->result.vars[i], *(unsigned int *)stmt->result.buf[i].val);
916 ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val);
920 ZVAL_DOUBLE(stmt->result.vars[i], *(double *)stmt->result.buf[i].val);
923 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
925 || stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT
928 my_bool uns= (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? 1:0;
930 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
931 switch (stmt->result.buf[i].output_len) {
932 case 8:llval = (my_ulonglong) bit_uint8korr(stmt->result.buf[i].val);break;
933 case 7:llval = (my_ulonglong) bit_uint7korr(stmt->result.buf[i].val);break;
934 case 6:llval = (my_ulonglong) bit_uint6korr(stmt->result.buf[i].val);break;
935 case 5:llval = (my_ulonglong) bit_uint5korr(stmt->result.buf[i].val);break;
936 case 4:llval = (my_ulonglong) bit_uint4korr(stmt->result.buf[i].val);break;
937 case 3:llval = (my_ulonglong) bit_uint3korr(stmt->result.buf[i].val);break;
938 case 2:llval = (my_ulonglong) bit_uint2korr(stmt->result.buf[i].val);break;
939 case 1:llval = (my_ulonglong) uint1korr(stmt->result.buf[i].val);break;
944 llval= *(my_ulonglong *) stmt->result.buf[i].val;
959 …snprintf(tmp, sizeof(tmp), (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI…
960 ZVAL_STRING(stmt->result.vars[i], tmp, 1);
962 ZVAL_LONG(stmt->result.vars[i], llval);
966 if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) {
968 ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
969 stmt->stmt->bind[i].buffer_length, 1);
974 ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
975 stmt->result.buf[i].output_len, 1);
983 ZVAL_NULL(stmt->result.vars[i]);
987 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
1014 MY_STMT *stmt; local
1021 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1023 if (FAIL == mysqlnd_stmt_fetch(stmt->stmt, &fetched_anything)) {
1552 MY_STMT *stmt; local
1558 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1560 RETURN_BOOL(mysqlnd_stmt_more_results(stmt->stmt));
1568 MY_STMT *stmt; local
1574 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1576 if (!mysqlnd_stmt_more_results(stmt->stmt)) {
1582 RETURN_BOOL(!mysql_stmt_next_result(stmt->stmt));
1771 MY_STMT *stmt; local
1789 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1791 if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1792 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1799 last_errno = stmt->stmt->last_errno;
1800 memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
1805 mysqli_stmt_close(stmt->stmt, FALSE);
1806 stmt->stmt = NULL;
1821 if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1822 stmt->query = (char *)emalloc(query_len + 1);
1823 memcpy(stmt->query, query, query_len);
1824 stmt->query[query_len] = '\0';
1828 if (!stmt->stmt) {
1830 efree(stmt);
1835 mysqli_resource->ptr = (void *)stmt;
1928 MY_STMT *stmt; local
1937 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1943 if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
1955 MY_STMT *stmt; local
1962 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1964 rc = mysql_stmt_affected_rows(stmt->stmt);
1976 MY_STMT *stmt; local
1982 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1984 mysqli_stmt_close(stmt->stmt, FALSE);
1985 stmt->stmt = NULL;
1986 php_clear_stmt_bind(stmt TSRMLS_CC);
1996 MY_STMT *stmt; local
2008 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2010 mysql_stmt_data_seek(stmt->stmt, offset);
2018 MY_STMT *stmt; local
2024 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2026 RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
2034 MY_STMT *stmt; local
2041 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2043 mysql_stmt_free_result(stmt->stmt);
2051 MY_STMT *stmt; local
2058 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2059 rc = mysql_stmt_insert_id(stmt->stmt);
2068 MY_STMT *stmt; local
2074 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2076 RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
2084 MY_STMT *stmt; local
2091 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2093 if (mysql_stmt_reset(stmt->stmt)) {
2104 MY_STMT *stmt; local
2112 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2114 rc = mysql_stmt_num_rows(stmt->stmt);
2238 MY_STMT *stmt; local
2251 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2271 if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2273 if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2285 MY_STMT *stmt; local
2294 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2296 if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2312 MY_STMT *stmt; local
2318 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2320 RETURN_LONG(mysql_stmt_errno(stmt->stmt));
2328 MY_STMT *stmt; local
2334 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2336 RETURN_STRING((char *)mysql_stmt_error(stmt->stmt),1);
2346 MY_STMT *stmt; local
2355 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
2357 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
2358 efree(stmt);
2364 mysqli_resource->ptr = (void *)stmt;
2374 MY_STMT *stmt; local
2382 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2384 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
2385 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2398 MY_STMT *stmt; local
2406 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2408 if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
2409 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2424 MY_STMT *stmt; local
2430 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2443 for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
2444 if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
2445 stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
2446 stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
2447 stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
2454 mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
2461 if (mysql_stmt_store_result(stmt->stmt)){
2462 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2473 MY_STMT *stmt; local
2479 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2481 RETURN_STRING((char *)mysql_stmt_sqlstate(stmt->stmt),1);