Lines Matching refs:stmt
182 int mysqli_stmt_bind_param_do_bind(MY_STMT *stmt, unsigned int num_vars, zval *args, const char * c… in mysqli_stmt_bind_param_do_bind() argument
189 if (stmt->param.var_cnt) { in mysqli_stmt_bind_param_do_bind()
190 php_free_stmt_bind_buffer(stmt->param, FETCH_SIMPLE); in mysqli_stmt_bind_param_do_bind()
193 stmt->param.is_null = ecalloc(num_vars, sizeof(char)); in mysqli_stmt_bind_param_do_bind()
209 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
219 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
230 bind[ofs].is_null = &stmt->param.is_null[ofs]; in mysqli_stmt_bind_param_do_bind()
240 rc = mysql_stmt_bind_param(stmt->stmt, bind); in mysqli_stmt_bind_param_do_bind()
244 efree(stmt->param.is_null); in mysqli_stmt_bind_param_do_bind()
246 stmt->param.var_cnt = num_vars; in mysqli_stmt_bind_param_do_bind()
247 stmt->param.vars = safe_emalloc(num_vars, sizeof(zval), 0); in mysqli_stmt_bind_param_do_bind()
250 ZVAL_COPY(&stmt->param.vars[i], &args[i]); in mysqli_stmt_bind_param_do_bind()
252 ZVAL_UNDEF(&stmt->param.vars[i]); in mysqli_stmt_bind_param_do_bind()
262 int mysqli_stmt_bind_param_do_bind(MY_STMT *stmt, unsigned int num_vars, zval *args, const char * c… in mysqli_stmt_bind_param_do_bind() argument
272 params = mysqlnd_stmt_alloc_param_bind(stmt->stmt); in mysqli_stmt_bind_param_do_bind()
298 mysqlnd_stmt_free_param_bind(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
304 ret = mysqlnd_stmt_bind_param(stmt->stmt, params); in mysqli_stmt_bind_param_do_bind()
317 MY_STMT *stmt; in PHP_FUNCTION() local
326 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
339 if (types_len != mysql_stmt_param_count(stmt->stmt)) { in PHP_FUNCTION()
344 RETVAL_BOOL(!mysqli_stmt_bind_param_do_bind(stmt, argc, args, types, getThis() ? 1 : 2)); in PHP_FUNCTION()
345 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in PHP_FUNCTION()
355 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc) in mysqli_stmt_bind_result_do_bind() argument
364 if (stmt->result.var_cnt) { in mysqli_stmt_bind_result_do_bind()
365 php_free_stmt_bind_buffer(stmt->result, FETCH_RESULT); in mysqli_stmt_bind_result_do_bind()
372 stmt->result.buf = (VAR_BUFFER *) p; in mysqli_stmt_bind_result_do_bind()
373 stmt->result.is_null = (my_bool *) (p + var_cnt * sizeof(VAR_BUFFER)); in mysqli_stmt_bind_result_do_bind()
379 col_type = (stmt->stmt->fields) ? stmt->stmt->fields[ofs].type : MYSQL_TYPE_STRING; in mysqli_stmt_bind_result_do_bind()
383 stmt->result.buf[ofs].type = IS_DOUBLE; in mysqli_stmt_bind_result_do_bind()
384 stmt->result.buf[ofs].buflen = sizeof(float); in mysqli_stmt_bind_result_do_bind()
386 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(float)); in mysqli_stmt_bind_result_do_bind()
388 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
389 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
393 stmt->result.buf[ofs].type = IS_DOUBLE; in mysqli_stmt_bind_result_do_bind()
394 stmt->result.buf[ofs].buflen = sizeof(double); in mysqli_stmt_bind_result_do_bind()
397 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(double)); in mysqli_stmt_bind_result_do_bind()
399 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
400 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
404 stmt->result.buf[ofs].type = IS_NULL; in mysqli_stmt_bind_result_do_bind()
413 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
421 stmt->result.buf[ofs].type = IS_LONG; in mysqli_stmt_bind_result_do_bind()
423 stmt->result.buf[ofs].val = (char *)emalloc(sizeof(int)); in mysqli_stmt_bind_result_do_bind()
425 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
426 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
427 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
432 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
433 stmt->result.buf[ofs].buflen = sizeof(my_ulonglong); in mysqli_stmt_bind_result_do_bind()
434 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
436 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
437 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
438 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
439 bind[ofs].is_unsigned = (stmt->stmt->fields[ofs].flags & UNSIGNED_FLAG) ? 1 : 0; in mysqli_stmt_bind_result_do_bind()
440 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
461 stmt->result.buf[ofs].type = IS_STRING; in mysqli_stmt_bind_result_do_bind()
467 if (stmt->stmt->fields[ofs].max_length == 0 && in mysqli_stmt_bind_result_do_bind()
468 !mysql_stmt_attr_get(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp) && !tmp) in mysqli_stmt_bind_result_do_bind()
476 stmt->result.buf[ofs].buflen = in mysqli_stmt_bind_result_do_bind()
477 …(stmt->stmt->fields) ? (stmt->stmt->fields[ofs].length) ? stmt->stmt->fields[ofs].length + 1: 256:… in mysqli_stmt_bind_result_do_bind()
484 if (!(stmt->result.buf[ofs].buflen = stmt->stmt->fields[ofs].max_length)) in mysqli_stmt_bind_result_do_bind()
485 ++stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
487 stmt->result.buf[ofs].val = (char *)emalloc(stmt->result.buf[ofs].buflen); in mysqli_stmt_bind_result_do_bind()
489 bind[ofs].buffer = stmt->result.buf[ofs].val; in mysqli_stmt_bind_result_do_bind()
490 bind[ofs].is_null = &stmt->result.is_null[ofs]; in mysqli_stmt_bind_result_do_bind()
491 bind[ofs].buffer_length = stmt->result.buf[ofs].buflen; in mysqli_stmt_bind_result_do_bind()
492 bind[ofs].length = &stmt->result.buf[ofs].output_len; in mysqli_stmt_bind_result_do_bind()
501 rc = mysql_stmt_bind_result(stmt->stmt, bind); in mysqli_stmt_bind_result_do_bind()
502 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
507 if (stmt->result.buf[i].val) { in mysqli_stmt_bind_result_do_bind()
508 efree(stmt->result.buf[i].val); in mysqli_stmt_bind_result_do_bind()
512 efree(stmt->result.buf); in mysqli_stmt_bind_result_do_bind()
514 stmt->result.var_cnt = var_cnt; in mysqli_stmt_bind_result_do_bind()
515 stmt->result.vars = safe_emalloc((var_cnt), sizeof(zval), 0); in mysqli_stmt_bind_result_do_bind()
517 ZVAL_COPY(&stmt->result.vars[i], &args[i]); in mysqli_stmt_bind_result_do_bind()
526 mysqli_stmt_bind_result_do_bind(MY_STMT *stmt, zval *args, unsigned int argc) in mysqli_stmt_bind_result_do_bind() argument
529 MYSQLND_RESULT_BIND *params = mysqlnd_stmt_alloc_result_bind(stmt->stmt); in mysqli_stmt_bind_result_do_bind()
534 return mysqlnd_stmt_bind_result(stmt->stmt, params); in mysqli_stmt_bind_result_do_bind()
547 MY_STMT *stmt; in PHP_FUNCTION() local
554 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
556 if ((uint32_t)argc != mysql_stmt_field_count(stmt->stmt)) { in PHP_FUNCTION()
561 rc = mysqli_stmt_bind_result_do_bind(stmt, args, argc); in PHP_FUNCTION()
812 MY_STMT *stmt; local
821 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
824 if (stmt->param.var_cnt) {
826 for (i = 0; i < stmt->param.var_cnt; i++) {
827 if (!Z_ISREF(stmt->param.vars[i])) {
830 for (j = i + 1; j < stmt->param.var_cnt; j++) {
832 if (Z_ISREF(stmt->param.vars[j]) &&
833 Z_REFVAL(stmt->param.vars[j]) == Z_REFVAL(stmt->param.vars[i])) {
835 Z_DELREF_P(&stmt->param.vars[j]);
836 ZVAL_COPY(&stmt->param.vars[j], Z_REFVAL(stmt->param.vars[j]));
842 for (i = 0; i < stmt->param.var_cnt; i++) {
843 if (!Z_ISUNDEF(stmt->param.vars[i])) {
845 if (Z_ISREF(stmt->param.vars[i])) {
846 param = Z_REFVAL(stmt->param.vars[i]);
848 param = &stmt->param.vars[i];
850 if (!(stmt->param.is_null[i] = (Z_ISNULL_P(param)))) {
851 switch (stmt->stmt->params[i].buffer_type) {
857 stmt->stmt->params[i].buffer = Z_STRVAL_P(param);
858 stmt->stmt->params[i].buffer_length = Z_STRLEN_P(param);
862 stmt->stmt->params[i].buffer = &Z_DVAL_P(param);
867 stmt->stmt->params[i].buffer = &Z_LVAL_P(param);
877 if (mysql_stmt_execute(stmt->stmt)) {
878 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
885 php_mysqli_report_index(stmt->query, mysqli_stmt_server_status(stmt->stmt));
895 MY_STMT *stmt; local
905 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
908 for (i = 0; i < stmt->result.var_cnt; i++) {
909 if (stmt->result.buf[i].type == IS_STRING) {
910 memset(stmt->result.buf[i].val, 0, stmt->result.buf[i].buflen);
913 ret = mysql_stmt_fetch(stmt->stmt);
919 for (i = 0; i < stmt->result.var_cnt; i++) {
922 if (Z_ISREF(stmt->result.vars[i])) {
923 result = &stmt->result.vars[i];
928 if (!stmt->result.is_null[i]) {
929 switch (stmt->result.buf[i].type) {
931 if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
932 && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
936 unsigned int uval = *(unsigned int *) stmt->result.buf[i].val;
954 if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) {
955 ZEND_TRY_ASSIGN_REF_LONG(result, *(unsigned int *)stmt->result.buf[i].val);
957 ZEND_TRY_ASSIGN_REF_LONG(result, *(int *)stmt->result.buf[i].val);
963 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_FLOAT) {
967 dval = mysql_float_to_double(*(float *)stmt->result.buf[i].val,
968 (stmt->stmt->fields[i].decimals >= NOT_FIXED_DEC) ? -1 :
969 stmt->stmt->fields[i].decimals);
971 dval = *((double *)stmt->result.buf[i].val);
978 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
979 || stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT
981 my_bool uns = (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? 1:0;
982 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
983 switch (stmt->result.buf[i].output_len) {
984 case 8:llval = (my_ulonglong) bit_uint8korr(stmt->result.buf[i].val);break;
985 case 7:llval = (my_ulonglong) bit_uint7korr(stmt->result.buf[i].val);break;
986 case 6:llval = (my_ulonglong) bit_uint6korr(stmt->result.buf[i].val);break;
987 case 5:llval = (my_ulonglong) bit_uint5korr(stmt->result.buf[i].val);break;
988 case 4:llval = (my_ulonglong) bit_uint4korr(stmt->result.buf[i].val);break;
989 case 3:llval = (my_ulonglong) bit_uint3korr(stmt->result.buf[i].val);break;
990 case 2:llval = (my_ulonglong) bit_uint2korr(stmt->result.buf[i].val);break;
991 case 1:llval = (my_ulonglong) uint1korr(stmt->result.buf[i].val);break;
994 llval= *(my_ulonglong *) stmt->result.buf[i].val;
1009 …snprintf(tmp, sizeof(tmp), (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI…
1015 if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) {
1017 … ZEND_TRY_ASSIGN_REF_STRINGL(result, stmt->result.buf[i].val, stmt->stmt->bind[i].buffer_length);
1019 … ZEND_TRY_ASSIGN_REF_STRINGL(result, stmt->result.buf[i].val, stmt->result.buf[i].output_len);
1031 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
1058 MY_STMT *stmt; local
1065 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1067 if (FAIL == mysqlnd_stmt_fetch(stmt->stmt, &fetched_anything)) {
1068 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
1557 MY_STMT *stmt; local
1563 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1565 RETURN_BOOL(mysqlnd_stmt_more_results(stmt->stmt));
1571 MY_STMT *stmt; local
1577 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1579 if (mysql_stmt_next_result(stmt->stmt)) {
1580 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
1764 MY_STMT *stmt; local
1782 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1784 if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1785 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1792 last_errno = stmt->stmt->last_errno;
1793 memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
1801 mysqli_stmt_close(stmt->stmt, FALSE);
1802 stmt->stmt = NULL;
1818 if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1819 stmt->query = (char *)emalloc(query_len + 1);
1820 memcpy(stmt->query, query, query_len);
1821 stmt->query[query_len] = '\0';
1825 if (!stmt->stmt) {
1827 efree(stmt);
1831 ZVAL_COPY(&stmt->link_handle, mysql_link);
1835 mysqli_resource->ptr = (void *)stmt;
1933 MY_STMT *stmt; local
1943 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1950 if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
1960 MY_STMT *stmt; local
1967 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1969 rc = mysql_stmt_affected_rows(stmt->stmt);
1980 MY_STMT *stmt; local
1986 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
1988 mysqli_stmt_close(stmt->stmt, FALSE);
1989 stmt->stmt = NULL;
1990 php_clear_stmt_bind(stmt);
1999 MY_STMT *stmt; local
2012 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2014 mysql_stmt_data_seek(stmt->stmt, offset);
2021 MY_STMT *stmt; local
2027 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2029 RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
2036 MY_STMT *stmt; local
2043 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2045 mysql_stmt_free_result(stmt->stmt);
2052 MY_STMT *stmt; local
2059 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2060 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));
2083 MY_STMT *stmt; local
2090 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2092 if (mysql_stmt_reset(stmt->stmt)) {
2102 MY_STMT *stmt; local
2110 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2112 rc = mysql_stmt_num_rows(stmt->stmt);
2231 MY_STMT *stmt; local
2243 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2286 if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2288 if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2290 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2300 MY_STMT *stmt; local
2310 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2312 if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2331 MY_STMT *stmt; local
2337 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2339 RETURN_LONG(mysql_stmt_errno(stmt->stmt));
2346 MY_STMT *stmt; local
2352 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2354 RETURN_STRING(mysql_stmt_error(stmt->stmt));
2362 MY_STMT *stmt; local
2371 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
2373 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
2374 efree(stmt);
2378 ZVAL_COPY(&stmt->link_handle, mysql_link);
2383 mysqli_resource->ptr = (void *)stmt;
2391 MY_STMT *stmt; local
2399 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2401 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
2402 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2414 MY_STMT *stmt; local
2422 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2424 if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
2425 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2439 MY_STMT *stmt; local
2445 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2458 for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
2459 if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
2460 stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
2461 stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
2462 stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
2465 mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
2472 if (mysql_stmt_store_result(stmt->stmt)){
2473 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2483 MY_STMT *stmt; local
2489 MYSQLI_FETCH_RESOURCE_STMT(stmt, mysql_stmt, MYSQLI_STATUS_VALID);
2491 RETURN_STRING(mysql_stmt_sqlstate(stmt->stmt));