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()
764 MY_STMT *stmt; in PHP_FUNCTION() local
774 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID); in PHP_FUNCTION()
777 if (stmt->param.var_cnt) { in PHP_FUNCTION()
779 for (i = 0; i < stmt->param.var_cnt; i++) { in PHP_FUNCTION()
780 for (j = i + 1; j < stmt->param.var_cnt; j++) { in PHP_FUNCTION()
782 if (stmt->param.vars[j] == stmt->param.vars[i] && stmt->param.vars[i]) { in PHP_FUNCTION()
783 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
789 for (i = 0; i < stmt->param.var_cnt; i++) { in PHP_FUNCTION()
790 if (stmt->param.vars[i]) { in PHP_FUNCTION()
791 if ( !(stmt->param.is_null[i] = (stmt->param.vars[i]->type == IS_NULL)) ) { in PHP_FUNCTION()
792 zval *the_var = copies && copies[i]? copies[i]:stmt->param.vars[i]; in PHP_FUNCTION()
793 switch (stmt->stmt->params[i].buffer_type) { in PHP_FUNCTION()
795 if (the_var == stmt->param.vars[i] && Z_TYPE_P(stmt->param.vars[i]) != IS_STRING) { in PHP_FUNCTION()
796 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
800 stmt->stmt->params[i].buffer = Z_STRVAL_P(the_var); in PHP_FUNCTION()
801 stmt->stmt->params[i].buffer_length = Z_STRLEN_P(the_var); in PHP_FUNCTION()
804 if (the_var == stmt->param.vars[i] && Z_TYPE_P(stmt->param.vars[i]) != IS_DOUBLE) { in PHP_FUNCTION()
805 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
809 stmt->stmt->params[i].buffer = &Z_DVAL_P(the_var); in PHP_FUNCTION()
813 if (the_var == stmt->param.vars[i] && Z_TYPE_P(stmt->param.vars[i]) != IS_LONG) { in PHP_FUNCTION()
814 php_mysqli_stmt_copy_it(&copies, stmt->param.vars[i], stmt->param.var_cnt, i); in PHP_FUNCTION()
818 stmt->stmt->params[i].buffer = &Z_LVAL_P(the_var); in PHP_FUNCTION()
828 if (mysql_stmt_execute(stmt->stmt)) { in PHP_FUNCTION()
829 MYSQLI_REPORT_STMT_ERROR(stmt->stmt); in PHP_FUNCTION()
837 for (i = 0; i < stmt->param.var_cnt; i++) { in PHP_FUNCTION()
847 php_mysqli_report_index(stmt->query, mysqli_stmt_server_status(stmt->stmt) TSRMLS_CC); in PHP_FUNCTION()
857 MY_STMT *stmt; local
868 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
871 for (i = 0; i < stmt->result.var_cnt; i++) {
872 if (stmt->result.buf[i].type == IS_STRING) {
873 memset(stmt->result.buf[i].val, 0, stmt->result.buf[i].buflen);
876 ret = mysql_stmt_fetch(stmt->stmt);
882 for (i = 0; i < stmt->result.var_cnt; i++) {
889 if (Z_TYPE_P(stmt->result.vars[i]) == IS_STRING) {
890 STR_FREE(stmt->result.vars[i]->value.str.val);
892 if (!stmt->result.is_null[i]) {
893 switch (stmt->result.buf[i].type) {
895 if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG)
896 && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG))
899 uval= *(unsigned int *) stmt->result.buf[i].val;
912 ZVAL_STRINGL(stmt->result.vars[i], tmp, 10, 0);
917 if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) {
918 ZVAL_LONG(stmt->result.vars[i], *(unsigned int *)stmt->result.buf[i].val);
920 ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val);
924 ZVAL_DOUBLE(stmt->result.vars[i], *(double *)stmt->result.buf[i].val);
927 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_LONGLONG
929 || stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT
932 my_bool uns= (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? 1:0;
934 if (stmt->stmt->bind[i].buffer_type == MYSQL_TYPE_BIT) {
935 switch (stmt->result.buf[i].output_len) {
936 case 8:llval = (my_ulonglong) bit_uint8korr(stmt->result.buf[i].val);break;
937 case 7:llval = (my_ulonglong) bit_uint7korr(stmt->result.buf[i].val);break;
938 case 6:llval = (my_ulonglong) bit_uint6korr(stmt->result.buf[i].val);break;
939 case 5:llval = (my_ulonglong) bit_uint5korr(stmt->result.buf[i].val);break;
940 case 4:llval = (my_ulonglong) bit_uint4korr(stmt->result.buf[i].val);break;
941 case 3:llval = (my_ulonglong) bit_uint3korr(stmt->result.buf[i].val);break;
942 case 2:llval = (my_ulonglong) bit_uint2korr(stmt->result.buf[i].val);break;
943 case 1:llval = (my_ulonglong) uint1korr(stmt->result.buf[i].val);break;
948 llval= *(my_ulonglong *) stmt->result.buf[i].val;
963 …snprintf(tmp, sizeof(tmp), (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)? MYSQLI_LLU_SPEC : MYSQLI…
964 ZVAL_STRING(stmt->result.vars[i], tmp, 1);
966 ZVAL_LONG(stmt->result.vars[i], llval);
970 if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) != 0) {
972 ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
973 stmt->stmt->bind[i].buffer_length, 1);
978 ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
979 stmt->result.buf[i].output_len, 1);
987 ZVAL_NULL(stmt->result.vars[i]);
991 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
1018 MY_STMT *stmt; local
1025 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1027 if (FAIL == mysqlnd_stmt_fetch(stmt->stmt, &fetched_anything)) {
1559 MY_STMT *stmt; local
1565 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1567 RETURN_BOOL(mysqlnd_stmt_more_results(stmt->stmt));
1575 MY_STMT *stmt; local
1581 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1583 if (!mysqlnd_stmt_more_results(stmt->stmt)) {
1589 RETURN_BOOL(!mysql_stmt_next_result(stmt->stmt));
1781 MY_STMT *stmt; local
1799 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
1801 if ((stmt->stmt = mysql_stmt_init(mysql->mysql))) {
1802 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
1809 last_errno = stmt->stmt->last_errno;
1810 memcpy(last_error, stmt->stmt->last_error, MYSQL_ERRMSG_SIZE);
1815 mysqli_stmt_close(stmt->stmt, FALSE);
1816 stmt->stmt = NULL;
1831 if (stmt->stmt && query_len && (MyG(report_mode) & MYSQLI_REPORT_INDEX)) {
1832 stmt->query = (char *)emalloc(query_len + 1);
1833 memcpy(stmt->query, query, query_len);
1834 stmt->query[query_len] = '\0';
1838 if (!stmt->stmt) {
1840 efree(stmt);
1844 stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
1845 zend_objects_store_add_ref_by_handle(stmt->link_handle TSRMLS_CC);
1849 mysqli_resource->ptr = (void *)stmt;
1942 MY_STMT *stmt; local
1951 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1957 if (mysql_stmt_send_long_data(stmt->stmt, param_nr, data, data_len)) {
1969 MY_STMT *stmt; local
1976 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1978 rc = mysql_stmt_affected_rows(stmt->stmt);
1990 MY_STMT *stmt; local
1996 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
1998 mysqli_stmt_close(stmt->stmt, FALSE);
1999 stmt->stmt = NULL;
2000 php_clear_stmt_bind(stmt TSRMLS_CC);
2010 MY_STMT *stmt; local
2022 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2024 mysql_stmt_data_seek(stmt->stmt, offset);
2032 MY_STMT *stmt; local
2038 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2040 RETURN_LONG(mysql_stmt_field_count(stmt->stmt));
2048 MY_STMT *stmt; local
2055 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2057 mysql_stmt_free_result(stmt->stmt);
2065 MY_STMT *stmt; local
2072 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2073 rc = mysql_stmt_insert_id(stmt->stmt);
2082 MY_STMT *stmt; local
2088 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2090 RETURN_LONG(mysql_stmt_param_count(stmt->stmt));
2098 MY_STMT *stmt; local
2105 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2107 if (mysql_stmt_reset(stmt->stmt)) {
2118 MY_STMT *stmt; local
2126 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2128 rc = mysql_stmt_num_rows(stmt->stmt);
2252 MY_STMT *stmt; local
2265 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2285 if (mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2287 if (FAIL == mysql_stmt_attr_set(stmt->stmt, attr, mode_p)) {
2299 MY_STMT *stmt; local
2308 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2310 if ((rc = mysql_stmt_attr_get(stmt->stmt, attr, &value))) {
2326 MY_STMT *stmt; local
2332 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2334 RETURN_LONG(mysql_stmt_errno(stmt->stmt));
2342 MY_STMT *stmt; local
2348 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2350 RETURN_STRING((char *)mysql_stmt_error(stmt->stmt),1);
2360 MY_STMT *stmt; local
2369 stmt = (MY_STMT *)ecalloc(1,sizeof(MY_STMT));
2371 if (!(stmt->stmt = mysql_stmt_init(mysql->mysql))) {
2372 efree(stmt);
2376 stmt->link_handle = Z_OBJ_HANDLE(*mysql_link);
2377 zend_objects_store_add_ref_by_handle(stmt->link_handle TSRMLS_CC);
2382 mysqli_resource->ptr = (void *)stmt;
2392 MY_STMT *stmt; local
2400 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_INITIALIZED);
2402 if (mysql_stmt_prepare(stmt->stmt, query, query_len)) {
2403 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2416 MY_STMT *stmt; local
2424 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2426 if (!(result = mysql_stmt_result_metadata(stmt->stmt))){
2427 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2442 MY_STMT *stmt; local
2448 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2461 for (i = mysql_stmt_field_count(stmt->stmt) - 1; i >=0; --i) {
2462 if (stmt->stmt->fields && (stmt->stmt->fields[i].type == MYSQL_TYPE_BLOB ||
2463 stmt->stmt->fields[i].type == MYSQL_TYPE_MEDIUM_BLOB ||
2464 stmt->stmt->fields[i].type == MYSQL_TYPE_LONG_BLOB ||
2465 stmt->stmt->fields[i].type == MYSQL_TYPE_GEOMETRY))
2472 mysql_stmt_attr_set(stmt->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &tmp);
2479 if (mysql_stmt_store_result(stmt->stmt)){
2480 MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
2491 MY_STMT *stmt; local
2497 MYSQLI_FETCH_RESOURCE_STMT(stmt, &mysql_stmt, MYSQLI_STATUS_VALID);
2499 RETURN_STRING((char *)mysql_stmt_sqlstate(stmt->stmt),1);