Lines Matching refs:stmt
38 pdo_stmt_t *stmt = Z_PDO_STMT_P(ZEND_THIS); \
39 if (!stmt->dbh) { \
44 static inline bool rewrite_name_to_position(pdo_stmt_t *stmt, struct pdo_bound_param_data *param) /… in rewrite_name_to_position() argument
46 if (stmt->bound_param_map) { in rewrite_name_to_position()
56 if (stmt->named_rewrite_template) { in rewrite_name_to_position()
62 if ((name = zend_hash_index_find_ptr(stmt->bound_param_map, param->paramno)) != NULL) { in rewrite_name_to_position()
67 pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined"); in rewrite_name_to_position()
71 ZEND_HASH_FOREACH_PTR(stmt->bound_param_map, name) { in rewrite_name_to_position()
78 …pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "PDO refuses to handle repeating the same :named pa… in rewrite_name_to_position()
85 pdo_raise_impl_error(stmt->dbh, stmt, "HY093", "parameter was not defined"); in rewrite_name_to_position()
93 static bool dispatch_param_event(pdo_stmt_t *stmt, enum pdo_param_event event_type) /* {{{ */ in dispatch_param_event() argument
99 if (stmt->dbh->skip_param_evt & (1 << event_type)) { in dispatch_param_event()
103 if (!stmt->methods->param_hook) { in dispatch_param_event()
107 ht = stmt->bound_params; in dispatch_param_event()
112 if (!stmt->methods->param_hook(stmt, param, event_type)) { in dispatch_param_event()
119 ht = stmt->bound_columns; in dispatch_param_event()
128 int pdo_stmt_describe_columns(pdo_stmt_t *stmt) /* {{{ */ in pdo_stmt_describe_columns() argument
132 stmt->columns = ecalloc(stmt->column_count, sizeof(struct pdo_column_data)); in pdo_stmt_describe_columns()
134 for (col = 0; col < stmt->column_count; col++) { in pdo_stmt_describe_columns()
135 if (!stmt->methods->describer(stmt, col)) { in pdo_stmt_describe_columns()
140 …if (stmt->dbh->native_case != stmt->dbh->desired_case && stmt->dbh->desired_case != PDO_CASE_NATUR… in pdo_stmt_describe_columns()
141 zend_string *orig_name = stmt->columns[col].name; in pdo_stmt_describe_columns()
142 switch (stmt->dbh->desired_case) { in pdo_stmt_describe_columns()
144 stmt->columns[col].name = zend_string_tolower(orig_name); in pdo_stmt_describe_columns()
148 stmt->columns[col].name = zend_string_separate(orig_name, 0); in pdo_stmt_describe_columns()
149 char *s = ZSTR_VAL(stmt->columns[col].name); in pdo_stmt_describe_columns()
161 if (stmt->bound_columns) { in pdo_stmt_describe_columns()
164 if ((param = zend_hash_find_ptr(stmt->bound_columns, in pdo_stmt_describe_columns()
165 stmt->columns[col].name)) != NULL) { in pdo_stmt_describe_columns()
175 static void pdo_stmt_reset_columns(pdo_stmt_t *stmt) { in pdo_stmt_reset_columns() argument
176 if (stmt->columns) { in pdo_stmt_reset_columns()
178 struct pdo_column_data *cols = stmt->columns; in pdo_stmt_reset_columns()
180 for (i = 0; i < stmt->column_count; i++) { in pdo_stmt_reset_columns()
185 efree(stmt->columns); in pdo_stmt_reset_columns()
187 stmt->columns = NULL; in pdo_stmt_reset_columns()
188 stmt->column_count = 0; in pdo_stmt_reset_columns()
195 PDO_API void php_pdo_stmt_set_column_count(pdo_stmt_t *stmt, int new_count) in php_pdo_stmt_set_column_count() argument
198 if (!stmt->columns) { in php_pdo_stmt_set_column_count()
199 stmt->column_count = new_count; in php_pdo_stmt_set_column_count()
205 if (new_count == stmt->column_count) { in php_pdo_stmt_set_column_count()
210 pdo_stmt_reset_columns(stmt); in php_pdo_stmt_set_column_count()
211 stmt->column_count = new_count; in php_pdo_stmt_set_column_count()
214 static void get_lazy_object(pdo_stmt_t *stmt, zval *return_value) /* {{{ */ in get_lazy_object() argument
216 if (Z_ISUNDEF(stmt->lazy_object_ref)) { in get_lazy_object()
218 row->stmt = stmt; in get_lazy_object()
220 ZVAL_OBJ(&stmt->lazy_object_ref, &row->std); in get_lazy_object()
222 GC_ADDREF(&stmt->std); in get_lazy_object()
225 ZVAL_COPY(return_value, &stmt->lazy_object_ref); in get_lazy_object()
234 if (param->stmt->methods->param_hook) { in param_dtor()
235 param->stmt->methods->param_hook(param->stmt, param, PDO_PARAM_EVT_FREE); in param_dtor()
253 static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_stmt_t *stmt, bool … in really_register_bound_param() argument
259 hash = is_param ? stmt->bound_params : stmt->bound_columns; in really_register_bound_param()
266 stmt->bound_params = hash; in really_register_bound_param()
268 stmt->bound_columns = hash; in really_register_bound_param()
288 param->stmt = stmt; in really_register_bound_param()
295 if (!is_param && param->name && stmt->columns) { in really_register_bound_param()
299 for (i = 0; i < stmt->column_count; i++) { in really_register_bound_param()
300 if (ZSTR_LEN(stmt->columns[i].name) == ZSTR_LEN(param->name) && in really_register_bound_param()
301 … strncmp(ZSTR_VAL(stmt->columns[i].name), ZSTR_VAL(param->name), ZSTR_LEN(param->name) + 1) == 0) { in really_register_bound_param()
314 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", tmp); in really_register_bound_param()
330 if (is_param && !rewrite_name_to_position(stmt, param)) { in really_register_bound_param()
342 if (stmt->methods->param_hook) { in really_register_bound_param()
343 if (!stmt->methods->param_hook(stmt, param, PDO_PARAM_EVT_NORMALIZE)) { in really_register_bound_param()
368 if (stmt->methods->param_hook) { in really_register_bound_param()
369 if (!stmt->methods->param_hook(stmt, pparam, PDO_PARAM_EVT_ALLOC)) { in really_register_bound_param()
407 if (stmt->bound_params) { in PHP_METHOD()
408 zend_hash_destroy(stmt->bound_params); in PHP_METHOD()
409 FREE_HASHTABLE(stmt->bound_params); in PHP_METHOD()
410 stmt->bound_params = NULL; in PHP_METHOD()
429 if (!really_register_bound_param(¶m, stmt, 1)) { in PHP_METHOD()
438 if (PDO_PLACEHOLDER_NONE == stmt->supports_placeholders) { in PHP_METHOD()
445 if (stmt->active_query_string && stmt->active_query_string != stmt->query_string) { in PHP_METHOD()
446 efree(stmt->active_query_string); in PHP_METHOD()
448 stmt->active_query_string = NULL; in PHP_METHOD()
450 ret = pdo_parse_params(stmt, stmt->query_string, stmt->query_stringlen, in PHP_METHOD()
451 &stmt->active_query_string, &stmt->active_query_stringlen); in PHP_METHOD()
455 stmt->active_query_string = stmt->query_string; in PHP_METHOD()
456 stmt->active_query_stringlen = stmt->query_stringlen; in PHP_METHOD()
462 } else if (!dispatch_param_event(stmt, PDO_PARAM_EVT_EXEC_PRE)) { in PHP_METHOD()
466 if (stmt->methods->executer(stmt)) { in PHP_METHOD()
467 if (!stmt->executed) { in PHP_METHOD()
470 if (stmt->dbh->alloc_own_columns && !stmt->columns) { in PHP_METHOD()
473 ret = pdo_stmt_describe_columns(stmt); in PHP_METHOD()
476 stmt->executed = 1; in PHP_METHOD()
479 if (ret && !dispatch_param_event(stmt, PDO_PARAM_EVT_EXEC_POST)) { in PHP_METHOD()
491 static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, int *type_override) /* {{{ … in fetch_value() argument
505 if (colno >= stmt->column_count) { in fetch_value()
511 col = &stmt->columns[colno]; in fetch_value()
518 stmt->methods->get_col(stmt, colno, &value, &value_len, &caller_frees); in fetch_value()
554 if (stmt->dbh->stringify || new_type == PDO_PARAM_STR) { in fetch_value()
566 } else if (!stmt->dbh->stringify && new_type != PDO_PARAM_STR) { in fetch_value()
591 if (value && !(value_len == 0 && stmt->dbh->oracle_nulls == PDO_NULL_EMPTY_STRING)) { in fetch_value()
622 if (stmt->dbh->stringify) { in fetch_value()
631 if (Z_TYPE_P(dest) == IS_NULL && stmt->dbh->oracle_nulls == PDO_NULL_TO_STRING) { in fetch_value()
637 static bool do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* … in do_fetch_common() argument
639 if (!stmt->executed) { in do_fetch_common()
643 if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_PRE)) { in do_fetch_common()
647 if (!stmt->methods->fetcher(stmt, ori, offset)) { in do_fetch_common()
652 if (!stmt->columns && !pdo_stmt_describe_columns(stmt)) { in do_fetch_common()
656 if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_POST)) { in do_fetch_common()
660 if (stmt->bound_columns) { in do_fetch_common()
664 ZEND_HASH_FOREACH_PTR(stmt->bound_columns, param) { in do_fetch_common()
674 fetch_value(stmt, Z_REFVAL(param->parameter), param->paramno, (int *)¶m->param_type); in do_fetch_common()
688 static bool do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */ in do_fetch_class_prepare() argument
690 zend_class_entry *ce = stmt->fetch.cls.ce; in do_fetch_class_prepare()
691 zend_fcall_info *fci = &stmt->fetch.cls.fci; in do_fetch_class_prepare()
692 zend_fcall_info_cache *fcc = &stmt->fetch.cls.fcc; in do_fetch_class_prepare()
697 stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; in do_fetch_class_prepare()
703 fci->retval = &stmt->fetch.cls.retval; in do_fetch_class_prepare()
707 zend_fcall_info_args_ex(fci, ce->constructor, &stmt->fetch.cls.ctor_args); in do_fetch_class_prepare()
712 } else if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) { in do_fetch_class_prepare()
721 static bool make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * fci, zend_fcall_in… in make_callable_ex() argument
746 static bool do_fetch_func_prepare(pdo_stmt_t *stmt) /* {{{ */ in do_fetch_func_prepare() argument
748 zend_fcall_info *fci = &stmt->fetch.cls.fci; in do_fetch_func_prepare()
749 zend_fcall_info_cache *fcc = &stmt->fetch.cls.fcc; in do_fetch_func_prepare()
751 if (!make_callable_ex(stmt, &stmt->fetch.func.function, fci, fcc, stmt->column_count)) { in do_fetch_func_prepare()
754 stmt->fetch.func.values = safe_emalloc(sizeof(zval), stmt->column_count, 0); in do_fetch_func_prepare()
760 static void do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs) /* {{{ */ in do_fetch_opt_finish() argument
763 if (stmt->fetch.cls.fci.size && stmt->fetch.cls.fci.params) { in do_fetch_opt_finish()
764 if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) { in do_fetch_opt_finish()
766 zend_fcall_info_args_clear(&stmt->fetch.cls.fci, 1); in do_fetch_opt_finish()
768 efree(stmt->fetch.cls.fci.params); in do_fetch_opt_finish()
770 stmt->fetch.cls.fci.params = NULL; in do_fetch_opt_finish()
773 stmt->fetch.cls.fci.size = 0; in do_fetch_opt_finish()
774 if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args) && free_ctor_agrs) { in do_fetch_opt_finish()
775 zval_ptr_dtor(&stmt->fetch.cls.ctor_args); in do_fetch_opt_finish()
776 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in do_fetch_opt_finish()
777 stmt->fetch.cls.fci.param_count = 0; in do_fetch_opt_finish()
779 if (stmt->fetch.func.values) { in do_fetch_opt_finish()
780 efree(stmt->fetch.func.values); in do_fetch_opt_finish()
781 stmt->fetch.func.values = NULL; in do_fetch_opt_finish()
788 static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type how, enum pdo_fetch_… in do_fetch() argument
797 how = stmt->default_fetch_type; in do_fetch()
802 if (!do_fetch_common(stmt, ori, offset)) { in do_fetch()
811 if ((flags & PDO_FETCH_GROUP) && stmt->fetch.column == -1) { in do_fetch()
814 colno = stmt->fetch.column; in do_fetch()
823 get_lazy_object(stmt, return_value); in do_fetch()
836 array_init_size(return_value, stmt->column_count); in do_fetch()
843 if (stmt->column_count != 2) { in do_fetch()
845 …pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "PDO::FETCH_KEY_PAIR fetch mode requires the result… in do_fetch()
859 if (colno >= stmt->column_count) { in do_fetch()
864 if (flags == PDO_FETCH_GROUP && stmt->fetch.column == -1) { in do_fetch()
865 fetch_value(stmt, return_value, 1, NULL); in do_fetch()
867 fetch_value(stmt, return_value, 0, NULL); in do_fetch()
869 fetch_value(stmt, return_value, colno, NULL); in do_fetch()
885 old_ce = stmt->fetch.cls.ce; in do_fetch()
886 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in do_fetch()
887 old_arg_count = stmt->fetch.cls.fci.param_count; in do_fetch()
888 do_fetch_opt_finish(stmt, 0); in do_fetch()
890 fetch_value(stmt, &val, i++, NULL); in do_fetch()
896 stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; in do_fetch()
898 stmt->fetch.cls.ce = cep; in do_fetch()
902 do_fetch_class_prepare(stmt); in do_fetch()
905 ce = stmt->fetch.cls.ce; in do_fetch()
909 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch class specified"); in do_fetch()
916 if (!stmt->fetch.cls.fci.size) { in do_fetch()
917 if (!do_fetch_class_prepare(stmt)) { in do_fetch()
923 stmt->fetch.cls.fci.object = Z_OBJ_P(return_value); in do_fetch()
924 stmt->fetch.cls.fcc.object = Z_OBJ_P(return_value); in do_fetch()
925 if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc) == FAILURE) { in do_fetch()
927 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor"); in do_fetch()
930 if (!Z_ISUNDEF(stmt->fetch.cls.retval)) { in do_fetch()
931 zval_ptr_dtor(&stmt->fetch.cls.retval); in do_fetch()
932 ZVAL_UNDEF(&stmt->fetch.cls.retval); in do_fetch()
941 if (Z_ISUNDEF(stmt->fetch.into)) { in do_fetch()
943 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch-into object specified."); in do_fetch()
948 ZVAL_COPY(return_value, &stmt->fetch.into); in do_fetch()
957 if (Z_ISUNDEF(stmt->fetch.func.function)) { in do_fetch()
959 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch function specified"); in do_fetch()
962 if (!stmt->fetch.func.fci.size) { in do_fetch()
963 if (!do_fetch_func_prepare(stmt)) in do_fetch()
973 if (flags == PDO_FETCH_GROUP && how == PDO_FETCH_COLUMN && stmt->fetch.column > 0) { in do_fetch()
974 fetch_value(stmt, &grp_val, colno, NULL); in do_fetch()
976 fetch_value(stmt, &grp_val, i, NULL); in do_fetch()
980 i = stmt->column_count; /* no more data to fetch */ in do_fetch()
986 for (idx = 0; i < stmt->column_count; i++, idx++) { in do_fetch()
988 fetch_value(stmt, &val, i, NULL); in do_fetch()
992 zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
998 fetch_value(stmt, &tmp, ++i, NULL); in do_fetch()
1013 zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
1023 if ((curr_val = zend_hash_find(Z_ARRVAL_P(return_value), stmt->columns[i].name))) { in do_fetch()
1048 zend_hash_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
1060 stmt->columns[i].name, in do_fetch()
1068 stmt->columns[i].name, in do_fetch()
1074 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class"); in do_fetch()
1078 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class"); in do_fetch()
1089 ZVAL_COPY_VALUE(&stmt->fetch.func.values[idx], &val); in do_fetch()
1090 ZVAL_COPY_VALUE(&stmt->fetch.cls.fci.params[idx], &stmt->fetch.func.values[idx]); in do_fetch()
1103 stmt->fetch.cls.fci.object = Z_OBJ_P(return_value); in do_fetch()
1104 stmt->fetch.cls.fcc.object = Z_OBJ_P(return_value); in do_fetch()
1105 if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc) == FAILURE) { in do_fetch()
1107 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor"); in do_fetch()
1110 if (!Z_ISUNDEF(stmt->fetch.cls.retval)) { in do_fetch()
1111 zval_ptr_dtor(&stmt->fetch.cls.retval); in do_fetch()
1116 do_fetch_opt_finish(stmt, 0); in do_fetch()
1117 stmt->fetch.cls.ce = old_ce; in do_fetch()
1118 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in do_fetch()
1119 stmt->fetch.cls.fci.param_count = old_arg_count; in do_fetch()
1124 stmt->fetch.func.fci.param_count = idx; in do_fetch()
1125 stmt->fetch.func.fci.retval = &retval; in do_fetch()
1126 if (zend_call_function(&stmt->fetch.func.fci, &stmt->fetch.func.fcc) == FAILURE) { in do_fetch()
1128 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call user-supplied function"); in do_fetch()
1139 zval_ptr_dtor(&stmt->fetch.func.values[idx]); in do_fetch()
1167 static bool pdo_stmt_verify_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_arg_num, bool fetc… in pdo_stmt_verify_mode() argument
1179 flags = stmt->default_fetch_type & PDO_FETCH_FLAGS; in pdo_stmt_verify_mode()
1180 mode = stmt->default_fetch_type & ~PDO_FETCH_FLAGS; in pdo_stmt_verify_mode()
1235 if (!pdo_stmt_verify_mode(stmt, how, 1, false)) { in PHP_METHOD()
1239 if (!do_fetch(stmt, return_value, how, ori, off, NULL)) { in PHP_METHOD()
1263 old_ce = stmt->fetch.cls.ce; in PHP_METHOD()
1264 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in PHP_METHOD()
1265 old_arg_count = stmt->fetch.cls.fci.param_count; in PHP_METHOD()
1267 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1270 ZVAL_ARR(&stmt->fetch.cls.ctor_args, zend_array_dup(Z_ARRVAL_P(ctor_args))); in PHP_METHOD()
1272 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in PHP_METHOD()
1275 stmt->fetch.cls.ce = ce; in PHP_METHOD()
1277 stmt->fetch.cls.ce = zend_standard_class_def; in PHP_METHOD()
1280 if (!do_fetch(stmt, return_value, PDO_FETCH_CLASS, PDO_FETCH_ORI_NEXT, /* offset */ 0, NULL)) { in PHP_METHOD()
1284 do_fetch_opt_finish(stmt, 1); in PHP_METHOD()
1286 stmt->fetch.cls.ce = old_ce; in PHP_METHOD()
1287 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in PHP_METHOD()
1288 stmt->fetch.cls.fci.param_count = old_arg_count; in PHP_METHOD()
1305 if (!do_fetch_common(stmt, PDO_FETCH_ORI_NEXT, 0)) { in PHP_METHOD()
1310 fetch_value(stmt, return_value, col_n, NULL); in PHP_METHOD()
1333 if (!pdo_stmt_verify_mode(stmt, how, 1, true)) { in PHP_METHOD()
1337 old_ce = stmt->fetch.cls.ce; in PHP_METHOD()
1338 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in PHP_METHOD()
1339 old_arg_count = stmt->fetch.cls.fci.param_count; in PHP_METHOD()
1341 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1353 stmt->fetch.cls.ce = zend_fetch_class(Z_STR_P(arg2), ZEND_FETCH_CLASS_AUTO); in PHP_METHOD()
1354 if (!stmt->fetch.cls.ce) { in PHP_METHOD()
1359 stmt->fetch.cls.ce = zend_standard_class_def; in PHP_METHOD()
1363 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, ctor_args); /* we're not going to free these */ in PHP_METHOD()
1365 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in PHP_METHOD()
1368 do_fetch_class_prepare(stmt); in PHP_METHOD()
1385 ZVAL_COPY_VALUE(&stmt->fetch.func.function, arg2); in PHP_METHOD()
1386 if (do_fetch_func_prepare(stmt) == false) { in PHP_METHOD()
1410 stmt->fetch.column = Z_LVAL_P(arg2); in PHP_METHOD()
1412 stmt->fetch.column = how & PDO_FETCH_GROUP ? -1 : 0; in PHP_METHOD()
1430 flags |= stmt->default_fetch_type & PDO_FETCH_FLAGS; in PHP_METHOD()
1431 how |= stmt->default_fetch_type & ~PDO_FETCH_FLAGS; in PHP_METHOD()
1436 (how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR) in PHP_METHOD()
1441 if (!do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, return_all)) { in PHP_METHOD()
1447 while (do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, return_all)); in PHP_METHOD()
1448 …} else if (how == PDO_FETCH_KEY_PAIR || (how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type … in PHP_METHOD()
1449 while (do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, return_all)); in PHP_METHOD()
1454 } while (do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, NULL)); in PHP_METHOD()
1458 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1461 stmt->fetch.cls.ce = old_ce; in PHP_METHOD()
1462 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in PHP_METHOD()
1463 stmt->fetch.cls.fci.param_count = old_arg_count; in PHP_METHOD()
1514 if (!really_register_bound_param(¶m, stmt, is_param)) { in register_bound_param()
1558 if (!really_register_bound_param(¶m, stmt, TRUE)) { in PHP_METHOD()
1589 RETURN_LONG(stmt->row_count); in PHP_METHOD()
1599 if (stmt->error_code[0] == '\0') { in PHP_METHOD()
1603 RETURN_STRING(stmt->error_code); in PHP_METHOD()
1618 add_next_index_string(return_value, stmt->error_code); in PHP_METHOD()
1620 if (strncmp(stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) { in PHP_METHOD()
1621 if (stmt->dbh->methods->fetch_err) { in PHP_METHOD()
1622 stmt->dbh->methods->fetch_err(stmt->dbh, stmt, return_value); in PHP_METHOD()
1653 if (!stmt->methods->set_attribute) { in PHP_METHOD()
1654 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "This driver doesn't support setting attributes"); in PHP_METHOD()
1659 if (stmt->methods->set_attribute(stmt, attr, value)) { in PHP_METHOD()
1671 static bool generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, zend_long attr) in generic_stmt_attr_get() argument
1675 RETVAL_BOOL(stmt->supports_placeholders == PDO_PLACEHOLDER_NONE); in generic_stmt_attr_get()
1690 if (!stmt->methods->get_attribute) { in PHP_METHOD()
1691 if (!generic_stmt_attr_get(stmt, return_value, attr)) { in PHP_METHOD()
1692 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", in PHP_METHOD()
1700 switch (stmt->methods->get_attribute(stmt, attr, return_value)) { in PHP_METHOD()
1706 if (!generic_stmt_attr_get(stmt, return_value, attr)) { in PHP_METHOD()
1708 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", in PHP_METHOD()
1726 RETURN_LONG(stmt->column_count); in PHP_METHOD()
1746 if (!stmt->methods->get_column_meta) { in PHP_METHOD()
1747 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver doesn't support meta data"); in PHP_METHOD()
1752 if (FAILURE == stmt->methods->get_column_meta(stmt, colno, return_value)) { in PHP_METHOD()
1758 col = &stmt->columns[colno]; in PHP_METHOD()
1771 bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_arg_num, in pdo_stmt_setup_fetch_mode() argument
1779 switch (stmt->default_fetch_type) { in pdo_stmt_setup_fetch_mode()
1781 if (!Z_ISUNDEF(stmt->fetch.into)) { in pdo_stmt_setup_fetch_mode()
1782 zval_ptr_dtor(&stmt->fetch.into); in pdo_stmt_setup_fetch_mode()
1783 ZVAL_UNDEF(&stmt->fetch.into); in pdo_stmt_setup_fetch_mode()
1790 stmt->default_fetch_type = PDO_FETCH_BOTH; in pdo_stmt_setup_fetch_mode()
1794 if (!pdo_stmt_verify_mode(stmt, mode, mode_arg_num, false)) { in pdo_stmt_setup_fetch_mode()
1833 stmt->fetch.column = Z_LVAL(args[0]); in pdo_stmt_setup_fetch_mode()
1839 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in pdo_stmt_setup_fetch_mode()
1849 stmt->fetch.cls.ce = NULL; in pdo_stmt_setup_fetch_mode()
1888 stmt->fetch.cls.ce = cep; in pdo_stmt_setup_fetch_mode()
1892 ZVAL_ARR(&stmt->fetch.cls.ctor_args, zend_array_dup(constructor_args)); in pdo_stmt_setup_fetch_mode()
1896 do_fetch_class_prepare(stmt); in pdo_stmt_setup_fetch_mode()
1912 ZVAL_COPY(&stmt->fetch.into, &args[0]); in pdo_stmt_setup_fetch_mode()
1919 stmt->default_fetch_type = mode; in pdo_stmt_setup_fetch_mode()
1936 do_fetch_opt_finish(stmt, 1); in PHP_METHOD()
1938 if (!pdo_stmt_setup_fetch_mode(stmt, fetch_mode, 1, args, num_args)) { in PHP_METHOD()
1949 static bool pdo_stmt_do_next_rowset(pdo_stmt_t *stmt) in pdo_stmt_do_next_rowset() argument
1951 pdo_stmt_reset_columns(stmt); in pdo_stmt_do_next_rowset()
1953 if (!stmt->methods->next_rowset(stmt)) { in pdo_stmt_do_next_rowset()
1955 stmt->executed = 0; in pdo_stmt_do_next_rowset()
1959 pdo_stmt_describe_columns(stmt); in pdo_stmt_do_next_rowset()
1969 if (!stmt->methods->next_rowset) { in PHP_METHOD()
1970 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver does not support multiple rowsets"); in PHP_METHOD()
1976 if (!pdo_stmt_do_next_rowset(stmt)) { in PHP_METHOD()
1991 if (!stmt->methods->cursor_closer) { in PHP_METHOD()
1994 while (stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0)) in PHP_METHOD()
1996 if (!stmt->methods->next_rowset) { in PHP_METHOD()
2000 if (!pdo_stmt_do_next_rowset(stmt)) { in PHP_METHOD()
2005 stmt->executed = 0; in PHP_METHOD()
2011 if (!stmt->methods->cursor_closer(stmt)) { in PHP_METHOD()
2015 stmt->executed = 0; in PHP_METHOD()
2037 php_stream_printf(out, "SQL: [%zd] ", stmt->query_stringlen); in PHP_METHOD()
2038 php_stream_write(out, stmt->query_string, stmt->query_stringlen); in PHP_METHOD()
2043 if (stmt->active_query_string != NULL && stmt->active_query_string != stmt->query_string) { in PHP_METHOD()
2045 php_stream_printf(out, "Sent SQL: [%zd] ", stmt->active_query_stringlen); in PHP_METHOD()
2046 php_stream_write(out, stmt->active_query_string, stmt->active_query_stringlen); in PHP_METHOD()
2051 stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0); in PHP_METHOD()
2053 if (stmt->bound_params) { in PHP_METHOD()
2056 ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) { in PHP_METHOD()
2119 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); in dbstmt_method_get() local
2121 if (!stmt->dbh) { in dbstmt_method_get()
2126 if (!stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT]) { in dbstmt_method_get()
2127 if (!pdo_hash_methods(Z_PDO_OBJECT_P(&stmt->database_object_handle), in dbstmt_method_get()
2129 || !stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT]) { in dbstmt_method_get()
2134 …if ((fbc = zend_hash_find_ptr(stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT], lc_method_n… in dbstmt_method_get()
2156 PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt) in php_pdo_free_statement() argument
2158 if (stmt->bound_params) { in php_pdo_free_statement()
2159 zend_hash_destroy(stmt->bound_params); in php_pdo_free_statement()
2160 FREE_HASHTABLE(stmt->bound_params); in php_pdo_free_statement()
2161 stmt->bound_params = NULL; in php_pdo_free_statement()
2163 if (stmt->bound_param_map) { in php_pdo_free_statement()
2164 zend_hash_destroy(stmt->bound_param_map); in php_pdo_free_statement()
2165 FREE_HASHTABLE(stmt->bound_param_map); in php_pdo_free_statement()
2166 stmt->bound_param_map = NULL; in php_pdo_free_statement()
2168 if (stmt->bound_columns) { in php_pdo_free_statement()
2169 zend_hash_destroy(stmt->bound_columns); in php_pdo_free_statement()
2170 FREE_HASHTABLE(stmt->bound_columns); in php_pdo_free_statement()
2171 stmt->bound_columns = NULL; in php_pdo_free_statement()
2174 if (stmt->methods && stmt->methods->dtor) { in php_pdo_free_statement()
2175 stmt->methods->dtor(stmt); in php_pdo_free_statement()
2177 if (stmt->active_query_string && stmt->active_query_string != stmt->query_string) { in php_pdo_free_statement()
2178 efree(stmt->active_query_string); in php_pdo_free_statement()
2180 if (stmt->query_string) { in php_pdo_free_statement()
2181 efree(stmt->query_string); in php_pdo_free_statement()
2184 pdo_stmt_reset_columns(stmt); in php_pdo_free_statement()
2186 if (!Z_ISUNDEF(stmt->fetch.into) && stmt->default_fetch_type == PDO_FETCH_INTO) { in php_pdo_free_statement()
2187 zval_ptr_dtor(&stmt->fetch.into); in php_pdo_free_statement()
2188 ZVAL_UNDEF(&stmt->fetch.into); in php_pdo_free_statement()
2191 do_fetch_opt_finish(stmt, 1); in php_pdo_free_statement()
2193 if (!Z_ISUNDEF(stmt->database_object_handle)) { in php_pdo_free_statement()
2194 zval_ptr_dtor(&stmt->database_object_handle); in php_pdo_free_statement()
2196 zend_object_std_dtor(&stmt->std); in php_pdo_free_statement()
2201 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(std); in pdo_dbstmt_free_storage() local
2202 php_pdo_free_statement(stmt); in pdo_dbstmt_free_storage()
2207 pdo_stmt_t *stmt; in pdo_dbstmt_new() local
2209 stmt = zend_object_alloc(sizeof(pdo_stmt_t), ce); in pdo_dbstmt_new()
2210 zend_object_std_init(&stmt->std, ce); in pdo_dbstmt_new()
2211 object_properties_init(&stmt->std, ce); in pdo_dbstmt_new()
2213 stmt->std.handlers = &pdo_dbstmt_object_handlers; in pdo_dbstmt_new()
2215 return &stmt->std; in pdo_dbstmt_new()
2271 pdo_stmt_t *stmt = Z_PDO_STMT_P(&I->iter.data); /* for PDO_HANDLE_STMT_ERR() */ in pdo_stmt_iter_move_forwards() local
2277 if (!do_fetch(stmt, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT, in pdo_stmt_iter_move_forwards()
2308 pdo_stmt_t *stmt = Z_PDO_STMT_P(object); in pdo_stmt_iter_get() local
2309 if (!stmt->dbh) { in pdo_stmt_iter_get()
2320 if (!do_fetch(stmt, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT, in pdo_stmt_iter_get()
2337 pdo_stmt_t *stmt = row->stmt; in row_prop_read() local
2342 if (stmt) { in row_prop_read()
2344 if (lval >= 0 && lval < stmt->column_count) { in row_prop_read()
2345 fetch_value(stmt, rv, lval, NULL); in row_prop_read()
2350 for (colno = 0; colno < stmt->column_count; colno++) { in row_prop_read()
2351 if (ZSTR_LEN(stmt->columns[colno].name) == ZSTR_LEN(name) && in row_prop_read()
2352 strncmp(ZSTR_VAL(stmt->columns[colno].name), ZSTR_VAL(name), ZSTR_LEN(name)) == 0) { in row_prop_read()
2353 fetch_value(stmt, rv, colno, NULL); in row_prop_read()
2359 return zend_std_read_property(&stmt->std, name, type, cache_slot, rv); in row_prop_read()
2370 pdo_stmt_t *stmt = row->stmt; in row_dim_read() local
2375 if (stmt) { in row_dim_read()
2377 if (Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count) { in row_dim_read()
2378 fetch_value(stmt, rv, Z_LVAL_P(member), NULL); in row_dim_read()
2382 if (lval >= 0 && lval < stmt->column_count) { in row_dim_read()
2383 fetch_value(stmt, rv, lval, NULL); in row_dim_read()
2392 for (colno = 0; colno < stmt->column_count; colno++) { in row_dim_read()
2393 if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) && in row_dim_read()
2394 strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { in row_dim_read()
2395 fetch_value(stmt, rv, colno, NULL); in row_dim_read()
2401 return zend_std_read_property(&stmt->std, Z_STR_P(member), type, NULL, rv); in row_dim_read()
2423 pdo_stmt_t *stmt = row->stmt; in row_prop_exists() local
2427 if (stmt) { in row_prop_exists()
2429 return lval >=0 && lval < stmt->column_count; in row_prop_exists()
2434 for (colno = 0; colno < stmt->column_count; colno++) { in row_prop_exists()
2435 if (ZSTR_LEN(stmt->columns[colno].name) == ZSTR_LEN(name) && in row_prop_exists()
2436 strncmp(ZSTR_VAL(stmt->columns[colno].name), ZSTR_VAL(name), ZSTR_LEN(name)) == 0) { in row_prop_exists()
2440 fetch_value(stmt, &val, colno, NULL); in row_prop_exists()
2455 pdo_stmt_t *stmt = row->stmt; in row_dim_exists() local
2459 if (stmt) { in row_dim_exists()
2461 return Z_LVAL_P(member) >= 0 && Z_LVAL_P(member) < stmt->column_count; in row_dim_exists()
2464 return lval >=0 && lval < stmt->column_count; in row_dim_exists()
2474 for (colno = 0; colno < stmt->column_count; colno++) { in row_dim_exists()
2475 if (ZSTR_LEN(stmt->columns[colno].name) == Z_STRLEN_P(member) && in row_dim_exists()
2476 strncmp(ZSTR_VAL(stmt->columns[colno].name), Z_STRVAL_P(member), Z_STRLEN_P(member)) == 0) { in row_dim_exists()
2480 fetch_value(stmt, &val, colno, NULL); in row_dim_exists()
2505 pdo_stmt_t *stmt = row->stmt; in row_get_properties_for() local
2509 if (purpose != ZEND_PROP_PURPOSE_DEBUG || stmt == NULL) { in row_get_properties_for()
2513 if (!stmt->std.properties) { in row_get_properties_for()
2514 rebuild_object_properties(&stmt->std); in row_get_properties_for()
2516 props = zend_array_dup(stmt->std.properties); in row_get_properties_for()
2517 for (i = 0; i < stmt->column_count; i++) { in row_get_properties_for()
2519 fetch_value(stmt, &val, i, NULL); in row_get_properties_for()
2521 zend_hash_update(props, stmt->columns[i].name, &val); in row_get_properties_for()
2564 if (row->stmt) { in pdo_row_free_storage()
2565 ZVAL_UNDEF(&row->stmt->lazy_object_ref); in pdo_row_free_storage()
2566 OBJ_RELEASE(&row->stmt->std); in pdo_row_free_storage()