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()
221 GC_ADDREF(&stmt->std); in get_lazy_object()
224 ZVAL_COPY(return_value, &stmt->lazy_object_ref); in get_lazy_object()
233 if (param->stmt->methods->param_hook) { in param_dtor()
234 param->stmt->methods->param_hook(param->stmt, param, PDO_PARAM_EVT_FREE); in param_dtor()
252 static bool really_register_bound_param(struct pdo_bound_param_data *param, pdo_stmt_t *stmt, bool … in really_register_bound_param() argument
258 hash = is_param ? stmt->bound_params : stmt->bound_columns; in really_register_bound_param()
265 stmt->bound_params = hash; in really_register_bound_param()
267 stmt->bound_columns = hash; in really_register_bound_param()
287 param->stmt = stmt; in really_register_bound_param()
294 if (!is_param && param->name && stmt->columns) { in really_register_bound_param()
298 for (i = 0; i < stmt->column_count; i++) { in really_register_bound_param()
299 if (zend_string_equals(stmt->columns[i].name, param->name)) { in really_register_bound_param()
312 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", tmp); in really_register_bound_param()
328 if (is_param && !rewrite_name_to_position(stmt, param)) { in really_register_bound_param()
340 if (stmt->methods->param_hook) { in really_register_bound_param()
341 if (!stmt->methods->param_hook(stmt, param, PDO_PARAM_EVT_NORMALIZE)) { in really_register_bound_param()
366 if (stmt->methods->param_hook) { in really_register_bound_param()
367 if (!stmt->methods->param_hook(stmt, pparam, PDO_PARAM_EVT_ALLOC)) { in really_register_bound_param()
405 if (stmt->bound_params) { in PHP_METHOD()
406 zend_hash_destroy(stmt->bound_params); in PHP_METHOD()
407 FREE_HASHTABLE(stmt->bound_params); in PHP_METHOD()
408 stmt->bound_params = NULL; in PHP_METHOD()
427 if (!really_register_bound_param(&param, stmt, 1)) { in PHP_METHOD()
436 if (PDO_PLACEHOLDER_NONE == stmt->supports_placeholders) { in PHP_METHOD()
443 if (stmt->active_query_string) { in PHP_METHOD()
444 zend_string_release(stmt->active_query_string); in PHP_METHOD()
445 stmt->active_query_string = NULL; in PHP_METHOD()
448 ret = pdo_parse_params(stmt, stmt->query_string, &stmt->active_query_string); in PHP_METHOD()
452 stmt->active_query_string = zend_string_copy(stmt->query_string); in PHP_METHOD()
458 } else if (!dispatch_param_event(stmt, PDO_PARAM_EVT_EXEC_PRE)) { in PHP_METHOD()
462 if (stmt->methods->executer(stmt)) { in PHP_METHOD()
463 if (!stmt->executed) { in PHP_METHOD()
466 if (stmt->dbh->alloc_own_columns && !stmt->columns) { in PHP_METHOD()
469 ret = pdo_stmt_describe_columns(stmt); in PHP_METHOD()
472 stmt->executed = 1; in PHP_METHOD()
475 if (ret && !dispatch_param_event(stmt, PDO_PARAM_EVT_EXEC_POST)) { in PHP_METHOD()
487 static inline void fetch_value(pdo_stmt_t *stmt, zval *dest, int colno, enum pdo_param_type *type_o… in fetch_value() argument
495 if (colno >= stmt->column_count) { in fetch_value()
502 stmt->methods->get_col(stmt, colno, dest, type_override); in fetch_value()
505 && stmt->dbh->oracle_nulls == PDO_NULL_EMPTY_STRING) { in fetch_value()
512 if (stmt->dbh->stringify) { in fetch_value()
561 if (Z_TYPE_P(dest) == IS_NULL && stmt->dbh->oracle_nulls == PDO_NULL_TO_STRING) { in fetch_value()
567 static bool do_fetch_common(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset) /* … in do_fetch_common() argument
569 if (!stmt->executed) { in do_fetch_common()
573 if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_PRE)) { in do_fetch_common()
577 if (!stmt->methods->fetcher(stmt, ori, offset)) { in do_fetch_common()
582 if (!stmt->columns && !pdo_stmt_describe_columns(stmt)) { in do_fetch_common()
586 if (!dispatch_param_event(stmt, PDO_PARAM_EVT_FETCH_POST)) { in do_fetch_common()
590 if (stmt->bound_columns) { in do_fetch_common()
594 ZEND_HASH_FOREACH_PTR(stmt->bound_columns, param) { in do_fetch_common()
604 fetch_value(stmt, Z_REFVAL(param->parameter), param->paramno, &param->param_type); in do_fetch_common()
618 static bool do_fetch_class_prepare(pdo_stmt_t *stmt) /* {{{ */ in do_fetch_class_prepare() argument
620 zend_class_entry *ce = stmt->fetch.cls.ce; in do_fetch_class_prepare()
621 zend_fcall_info *fci = &stmt->fetch.cls.fci; in do_fetch_class_prepare()
622 zend_fcall_info_cache *fcc = &stmt->fetch.cls.fcc; in do_fetch_class_prepare()
627 stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; in do_fetch_class_prepare()
633 fci->retval = &stmt->fetch.cls.retval; in do_fetch_class_prepare()
637 zend_fcall_info_args_ex(fci, ce->constructor, &stmt->fetch.cls.ctor_args); in do_fetch_class_prepare()
642 } else if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) { in do_fetch_class_prepare()
651 static bool make_callable_ex(pdo_stmt_t *stmt, zval *callable, zend_fcall_info * fci, zend_fcall_in… in make_callable_ex() argument
676 static bool do_fetch_func_prepare(pdo_stmt_t *stmt) /* {{{ */ in do_fetch_func_prepare() argument
678 zend_fcall_info *fci = &stmt->fetch.cls.fci; in do_fetch_func_prepare()
679 zend_fcall_info_cache *fcc = &stmt->fetch.cls.fcc; in do_fetch_func_prepare()
681 if (!make_callable_ex(stmt, &stmt->fetch.func.function, fci, fcc, stmt->column_count)) { in do_fetch_func_prepare()
684 stmt->fetch.func.values = safe_emalloc(sizeof(zval), stmt->column_count, 0); in do_fetch_func_prepare()
690 static void do_fetch_opt_finish(pdo_stmt_t *stmt, int free_ctor_agrs) /* {{{ */ in do_fetch_opt_finish() argument
693 if (stmt->fetch.cls.fci.size && stmt->fetch.cls.fci.params) { in do_fetch_opt_finish()
694 if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args)) { in do_fetch_opt_finish()
696 zend_fcall_info_args_clear(&stmt->fetch.cls.fci, 1); in do_fetch_opt_finish()
698 efree(stmt->fetch.cls.fci.params); in do_fetch_opt_finish()
700 stmt->fetch.cls.fci.params = NULL; in do_fetch_opt_finish()
703 stmt->fetch.cls.fci.size = 0; in do_fetch_opt_finish()
704 if (!Z_ISUNDEF(stmt->fetch.cls.ctor_args) && free_ctor_agrs) { in do_fetch_opt_finish()
705 zval_ptr_dtor(&stmt->fetch.cls.ctor_args); in do_fetch_opt_finish()
706 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in do_fetch_opt_finish()
707 stmt->fetch.cls.fci.param_count = 0; in do_fetch_opt_finish()
709 if (stmt->fetch.func.values) { in do_fetch_opt_finish()
710 efree(stmt->fetch.func.values); in do_fetch_opt_finish()
711 stmt->fetch.func.values = NULL; in do_fetch_opt_finish()
718 static bool do_fetch(pdo_stmt_t *stmt, zval *return_value, enum pdo_fetch_type how, enum pdo_fetch_… in do_fetch() argument
727 how = stmt->default_fetch_type; in do_fetch()
732 if (!do_fetch_common(stmt, ori, offset)) { in do_fetch()
741 if ((flags & PDO_FETCH_GROUP) && stmt->fetch.column == -1) { in do_fetch()
744 colno = stmt->fetch.column; in do_fetch()
748 get_lazy_object(stmt, return_value); in do_fetch()
761 array_init_size(return_value, stmt->column_count); in do_fetch()
768 if (stmt->column_count != 2) { in do_fetch()
770 …pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "PDO::FETCH_KEY_PAIR fetch mode requires the result… in do_fetch()
784 if (colno >= stmt->column_count) { in do_fetch()
789 if (flags == PDO_FETCH_GROUP && stmt->fetch.column == -1) { in do_fetch()
790 fetch_value(stmt, return_value, 1, NULL); in do_fetch()
792 fetch_value(stmt, return_value, 0, NULL); in do_fetch()
794 fetch_value(stmt, return_value, colno, NULL); in do_fetch()
810 old_ce = stmt->fetch.cls.ce; in do_fetch()
811 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in do_fetch()
812 old_arg_count = stmt->fetch.cls.fci.param_count; in do_fetch()
813 do_fetch_opt_finish(stmt, 0); in do_fetch()
815 fetch_value(stmt, &val, i++, NULL); in do_fetch()
821 stmt->fetch.cls.ce = ZEND_STANDARD_CLASS_DEF_PTR; in do_fetch()
823 stmt->fetch.cls.ce = cep; in do_fetch()
827 do_fetch_class_prepare(stmt); in do_fetch()
830 ce = stmt->fetch.cls.ce; in do_fetch()
834 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch class specified"); in do_fetch()
841 if (!stmt->fetch.cls.fci.size) { in do_fetch()
842 if (!do_fetch_class_prepare(stmt)) { in do_fetch()
848 stmt->fetch.cls.fci.object = Z_OBJ_P(return_value); in do_fetch()
849 stmt->fetch.cls.fcc.object = Z_OBJ_P(return_value); in do_fetch()
850 if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc) == FAILURE) { in do_fetch()
852 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor"); in do_fetch()
855 if (!Z_ISUNDEF(stmt->fetch.cls.retval)) { in do_fetch()
856 zval_ptr_dtor(&stmt->fetch.cls.retval); in do_fetch()
857 ZVAL_UNDEF(&stmt->fetch.cls.retval); in do_fetch()
866 if (Z_ISUNDEF(stmt->fetch.into)) { in do_fetch()
868 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch-into object specified."); in do_fetch()
873 ZVAL_COPY(return_value, &stmt->fetch.into); in do_fetch()
882 if (Z_ISUNDEF(stmt->fetch.func.function)) { in do_fetch()
884 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "No fetch function specified"); in do_fetch()
887 if (!stmt->fetch.func.fci.size) { in do_fetch()
888 if (!do_fetch_func_prepare(stmt)) in do_fetch()
898 if (flags == PDO_FETCH_GROUP && how == PDO_FETCH_COLUMN && stmt->fetch.column > 0) { in do_fetch()
899 fetch_value(stmt, &grp_val, colno, NULL); in do_fetch()
901 fetch_value(stmt, &grp_val, i, NULL); in do_fetch()
905 i = stmt->column_count; /* no more data to fetch */ in do_fetch()
911 for (idx = 0; i < stmt->column_count; i++, idx++) { in do_fetch()
913 fetch_value(stmt, &val, i, NULL); in do_fetch()
917 zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
923 fetch_value(stmt, &tmp, ++i, NULL); in do_fetch()
938 zend_symtable_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
948 if ((curr_val = zend_hash_find(Z_ARRVAL_P(return_value), stmt->columns[i].name))) { in do_fetch()
973 zend_hash_update(Z_ARRVAL_P(return_value), stmt->columns[i].name, &val); in do_fetch()
985 stmt->columns[i].name, in do_fetch()
993 stmt->columns[i].name, in do_fetch()
999 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class"); in do_fetch()
1003 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "cannot unserialize class"); in do_fetch()
1014 ZVAL_COPY_VALUE(&stmt->fetch.func.values[idx], &val); in do_fetch()
1015 ZVAL_COPY_VALUE(&stmt->fetch.cls.fci.params[idx], &stmt->fetch.func.values[idx]); in do_fetch()
1028 stmt->fetch.cls.fci.object = Z_OBJ_P(return_value); in do_fetch()
1029 stmt->fetch.cls.fcc.object = Z_OBJ_P(return_value); in do_fetch()
1030 if (zend_call_function(&stmt->fetch.cls.fci, &stmt->fetch.cls.fcc) == FAILURE) { in do_fetch()
1032 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call class constructor"); in do_fetch()
1035 if (!Z_ISUNDEF(stmt->fetch.cls.retval)) { in do_fetch()
1036 zval_ptr_dtor(&stmt->fetch.cls.retval); in do_fetch()
1041 do_fetch_opt_finish(stmt, 0); in do_fetch()
1042 stmt->fetch.cls.ce = old_ce; in do_fetch()
1043 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in do_fetch()
1044 stmt->fetch.cls.fci.param_count = old_arg_count; in do_fetch()
1049 stmt->fetch.func.fci.param_count = idx; in do_fetch()
1050 stmt->fetch.func.fci.retval = &retval; in do_fetch()
1051 if (zend_call_function(&stmt->fetch.func.fci, &stmt->fetch.func.fcc) == FAILURE) { in do_fetch()
1053 pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "could not call user-supplied function"); in do_fetch()
1064 zval_ptr_dtor(&stmt->fetch.func.values[idx]); in do_fetch()
1092 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
1104 flags = stmt->default_fetch_type & PDO_FETCH_FLAGS; in pdo_stmt_verify_mode()
1105 mode = stmt->default_fetch_type & ~PDO_FETCH_FLAGS; in pdo_stmt_verify_mode()
1163 if (!pdo_stmt_verify_mode(stmt, how, 1, false)) { in PHP_METHOD()
1167 if (!do_fetch(stmt, return_value, how, ori, off, NULL)) { in PHP_METHOD()
1191 old_ce = stmt->fetch.cls.ce; in PHP_METHOD()
1192 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in PHP_METHOD()
1193 old_arg_count = stmt->fetch.cls.fci.param_count; in PHP_METHOD()
1195 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1198 ZVAL_ARR(&stmt->fetch.cls.ctor_args, zend_array_dup(Z_ARRVAL_P(ctor_args))); in PHP_METHOD()
1200 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in PHP_METHOD()
1203 stmt->fetch.cls.ce = ce; in PHP_METHOD()
1205 stmt->fetch.cls.ce = zend_standard_class_def; in PHP_METHOD()
1208 if (!do_fetch(stmt, return_value, PDO_FETCH_CLASS, PDO_FETCH_ORI_NEXT, /* offset */ 0, NULL)) { in PHP_METHOD()
1212 do_fetch_opt_finish(stmt, 1); in PHP_METHOD()
1214 stmt->fetch.cls.ce = old_ce; in PHP_METHOD()
1215 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in PHP_METHOD()
1216 stmt->fetch.cls.fci.param_count = old_arg_count; in PHP_METHOD()
1233 if (!do_fetch_common(stmt, PDO_FETCH_ORI_NEXT, 0)) { in PHP_METHOD()
1238 fetch_value(stmt, return_value, col_n, NULL); in PHP_METHOD()
1261 if (!pdo_stmt_verify_mode(stmt, how, 1, true)) { in PHP_METHOD()
1265 old_ce = stmt->fetch.cls.ce; in PHP_METHOD()
1266 ZVAL_COPY_VALUE(&old_ctor_args, &stmt->fetch.cls.ctor_args); in PHP_METHOD()
1267 old_arg_count = stmt->fetch.cls.fci.param_count; in PHP_METHOD()
1269 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1281 stmt->fetch.cls.ce = zend_fetch_class(Z_STR_P(arg2), ZEND_FETCH_CLASS_AUTO); in PHP_METHOD()
1282 if (!stmt->fetch.cls.ce) { in PHP_METHOD()
1287 stmt->fetch.cls.ce = zend_standard_class_def; in PHP_METHOD()
1291 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, ctor_args); /* we're not going to free these */ in PHP_METHOD()
1293 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in PHP_METHOD()
1296 do_fetch_class_prepare(stmt); in PHP_METHOD()
1313 ZVAL_COPY_VALUE(&stmt->fetch.func.function, arg2); in PHP_METHOD()
1314 if (do_fetch_func_prepare(stmt) == false) { in PHP_METHOD()
1338 stmt->fetch.column = Z_LVAL_P(arg2); in PHP_METHOD()
1340 stmt->fetch.column = how & PDO_FETCH_GROUP ? -1 : 0; in PHP_METHOD()
1358 flags |= stmt->default_fetch_type & PDO_FETCH_FLAGS; in PHP_METHOD()
1359 how |= stmt->default_fetch_type & ~PDO_FETCH_FLAGS; in PHP_METHOD()
1364 (how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR) in PHP_METHOD()
1369 if (!do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, return_all)) { in PHP_METHOD()
1375 (how == PDO_FETCH_USE_DEFAULT && stmt->default_fetch_type == PDO_FETCH_KEY_PAIR) in PHP_METHOD()
1377 while (do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, return_all)); in PHP_METHOD()
1382 } while (do_fetch(stmt, &data, how | flags, PDO_FETCH_ORI_NEXT, /* offset */ 0, NULL)); in PHP_METHOD()
1386 do_fetch_opt_finish(stmt, 0); in PHP_METHOD()
1389 stmt->fetch.cls.ce = old_ce; in PHP_METHOD()
1390 ZVAL_COPY_VALUE(&stmt->fetch.cls.ctor_args, &old_ctor_args); in PHP_METHOD()
1391 stmt->fetch.cls.fci.param_count = old_arg_count; in PHP_METHOD()
1442 if (!really_register_bound_param(&param, stmt, is_param)) { in register_bound_param()
1486 if (!really_register_bound_param(&param, stmt, TRUE)) { in PHP_METHOD()
1517 RETURN_LONG(stmt->row_count); in PHP_METHOD()
1527 if (stmt->error_code[0] == '\0') { in PHP_METHOD()
1531 RETURN_STRING(stmt->error_code); in PHP_METHOD()
1546 add_next_index_string(return_value, stmt->error_code); in PHP_METHOD()
1548 if (strncmp(stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) { in PHP_METHOD()
1549 if (stmt->dbh->methods->fetch_err) { in PHP_METHOD()
1550 stmt->dbh->methods->fetch_err(stmt->dbh, stmt, return_value); in PHP_METHOD()
1581 if (!stmt->methods->set_attribute) { in PHP_METHOD()
1582 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "This driver doesn't support setting attributes"); in PHP_METHOD()
1587 if (stmt->methods->set_attribute(stmt, attr, value)) { in PHP_METHOD()
1599 static bool generic_stmt_attr_get(pdo_stmt_t *stmt, zval *return_value, zend_long attr) in generic_stmt_attr_get() argument
1603 RETVAL_BOOL(stmt->supports_placeholders == PDO_PLACEHOLDER_NONE); in generic_stmt_attr_get()
1618 if (!stmt->methods->get_attribute) { in PHP_METHOD()
1619 if (!generic_stmt_attr_get(stmt, return_value, attr)) { in PHP_METHOD()
1620 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", in PHP_METHOD()
1628 switch (stmt->methods->get_attribute(stmt, attr, return_value)) { in PHP_METHOD()
1634 if (!generic_stmt_attr_get(stmt, return_value, attr)) { in PHP_METHOD()
1636 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", in PHP_METHOD()
1654 RETURN_LONG(stmt->column_count); in PHP_METHOD()
1674 if (!stmt->methods->get_column_meta) { in PHP_METHOD()
1675 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver doesn't support meta data"); in PHP_METHOD()
1680 if (FAILURE == stmt->methods->get_column_meta(stmt, colno, return_value)) { in PHP_METHOD()
1686 col = &stmt->columns[colno]; in PHP_METHOD()
1695 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
1703 switch (stmt->default_fetch_type) { in pdo_stmt_setup_fetch_mode()
1705 if (!Z_ISUNDEF(stmt->fetch.into)) { in pdo_stmt_setup_fetch_mode()
1706 zval_ptr_dtor(&stmt->fetch.into); in pdo_stmt_setup_fetch_mode()
1707 ZVAL_UNDEF(&stmt->fetch.into); in pdo_stmt_setup_fetch_mode()
1714 stmt->default_fetch_type = PDO_FETCH_BOTH; in pdo_stmt_setup_fetch_mode()
1718 if (!pdo_stmt_verify_mode(stmt, mode, mode_arg_num, false)) { in pdo_stmt_setup_fetch_mode()
1757 stmt->fetch.column = Z_LVAL(args[0]); in pdo_stmt_setup_fetch_mode()
1763 ZVAL_UNDEF(&stmt->fetch.cls.ctor_args); in pdo_stmt_setup_fetch_mode()
1773 stmt->fetch.cls.ce = NULL; in pdo_stmt_setup_fetch_mode()
1812 stmt->fetch.cls.ce = cep; in pdo_stmt_setup_fetch_mode()
1816 ZVAL_ARR(&stmt->fetch.cls.ctor_args, zend_array_dup(constructor_args)); in pdo_stmt_setup_fetch_mode()
1820 do_fetch_class_prepare(stmt); in pdo_stmt_setup_fetch_mode()
1836 ZVAL_COPY(&stmt->fetch.into, &args[0]); in pdo_stmt_setup_fetch_mode()
1843 stmt->default_fetch_type = mode; in pdo_stmt_setup_fetch_mode()
1860 do_fetch_opt_finish(stmt, 1); in PHP_METHOD()
1862 if (!pdo_stmt_setup_fetch_mode(stmt, fetch_mode, 1, args, num_args)) { in PHP_METHOD()
1873 static bool pdo_stmt_do_next_rowset(pdo_stmt_t *stmt) in pdo_stmt_do_next_rowset() argument
1875 pdo_stmt_reset_columns(stmt); in pdo_stmt_do_next_rowset()
1877 if (!stmt->methods->next_rowset(stmt)) { in pdo_stmt_do_next_rowset()
1879 stmt->executed = 0; in pdo_stmt_do_next_rowset()
1883 pdo_stmt_describe_columns(stmt); in pdo_stmt_do_next_rowset()
1893 if (!stmt->methods->next_rowset) { in PHP_METHOD()
1894 pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver does not support multiple rowsets"); in PHP_METHOD()
1900 if (!pdo_stmt_do_next_rowset(stmt)) { in PHP_METHOD()
1915 if (!stmt->methods->cursor_closer) { in PHP_METHOD()
1918 while (stmt->methods->fetcher(stmt, PDO_FETCH_ORI_NEXT, 0)) in PHP_METHOD()
1920 if (!stmt->methods->next_rowset) { in PHP_METHOD()
1924 if (!pdo_stmt_do_next_rowset(stmt)) { in PHP_METHOD()
1929 stmt->executed = 0; in PHP_METHOD()
1935 if (!stmt->methods->cursor_closer(stmt)) { in PHP_METHOD()
1939 stmt->executed = 0; in PHP_METHOD()
1961 php_stream_printf(out, "SQL: [%zd] ", ZSTR_LEN(stmt->query_string)); in PHP_METHOD()
1962 php_stream_write(out, ZSTR_VAL(stmt->query_string), ZSTR_LEN(stmt->query_string)); in PHP_METHOD()
1967 if (stmt->active_query_string != NULL && stmt->active_query_string != stmt->query_string) { in PHP_METHOD()
1969 php_stream_printf(out, "Sent SQL: [%zd] ", ZSTR_LEN(stmt->active_query_string)); in PHP_METHOD()
1970 php_stream_write(out, ZSTR_VAL(stmt->active_query_string), ZSTR_LEN(stmt->active_query_string)); in PHP_METHOD()
1975 stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0); in PHP_METHOD()
1977 if (stmt->bound_params) { in PHP_METHOD()
1980 ZEND_HASH_FOREACH_KEY_PTR(stmt->bound_params, num, key, param) { in PHP_METHOD()
2045 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); in dbstmt_method_get() local
2047 if (!stmt->dbh) { in dbstmt_method_get()
2052 if (!stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT]) { in dbstmt_method_get()
2053 if (!pdo_hash_methods(Z_PDO_OBJECT_P(&stmt->database_object_handle), in dbstmt_method_get()
2055 || !stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT]) { in dbstmt_method_get()
2060 …if ((fbc = zend_hash_find_ptr(stmt->dbh->cls_methods[PDO_DBH_DRIVER_METHOD_KIND_STMT], lc_method_n… in dbstmt_method_get()
2076 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(object); in dbstmt_get_gc() local
2077 *gc_data = &stmt->fetch.into; in dbstmt_get_gc()
2094 PDO_API void php_pdo_free_statement(pdo_stmt_t *stmt) in php_pdo_free_statement() argument
2096 if (stmt->bound_params) { in php_pdo_free_statement()
2097 zend_hash_destroy(stmt->bound_params); in php_pdo_free_statement()
2098 FREE_HASHTABLE(stmt->bound_params); in php_pdo_free_statement()
2099 stmt->bound_params = NULL; in php_pdo_free_statement()
2101 if (stmt->bound_param_map) { in php_pdo_free_statement()
2102 zend_hash_destroy(stmt->bound_param_map); in php_pdo_free_statement()
2103 FREE_HASHTABLE(stmt->bound_param_map); in php_pdo_free_statement()
2104 stmt->bound_param_map = NULL; in php_pdo_free_statement()
2106 if (stmt->bound_columns) { in php_pdo_free_statement()
2107 zend_hash_destroy(stmt->bound_columns); in php_pdo_free_statement()
2108 FREE_HASHTABLE(stmt->bound_columns); in php_pdo_free_statement()
2109 stmt->bound_columns = NULL; in php_pdo_free_statement()
2112 if (stmt->methods && stmt->methods->dtor) { in php_pdo_free_statement()
2113 stmt->methods->dtor(stmt); in php_pdo_free_statement()
2115 if (stmt->active_query_string) { in php_pdo_free_statement()
2116 zend_string_release(stmt->active_query_string); in php_pdo_free_statement()
2118 if (stmt->query_string) { in php_pdo_free_statement()
2119 zend_string_release(stmt->query_string); in php_pdo_free_statement()
2122 pdo_stmt_reset_columns(stmt); in php_pdo_free_statement()
2124 if (!Z_ISUNDEF(stmt->fetch.into) && stmt->default_fetch_type == PDO_FETCH_INTO) { in php_pdo_free_statement()
2125 zval_ptr_dtor(&stmt->fetch.into); in php_pdo_free_statement()
2126 ZVAL_UNDEF(&stmt->fetch.into); in php_pdo_free_statement()
2129 do_fetch_opt_finish(stmt, 1); in php_pdo_free_statement()
2131 if (!Z_ISUNDEF(stmt->database_object_handle)) { in php_pdo_free_statement()
2132 zval_ptr_dtor(&stmt->database_object_handle); in php_pdo_free_statement()
2134 zend_object_std_dtor(&stmt->std); in php_pdo_free_statement()
2139 pdo_stmt_t *stmt = php_pdo_stmt_fetch_object(std); in pdo_dbstmt_free_storage() local
2140 php_pdo_free_statement(stmt); in pdo_dbstmt_free_storage()
2145 pdo_stmt_t *stmt; in pdo_dbstmt_new() local
2147 stmt = zend_object_alloc(sizeof(pdo_stmt_t), ce); in pdo_dbstmt_new()
2148 zend_object_std_init(&stmt->std, ce); in pdo_dbstmt_new()
2149 object_properties_init(&stmt->std, ce); in pdo_dbstmt_new()
2151 return &stmt->std; in pdo_dbstmt_new()
2207 pdo_stmt_t *stmt = Z_PDO_STMT_P(&I->iter.data); /* for PDO_HANDLE_STMT_ERR() */ in pdo_stmt_iter_move_forwards() local
2213 if (!do_fetch(stmt, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT, in pdo_stmt_iter_move_forwards()
2244 pdo_stmt_t *stmt = Z_PDO_STMT_P(object); in pdo_stmt_iter_get() local
2245 if (!stmt->dbh) { in pdo_stmt_iter_get()
2256 if (!do_fetch(stmt, &I->fetch_ahead, PDO_FETCH_USE_DEFAULT, in pdo_stmt_iter_get()
2269 static zval *row_read_column_name(pdo_stmt_t *stmt, zend_string *name, zval *rv) in row_read_column_name() argument
2272 for (int colno = 0; colno < stmt->column_count; colno++) { in row_read_column_name()
2273 if (zend_string_equals(stmt->columns[colno].name, name)) { in row_read_column_name()
2274 fetch_value(stmt, rv, colno, NULL); in row_read_column_name()
2281 static zval *row_read_column_number(pdo_stmt_t *stmt, zend_long column, zval *rv) in row_read_column_number() argument
2283 if (column >= 0 && column < stmt->column_count) { in row_read_column_number()
2284 fetch_value(stmt, rv, column, NULL); in row_read_column_number()
2293 pdo_stmt_t *stmt = row->stmt; in row_prop_read() local
2296 ZEND_ASSERT(stmt); in row_prop_read()
2300 return zend_std_read_property(&stmt->std, name, type, cache_slot, rv); in row_prop_read()
2302 retval = row_read_column_number(stmt, lval, rv); in row_prop_read()
2304 retval = row_read_column_name(stmt, name, rv); in row_prop_read()
2330 pdo_stmt_t *stmt = row->stmt; in row_dim_read() local
2331 ZEND_ASSERT(stmt); in row_dim_read()
2334 if (Z_LVAL_P(offset) >= 0 && Z_LVAL_P(offset) < stmt->column_count) { in row_dim_read()
2335 fetch_value(stmt, rv, Z_LVAL_P(offset), NULL); in row_dim_read()
2368 pdo_stmt_t *stmt = row->stmt; in row_prop_exists() local
2372 ZEND_ASSERT(stmt); in row_prop_exists()
2375 retval = row_read_column_number(stmt, lval, &tmp_val); in row_prop_exists()
2377 retval = row_read_column_name(stmt, name, &tmp_val); in row_prop_exists()
2396 pdo_stmt_t *stmt = row->stmt; in row_dim_exists() local
2397 ZEND_ASSERT(stmt); in row_dim_exists()
2401 return column >= 0 && column < stmt->column_count; in row_dim_exists()
2405 zval *retval = row_read_column_number(stmt, column, &tmp_val); in row_dim_exists()
2437 pdo_stmt_t *stmt = row->stmt; in row_get_properties_for() local
2440 ZEND_ASSERT(stmt); in row_get_properties_for()
2446 props = zend_array_dup(zend_std_get_properties_ex(&stmt->std)); in row_get_properties_for()
2447 for (i = 0; i < stmt->column_count; i++) { in row_get_properties_for()
2448 if (zend_string_equals_literal(stmt->columns[i].name, "queryString")) { in row_get_properties_for()
2453 fetch_value(stmt, &val, i, NULL); in row_get_properties_for()
2455 zend_hash_update(props, stmt->columns[i].name, &val); in row_get_properties_for()
2479 if (row->stmt) { in pdo_row_free_storage()
2480 ZVAL_UNDEF(&row->stmt->lazy_object_ref); in pdo_row_free_storage()
2481 OBJ_RELEASE(&row->stmt->std); in pdo_row_free_storage()