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 bool 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 (zend_string_equals(stmt->columns[i].name, param->name)) { in really_register_bound_param()
313 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", tmp); in really_register_bound_param()
329 if (is_param && !rewrite_name_to_position(stmt, param)) { in really_register_bound_param()
341 if (stmt->methods->param_hook) { in really_register_bound_param()
342 if (!stmt->methods->param_hook(stmt, param, PDO_PARAM_EVT_NORMALIZE)) { in really_register_bound_param()
367 if (stmt->methods->param_hook) { in really_register_bound_param()
368 if (!stmt->methods->param_hook(stmt, pparam, PDO_PARAM_EVT_ALLOC)) { in really_register_bound_param()
406 if (stmt->bound_params) { in PHP_METHOD()
407 zend_hash_destroy(stmt->bound_params); in PHP_METHOD()
408 FREE_HASHTABLE(stmt->bound_params); in PHP_METHOD()
409 stmt->bound_params = NULL; in PHP_METHOD()
428 if (!really_register_bound_param(¶m, stmt, 1)) { in PHP_METHOD()
437 if (PDO_PLACEHOLDER_NONE == stmt->supports_placeholders) { in PHP_METHOD()
444 if (stmt->active_query_string) { in PHP_METHOD()
445 zend_string_release(stmt->active_query_string); in PHP_METHOD()
446 stmt->active_query_string = NULL; in PHP_METHOD()
449 ret = pdo_parse_params(stmt, stmt->query_string, &stmt->active_query_string); in PHP_METHOD()
453 stmt->active_query_string = zend_string_copy(stmt->query_string); in PHP_METHOD()
459 } else if (!dispatch_param_event(stmt, PDO_PARAM_EVT_EXEC_PRE)) { in PHP_METHOD()
463 if (stmt->methods->executer(stmt)) { in PHP_METHOD()
464 if (!stmt->executed) { in PHP_METHOD()
467 if (stmt->dbh->alloc_own_columns && !stmt->columns) { in PHP_METHOD()
470 ret = pdo_stmt_describe_columns(stmt); in PHP_METHOD()
473 stmt->executed = 1; in PHP_METHOD()
476 if (ret && !dispatch_param_event(stmt, PDO_PARAM_EVT_EXEC_POST)) { in PHP_METHOD()
488 static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo_param_type *type_o… in fetch_value() argument
496 if (colno >= stmt->column_count) { in fetch_value()
503 stmt->methods->get_col(stmt, colno, dest, type_override); in fetch_value()
506 && stmt->dbh->oracle_nulls == PDO_NULL_EMPTY_STRING) { in fetch_value()
513 if (stmt->dbh->stringify) { in fetch_value()
562 if (Z_TYPE_P(dest) == IS_NULL && stmt->dbh->oracle_nulls == PDO_NULL_TO_STRING) { in fetch_value()
568 static bool do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* … in do_fetch_common() argument
570 if (!stmt->executed) { in do_fetch_common()
574 if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_PRE)) { in do_fetch_common()
578 if (!stmt->methods->fetcher(stmt, ori, offset)) { in do_fetch_common()
583 if (!stmt->columns && !pdo_stmt_describe_columns(stmt)) { in do_fetch_common()
587 if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_POST)) { in do_fetch_common()
591 if (stmt->bound_columns) { in do_fetch_common()
595 ZEND_HASH_FOREACH_PTR(stmt->bound_columns, param) { in do_fetch_common()
605 fetch_value(stmt, Z_REFVAL(param->parameter), param->paramno, ¶m->param_type); in do_fetch_common()
619 static bool do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */ in do_fetch_class_prepare() argument
621 zend_class_entry *ce = stmt->fetch.cls.ce; in do_fetch_class_prepare()
622 zend_fcall_info *fci = &stmt->fetch.cls.fci; in do_fetch_class_prepare()
623 zend_fcall_info_cache *fcc = &stmt->fetch.cls.fcc; in do_fetch_class_prepare()
628 stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; in do_fetch_class_prepare()
634 fci->retval = &stmt->fetch.cls.retval; in do_fetch_class_prepare()
638 zend_fcall_info_args_ex(fci, ce->constructor, &stmt->fetch.cls.ctor_args); in do_fetch_class_prepare()
643 } else if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) { in do_fetch_class_prepare()
652 static bool make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * fci, zend_fcall_in… in make_callable_ex() argument
677 static bool do_fetch_func_prepare(pdo_stmt_t *stmt) /* {{{ */ in do_fetch_func_prepare() argument
679 zend_fcall_info *fci = &stmt->fetch.cls.fci; in do_fetch_func_prepare()
680 zend_fcall_info_cache *fcc = &stmt->fetch.cls.fcc; in do_fetch_func_prepare()
682 if (!make_callable_ex(stmt, &stmt->fetch.func.function, fci, fcc, stmt->column_count)) { in do_fetch_func_prepare()
685 stmt->fetch.func.values = safe_emalloc(sizeof(zval), stmt->column_count, 0); in do_fetch_func_prepare()
691 static void do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs) /* {{{ */ in do_fetch_opt_finish() argument
694 if (stmt->fetch.cls.fci.size && stmt->fetch.cls.fci.params) { in do_fetch_opt_finish()
695 if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) { in do_fetch_opt_finish()
697 zend_fcall_info_args_clear(&stmt->fetch.cls.fci, 1); in do_fetch_opt_finish()
699 efree(stmt->fetch.cls.fci.params); in do_fetch_opt_finish()
701 stmt->fetch.cls.fci.params = NULL; in do_fetch_opt_finish()
704 stmt->fetch.cls.fci.size = 0; in do_fetch_opt_finish()
705 if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args) && free_ctor_agrs) { in do_fetch_opt_finish()
706 zval_ptr_dtor(&stmt->fetch.cls.ctor_args); in do_fetch_opt_finish()
707 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in do_fetch_opt_finish()
708 stmt->fetch.cls.fci.param_count = 0; in do_fetch_opt_finish()
710 if (stmt->fetch.func.values) { in do_fetch_opt_finish()
711 efree(stmt->fetch.func.values); in do_fetch_opt_finish()
712 stmt->fetch.func.values = NULL; in do_fetch_opt_finish()
719 static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type how, enum pdo_fetch_… in do_fetch() argument
728 how = stmt->default_fetch_type; in do_fetch()
733 if (!do_fetch_common(stmt, ori, offset)) { in do_fetch()
742 if ((flags & PDO_FETCH_GROUP) && stmt->fetch.column == -1) { in do_fetch()
745 colno = stmt->fetch.column; in do_fetch()
754 get_lazy_object(stmt, return_value); in do_fetch()
767 array_init_size(return_value, stmt->column_count); in do_fetch()
774 if (stmt->column_count != 2) { in do_fetch()
776 …pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "PDO::FETCH_KEY_PAIR fetch mode requires the result… in do_fetch()
790 if (colno >= stmt->column_count) { in do_fetch()
795 if (flags == PDO_FETCH_GROUP && stmt->fetch.column == -1) { in do_fetch()
796 fetch_value(stmt, return_value, 1, NULL); in do_fetch()
798 fetch_value(stmt, return_value, 0, NULL); in do_fetch()
800 fetch_value(stmt, return_value, colno, NULL); in do_fetch()
816 old_ce = stmt->fetch.cls.ce; in do_fetch()
817 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in do_fetch()
818 old_arg_count = stmt->fetch.cls.fci.param_count; in do_fetch()
819 do_fetch_opt_finish(stmt, 0); in do_fetch()
821 fetch_value(stmt, &val, i++, NULL); in do_fetch()
827 stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; in do_fetch()
829 stmt->fetch.cls.ce = cep; in do_fetch()
833 do_fetch_class_prepare(stmt); in do_fetch()
836 ce = stmt->fetch.cls.ce; in do_fetch()
840 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch class specified"); in do_fetch()
847 if (!stmt->fetch.cls.fci.size) { in do_fetch()
848 if (!do_fetch_class_prepare(stmt)) { in do_fetch()
854 stmt->fetch.cls.fci.object = Z_OBJ_P(return_value); in do_fetch()
855 stmt->fetch.cls.fcc.object = Z_OBJ_P(return_value); in do_fetch()
856 if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc) == FAILURE) { in do_fetch()
858 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor"); in do_fetch()
861 if (!Z_ISUNDEF(stmt->fetch.cls.retval)) { in do_fetch()
862 zval_ptr_dtor(&stmt->fetch.cls.retval); in do_fetch()
863 ZVAL_UNDEF(&stmt->fetch.cls.retval); in do_fetch()
872 if (Z_ISUNDEF(stmt->fetch.into)) { in do_fetch()
874 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch-into object specified."); in do_fetch()
879 ZVAL_COPY(return_value, &stmt->fetch.into); in do_fetch()
888 if (Z_ISUNDEF(stmt->fetch.func.function)) { in do_fetch()
890 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch function specified"); in do_fetch()
893 if (!stmt->fetch.func.fci.size) { in do_fetch()
894 if (!do_fetch_func_prepare(stmt)) in do_fetch()
904 if (flags == PDO_FETCH_GROUP && how == PDO_FETCH_COLUMN && stmt->fetch.column > 0) { in do_fetch()
905 fetch_value(stmt, &grp_val, colno, NULL); in do_fetch()
907 fetch_value(stmt, &grp_val, i, NULL); in do_fetch()
911 i = stmt->column_count; /* no more data to fetch */ in do_fetch()
917 for (idx = 0; i < stmt->column_count; i++, idx++) { in do_fetch()
919 fetch_value(stmt, &val, i, NULL); in do_fetch()
923 zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
929 fetch_value(stmt, &tmp, ++i, NULL); in do_fetch()
944 zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
954 if ((curr_val = zend_hash_find(Z_ARRVAL_P(return_value), stmt->columns[i].name))) { in do_fetch()
979 zend_hash_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
991 stmt->columns[i].name, in do_fetch()
999 stmt->columns[i].name, in do_fetch()
1005 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class"); in do_fetch()
1009 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class"); in do_fetch()
1020 ZVAL_COPY_VALUE(&stmt->fetch.func.values[idx], &val); in do_fetch()
1021 ZVAL_COPY_VALUE(&stmt->fetch.cls.fci.params[idx], &stmt->fetch.func.values[idx]); in do_fetch()
1034 stmt->fetch.cls.fci.object = Z_OBJ_P(return_value); in do_fetch()
1035 stmt->fetch.cls.fcc.object = Z_OBJ_P(return_value); in do_fetch()
1036 if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc) == FAILURE) { in do_fetch()
1038 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor"); in do_fetch()
1041 if (!Z_ISUNDEF(stmt->fetch.cls.retval)) { in do_fetch()
1042 zval_ptr_dtor(&stmt->fetch.cls.retval); in do_fetch()
1047 do_fetch_opt_finish(stmt, 0); in do_fetch()
1048 stmt->fetch.cls.ce = old_ce; in do_fetch()
1049 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in do_fetch()
1050 stmt->fetch.cls.fci.param_count = old_arg_count; in do_fetch()
1055 stmt->fetch.func.fci.param_count = idx; in do_fetch()
1056 stmt->fetch.func.fci.retval = &retval; in do_fetch()
1057 if (zend_call_function(&stmt->fetch.func.fci, &stmt->fetch.func.fcc) == FAILURE) { in do_fetch()
1059 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call user-supplied function"); in do_fetch()
1070 zval_ptr_dtor(&stmt->fetch.func.values[idx]); in do_fetch()
1098 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
1110 flags = stmt->default_fetch_type & PDO_FETCH_FLAGS; in pdo_stmt_verify_mode()
1111 mode = stmt->default_fetch_type & ~PDO_FETCH_FLAGS; in pdo_stmt_verify_mode()
1169 if (!pdo_stmt_verify_mode(stmt, how, 1, false)) { in PHP_METHOD()
1173 if (!do_fetch(stmt, return_value, how, ori, off, NULL)) { in PHP_METHOD()
1197 old_ce = stmt->fetch.cls.ce; in PHP_METHOD()
1198 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in PHP_METHOD()
1199 old_arg_count = stmt->fetch.cls.fci.param_count; in PHP_METHOD()
1201 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1204 ZVAL_ARR(&stmt->fetch.cls.ctor_args, zend_array_dup(Z_ARRVAL_P(ctor_args))); in PHP_METHOD()
1206 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in PHP_METHOD()
1209 stmt->fetch.cls.ce = ce; in PHP_METHOD()
1211 stmt->fetch.cls.ce = zend_standard_class_def; in PHP_METHOD()
1214 if (!do_fetch(stmt, return_value, PDO_FETCH_CLASS, PDO_FETCH_ORI_NEXT, /* offset */ 0, NULL)) { in PHP_METHOD()
1218 do_fetch_opt_finish(stmt, 1); in PHP_METHOD()
1220 stmt->fetch.cls.ce = old_ce; in PHP_METHOD()
1221 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in PHP_METHOD()
1222 stmt->fetch.cls.fci.param_count = old_arg_count; in PHP_METHOD()
1239 if (!do_fetch_common(stmt, PDO_FETCH_ORI_NEXT, 0)) { in PHP_METHOD()
1244 fetch_value(stmt, return_value, col_n, NULL); in PHP_METHOD()
1267 if (!pdo_stmt_verify_mode(stmt, how, 1, true)) { in PHP_METHOD()
1271 old_ce = stmt->fetch.cls.ce; in PHP_METHOD()
1272 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in PHP_METHOD()
1273 old_arg_count = stmt->fetch.cls.fci.param_count; in PHP_METHOD()
1275 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1287 stmt->fetch.cls.ce = zend_fetch_class(Z_STR_P(arg2), ZEND_FETCH_CLASS_AUTO); in PHP_METHOD()
1288 if (!stmt->fetch.cls.ce) { in PHP_METHOD()
1293 stmt->fetch.cls.ce = zend_standard_class_def; in PHP_METHOD()
1297 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, ctor_args); /* we're not going to free these */ in PHP_METHOD()
1299 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in PHP_METHOD()
1302 do_fetch_class_prepare(stmt); in PHP_METHOD()
1319 ZVAL_COPY_VALUE(&stmt->fetch.func.function, arg2); in PHP_METHOD()
1320 if (do_fetch_func_prepare(stmt) == false) { in PHP_METHOD()
1344 stmt->fetch.column = Z_LVAL_P(arg2); in PHP_METHOD()
1346 stmt->fetch.column = how & PDO_FETCH_GROUP ? -1 : 0; in PHP_METHOD()
1364 flags |= stmt->default_fetch_type & PDO_FETCH_FLAGS; in PHP_METHOD()
1365 how |= stmt->default_fetch_type & ~PDO_FETCH_FLAGS; in PHP_METHOD()
1370 (how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR) in PHP_METHOD()
1375 if (!do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, return_all)) { in PHP_METHOD()
1381 (how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR) in PHP_METHOD()
1383 while (do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, return_all)); in PHP_METHOD()
1388 } while (do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, NULL)); in PHP_METHOD()
1392 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1395 stmt->fetch.cls.ce = old_ce; in PHP_METHOD()
1396 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in PHP_METHOD()
1397 stmt->fetch.cls.fci.param_count = old_arg_count; in PHP_METHOD()
1448 if (!really_register_bound_param(¶m, stmt, is_param)) { in register_bound_param()
1492 if (!really_register_bound_param(¶m, stmt, TRUE)) { in PHP_METHOD()
1523 RETURN_LONG(stmt->row_count); in PHP_METHOD()
1533 if (stmt->error_code[0] == '\0') { in PHP_METHOD()
1537 RETURN_STRING(stmt->error_code); in PHP_METHOD()
1552 add_next_index_string(return_value, stmt->error_code); in PHP_METHOD()
1554 if (strncmp(stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) { in PHP_METHOD()
1555 if (stmt->dbh->methods->fetch_err) { in PHP_METHOD()
1556 stmt->dbh->methods->fetch_err(stmt->dbh, stmt, return_value); in PHP_METHOD()
1587 if (!stmt->methods->set_attribute) { in PHP_METHOD()
1588 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "This driver doesn't support setting attributes"); in PHP_METHOD()
1593 if (stmt->methods->set_attribute(stmt, attr, value)) { in PHP_METHOD()
1605 static bool generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, zend_long attr) in generic_stmt_attr_get() argument
1609 RETVAL_BOOL(stmt->supports_placeholders == PDO_PLACEHOLDER_NONE); in generic_stmt_attr_get()
1624 if (!stmt->methods->get_attribute) { in PHP_METHOD()
1625 if (!generic_stmt_attr_get(stmt, return_value, attr)) { in PHP_METHOD()
1626 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", in PHP_METHOD()
1634 switch (stmt->methods->get_attribute(stmt, attr, return_value)) { in PHP_METHOD()
1640 if (!generic_stmt_attr_get(stmt, return_value, attr)) { in PHP_METHOD()
1642 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", in PHP_METHOD()
1660 RETURN_LONG(stmt->column_count); in PHP_METHOD()
1680 if (!stmt->methods->get_column_meta) { in PHP_METHOD()
1681 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver doesn't support meta data"); in PHP_METHOD()
1686 if (FAILURE == stmt->methods->get_column_meta(stmt, colno, return_value)) { in PHP_METHOD()
1692 col = &stmt->columns[colno]; in PHP_METHOD()
1701 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
1709 switch (stmt->default_fetch_type) { in pdo_stmt_setup_fetch_mode()
1711 if (!Z_ISUNDEF(stmt->fetch.into)) { in pdo_stmt_setup_fetch_mode()
1712 zval_ptr_dtor(&stmt->fetch.into); in pdo_stmt_setup_fetch_mode()
1713 ZVAL_UNDEF(&stmt->fetch.into); in pdo_stmt_setup_fetch_mode()
1720 stmt->default_fetch_type = PDO_FETCH_BOTH; in pdo_stmt_setup_fetch_mode()
1724 if (!pdo_stmt_verify_mode(stmt, mode, mode_arg_num, false)) { in pdo_stmt_setup_fetch_mode()
1763 stmt->fetch.column = Z_LVAL(args[0]); in pdo_stmt_setup_fetch_mode()
1769 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in pdo_stmt_setup_fetch_mode()
1779 stmt->fetch.cls.ce = NULL; in pdo_stmt_setup_fetch_mode()
1818 stmt->fetch.cls.ce = cep; in pdo_stmt_setup_fetch_mode()
1822 ZVAL_ARR(&stmt->fetch.cls.ctor_args, zend_array_dup(constructor_args)); in pdo_stmt_setup_fetch_mode()
1826 do_fetch_class_prepare(stmt); in pdo_stmt_setup_fetch_mode()
1842 ZVAL_COPY(&stmt->fetch.into, &args[0]); in pdo_stmt_setup_fetch_mode()
1849 stmt->default_fetch_type = mode; in pdo_stmt_setup_fetch_mode()
1866 do_fetch_opt_finish(stmt, 1); in PHP_METHOD()
1868 if (!pdo_stmt_setup_fetch_mode(stmt, fetch_mode, 1, args, num_args)) { in PHP_METHOD()
1879 static bool pdo_stmt_do_next_rowset(pdo_stmt_t *stmt) in pdo_stmt_do_next_rowset() argument
1881 pdo_stmt_reset_columns(stmt); in pdo_stmt_do_next_rowset()
1883 if (!stmt->methods->next_rowset(stmt)) { in pdo_stmt_do_next_rowset()
1885 stmt->executed = 0; in pdo_stmt_do_next_rowset()
1889 pdo_stmt_describe_columns(stmt); in pdo_stmt_do_next_rowset()
1899 if (!stmt->methods->next_rowset) { in PHP_METHOD()
1900 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver does not support multiple rowsets"); in PHP_METHOD()
1906 if (!pdo_stmt_do_next_rowset(stmt)) { in PHP_METHOD()
1921 if (!stmt->methods->cursor_closer) { in PHP_METHOD()
1924 while (stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0)) in PHP_METHOD()
1926 if (!stmt->methods->next_rowset) { in PHP_METHOD()
1930 if (!pdo_stmt_do_next_rowset(stmt)) { in PHP_METHOD()
1935 stmt->executed = 0; in PHP_METHOD()
1941 if (!stmt->methods->cursor_closer(stmt)) { in PHP_METHOD()
1945 stmt->executed = 0; in PHP_METHOD()
1967 php_stream_printf(out, "SQL: [%zd] ", ZSTR_LEN(stmt->query_string)); in PHP_METHOD()
1968 php_stream_write(out, ZSTR_VAL(stmt->query_string), ZSTR_LEN(stmt->query_string)); in PHP_METHOD()
1973 if (stmt->active_query_string != NULL && stmt->active_query_string != stmt->query_string) { in PHP_METHOD()
1975 php_stream_printf(out, "Sent SQL: [%zd] ", ZSTR_LEN(stmt->active_query_string)); in PHP_METHOD()
1976 php_stream_write(out, ZSTR_VAL(stmt->active_query_string), ZSTR_LEN(stmt->active_query_string)); in PHP_METHOD()
1981 stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0); in PHP_METHOD()
1983 if (stmt->bound_params) { in PHP_METHOD()
1986 ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) { in PHP_METHOD()
2051 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); in dbstmt_method_get() local
2053 if (!stmt->dbh) { in dbstmt_method_get()
2058 if (!stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT]) { in dbstmt_method_get()
2059 if (!pdo_hash_methods(Z_PDO_OBJECT_P(&stmt->database_object_handle), in dbstmt_method_get()
2061 || !stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT]) { in dbstmt_method_get()
2066 …if ((fbc = zend_hash_find_ptr(stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT], lc_method_n… in dbstmt_method_get()
2082 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); in dbstmt_get_gc() local
2083 *gc_data = &stmt->fetch.into; in dbstmt_get_gc()
2100 PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt) in php_pdo_free_statement() argument
2102 if (stmt->bound_params) { in php_pdo_free_statement()
2103 zend_hash_destroy(stmt->bound_params); in php_pdo_free_statement()
2104 FREE_HASHTABLE(stmt->bound_params); in php_pdo_free_statement()
2105 stmt->bound_params = NULL; in php_pdo_free_statement()
2107 if (stmt->bound_param_map) { in php_pdo_free_statement()
2108 zend_hash_destroy(stmt->bound_param_map); in php_pdo_free_statement()
2109 FREE_HASHTABLE(stmt->bound_param_map); in php_pdo_free_statement()
2110 stmt->bound_param_map = NULL; in php_pdo_free_statement()
2112 if (stmt->bound_columns) { in php_pdo_free_statement()
2113 zend_hash_destroy(stmt->bound_columns); in php_pdo_free_statement()
2114 FREE_HASHTABLE(stmt->bound_columns); in php_pdo_free_statement()
2115 stmt->bound_columns = NULL; in php_pdo_free_statement()
2118 if (stmt->methods && stmt->methods->dtor) { in php_pdo_free_statement()
2119 stmt->methods->dtor(stmt); in php_pdo_free_statement()
2121 if (stmt->active_query_string) { in php_pdo_free_statement()
2122 zend_string_release(stmt->active_query_string); in php_pdo_free_statement()
2124 if (stmt->query_string) { in php_pdo_free_statement()
2125 zend_string_release(stmt->query_string); in php_pdo_free_statement()
2128 pdo_stmt_reset_columns(stmt); in php_pdo_free_statement()
2130 if (!Z_ISUNDEF(stmt->fetch.into) && stmt->default_fetch_type == PDO_FETCH_INTO) { in php_pdo_free_statement()
2131 zval_ptr_dtor(&stmt->fetch.into); in php_pdo_free_statement()
2132 ZVAL_UNDEF(&stmt->fetch.into); in php_pdo_free_statement()
2135 do_fetch_opt_finish(stmt, 1); in php_pdo_free_statement()
2137 if (!Z_ISUNDEF(stmt->database_object_handle)) { in php_pdo_free_statement()
2138 zval_ptr_dtor(&stmt->database_object_handle); in php_pdo_free_statement()
2140 zend_object_std_dtor(&stmt->std); in php_pdo_free_statement()
2145 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(std); in pdo_dbstmt_free_storage() local
2146 php_pdo_free_statement(stmt); in pdo_dbstmt_free_storage()
2151 pdo_stmt_t *stmt; in pdo_dbstmt_new() local
2153 stmt = zend_object_alloc(sizeof(pdo_stmt_t), ce); in pdo_dbstmt_new()
2154 zend_object_std_init(&stmt->std, ce); in pdo_dbstmt_new()
2155 object_properties_init(&stmt->std, ce); in pdo_dbstmt_new()
2157 stmt->std.handlers = &pdo_dbstmt_object_handlers; in pdo_dbstmt_new()
2159 return &stmt->std; in pdo_dbstmt_new()
2215 pdo_stmt_t *stmt = Z_PDO_STMT_P(&I->iter.data); /* for PDO_HANDLE_STMT_ERR() */ in pdo_stmt_iter_move_forwards() local
2221 if (!do_fetch(stmt, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT, in pdo_stmt_iter_move_forwards()
2252 pdo_stmt_t *stmt = Z_PDO_STMT_P(object); in pdo_stmt_iter_get() local
2253 if (!stmt->dbh) { in pdo_stmt_iter_get()
2264 if (!do_fetch(stmt, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT, in pdo_stmt_iter_get()
2277 static zval *row_read_column_name(pdo_stmt_t *stmt, zend_string *name, zval *rv) in row_read_column_name() argument
2280 for (int colno = 0; colno < stmt->column_count; colno++) { in row_read_column_name()
2281 if (zend_string_equals(stmt->columns[colno].name, name)) { in row_read_column_name()
2282 fetch_value(stmt, rv, colno, NULL); in row_read_column_name()
2289 static zval *row_read_column_number(pdo_stmt_t *stmt, zend_long column, zval *rv) in row_read_column_number() argument
2291 if (column >= 0 && column < stmt->column_count) { in row_read_column_number()
2292 fetch_value(stmt, rv, column, NULL); in row_read_column_number()
2301 pdo_stmt_t *stmt = row->stmt; in row_prop_read() local
2304 ZEND_ASSERT(stmt); in row_prop_read()
2308 return zend_std_read_property(&stmt->std, name, type, cache_slot, rv); in row_prop_read()
2310 retval = row_read_column_number(stmt, lval, rv); in row_prop_read()
2312 retval = row_read_column_name(stmt, name, rv); in row_prop_read()
2338 pdo_stmt_t *stmt = row->stmt; in row_dim_read() local
2339 ZEND_ASSERT(stmt); in row_dim_read()
2342 if (Z_LVAL_P(offset) >= 0 && Z_LVAL_P(offset) < stmt->column_count) { in row_dim_read()
2343 fetch_value(stmt, rv, Z_LVAL_P(offset), NULL); in row_dim_read()
2375 pdo_stmt_t *stmt = row->stmt; in row_prop_exists() local
2379 ZEND_ASSERT(stmt); in row_prop_exists()
2382 retval = row_read_column_number(stmt, lval, &tmp_val); in row_prop_exists()
2384 retval = row_read_column_name(stmt, name, &tmp_val); in row_prop_exists()
2400 pdo_stmt_t *stmt = row->stmt; in row_dim_exists() local
2401 ZEND_ASSERT(stmt); in row_dim_exists()
2405 return column >= 0 && column < stmt->column_count; in row_dim_exists()
2409 zval *retval = row_read_column_number(stmt, column, &tmp_val); in row_dim_exists()
2441 pdo_stmt_t *stmt = row->stmt; in row_get_properties_for() local
2444 ZEND_ASSERT(stmt); in row_get_properties_for()
2450 if (!stmt->std.properties) { in row_get_properties_for()
2451 rebuild_object_properties(&stmt->std); in row_get_properties_for()
2453 props = zend_array_dup(stmt->std.properties); in row_get_properties_for()
2454 for (i = 0; i < stmt->column_count; i++) { in row_get_properties_for()
2455 if (zend_string_equals_literal(stmt->columns[i].name, "queryString")) { in row_get_properties_for()
2460 fetch_value(stmt, &val, i, NULL); in row_get_properties_for()
2462 zend_hash_update(props, stmt->columns[i].name, &val); in row_get_properties_for()
2486 if (row->stmt) { in pdo_row_free_storage()
2487 ZVAL_UNDEF(&row->stmt->lazy_object_ref); in pdo_row_free_storage()
2488 OBJ_RELEASE(&row->stmt->std); in pdo_row_free_storage()