Lines Matching refs:stmt
32 # define pdo_mysql_stmt_execute_prepared(stmt) pdo_mysql_stmt_execute_prepared_mysqlnd(stmt) argument
34 # define pdo_mysql_stmt_execute_prepared(stmt) pdo_mysql_stmt_execute_prepared_libmysql(stmt) argument
69 static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_dtor() argument
71 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_dtor()
74 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_dtor()
78 pefree(S->einfo.errmsg, stmt->dbh->is_persistent); in pdo_mysql_stmt_dtor()
81 if (S->stmt) { in pdo_mysql_stmt_dtor()
82 mysql_stmt_close(S->stmt); in pdo_mysql_stmt_dtor()
83 S->stmt = NULL; in pdo_mysql_stmt_dtor()
98 if (!S->done && !Z_ISUNDEF(stmt->database_object_handle) in pdo_mysql_stmt_dtor()
99 && IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)]) in pdo_mysql_stmt_dtor()
100 && (!(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED))) { in pdo_mysql_stmt_dtor()
119 static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_set_row_count() argument
121 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_set_row_count()
122 zend_long row_count = (zend_long) mysql_stmt_affected_rows(S->stmt); in pdo_mysql_stmt_set_row_count()
124 stmt->row_count = row_count; in pdo_mysql_stmt_set_row_count()
129 static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_fill_stmt_from_result() argument
131 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_fill_stmt_from_result()
146 pdo_mysql_error_stmt(stmt); in pdo_mysql_fill_stmt_from_result()
150 stmt->row_count = (zend_long) mysql_num_rows(S->result); in pdo_mysql_fill_stmt_from_result()
151 php_pdo_stmt_set_column_count(stmt, (int) mysql_num_fields(S->result)); in pdo_mysql_fill_stmt_from_result()
155 stmt->row_count = (zend_long) row_count; in pdo_mysql_fill_stmt_from_result()
162 static bool pdo_mysql_stmt_after_execute_prepared(pdo_stmt_t *stmt) { in pdo_mysql_stmt_after_execute_prepared() argument
163 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_after_execute_prepared()
168 php_pdo_stmt_set_column_count(stmt, mysql_stmt_field_count(S->stmt)); in pdo_mysql_stmt_after_execute_prepared()
169 for (int i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_after_execute_prepared()
170 mysqlnd_stmt_bind_one_result(S->stmt, i); in pdo_mysql_stmt_after_execute_prepared()
173 S->result = mysqlnd_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_after_execute_prepared()
178 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_after_execute_prepared()
179 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_after_execute_prepared()
186 S->result = mysql_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_after_execute_prepared()
191 php_pdo_stmt_set_column_count(stmt, (int)mysql_num_fields(S->result)); in pdo_mysql_stmt_after_execute_prepared()
192 S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND)); in pdo_mysql_stmt_after_execute_prepared()
193 S->out_null = ecalloc(stmt->column_count, sizeof(my_bool)); in pdo_mysql_stmt_after_execute_prepared()
194 S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong)); in pdo_mysql_stmt_after_execute_prepared()
197 for (int i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_after_execute_prepared()
200 mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on); in pdo_mysql_stmt_after_execute_prepared()
245 if (mysql_stmt_bind_result(S->stmt, S->bound_result)) { in pdo_mysql_stmt_after_execute_prepared()
246 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_after_execute_prepared()
252 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_after_execute_prepared()
253 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_after_execute_prepared()
260 pdo_mysql_stmt_set_row_count(stmt); in pdo_mysql_stmt_after_execute_prepared()
265 static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_libmysql() argument
267 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_libmysql()
272 if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_libmysql()
276 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
277 if (mysql_stmt_errno(S->stmt) == 2057) { in pdo_mysql_stmt_execute_prepared_libmysql()
279 S->stmt = NULL; in pdo_mysql_stmt_execute_prepared_libmysql()
284 PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt)); in pdo_mysql_stmt_execute_prepared_libmysql()
290 static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_mysqlnd() argument
292 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_mysqlnd()
296 if (mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
297 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
301 PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt)); in pdo_mysql_stmt_execute_prepared_mysqlnd()
306 static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute() argument
308 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_execute()
311 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_execute()
317 if (S->stmt) { in pdo_mysql_stmt_execute()
319 stmt->bound_params ? zend_hash_num_elements(stmt->bound_params) : 0; in pdo_mysql_stmt_execute()
323 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_execute()
327 PDO_DBG_RETURN(pdo_mysql_stmt_execute_prepared(stmt)); in pdo_mysql_stmt_execute()
330 …if (mysql_real_query(H->server, ZSTR_VAL(stmt->active_query_string), ZSTR_LEN(stmt->active_query_s… in pdo_mysql_stmt_execute()
331 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute()
335 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_execute()
339 static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_next_rowset() argument
341 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_next_rowset()
344 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_next_rowset()
349 if (S->stmt) { in pdo_mysql_stmt_next_rowset()
350 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_next_rowset()
351 if (mysql_stmt_next_result(S->stmt)) { in pdo_mysql_stmt_next_rowset()
352 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
356 PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt)); in pdo_mysql_stmt_next_rowset()
359 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
363 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_next_rowset()
385 static int pdo_mysql_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, enum pdo… in pdo_mysql_stmt_param_hook() argument
391 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_param_hook()
394 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_param_hook()
396 if (S->stmt && param->is_param) { in pdo_mysql_stmt_param_hook()
401 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_param_hook()
423 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_NULL); in pdo_mysql_stmt_param_hook()
457 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_mysql_stmt_param_hook()
477 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING); in pdo_mysql_stmt_param_hook()
481 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG); in pdo_mysql_stmt_param_hook()
483 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG); in pdo_mysql_stmt_param_hook()
488 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_TINY); in pdo_mysql_stmt_param_hook()
491 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_DOUBLE); in pdo_mysql_stmt_param_hook()
551 static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset)… in pdo_mysql_stmt_fetch() argument
553 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_fetch()
563 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_fetch()
564 if (S->stmt) { in pdo_mysql_stmt_fetch()
565 if (FAIL == mysqlnd_stmt_fetch(S->stmt, &fetched_anything) || !fetched_anything) { in pdo_mysql_stmt_fetch()
566 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_fetch()
575 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_fetch()
584 S->current_row = ecalloc(stmt->column_count, sizeof(zval)); in pdo_mysql_stmt_fetch()
586 for (unsigned i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_fetch()
594 if (S->stmt) { in pdo_mysql_stmt_fetch()
595 ret = mysql_stmt_fetch(S->stmt); in pdo_mysql_stmt_fetch()
605 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_fetch()
615 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_fetch()
626 static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */ in pdo_mysql_stmt_describe() argument
628 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_describe()
629 struct pdo_column_data *cols = stmt->columns; in pdo_mysql_stmt_describe()
633 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_describe()
638 if (colno >= stmt->column_count) { in pdo_mysql_stmt_describe()
649 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_describe()
669 pdo_stmt_t *stmt, int colno, zval *result, enum pdo_param_type *type) /* {{{ */ in pdo_mysql_stmt_get_col() argument
671 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_get_col()
674 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_get_col()
679 if (colno >= stmt->column_count) { in pdo_mysql_stmt_get_col()
684 if (S->stmt) { in pdo_mysql_stmt_get_col()
685 ZVAL_COPY(result, &S->stmt->data->result_bind[colno].zv); in pdo_mysql_stmt_get_col()
691 if (S->stmt) { in pdo_mysql_stmt_get_col()
699 strcpy(stmt->error_code, "01004"); /* truncated */ in pdo_mysql_stmt_get_col()
765 static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) /* {{{ */ in pdo_mysql_stmt_col_meta() argument
767 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_col_meta()
773 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_col_meta()
777 if (colno >= stmt->column_count) { in pdo_mysql_stmt_col_meta()
835 static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_cursor_closer() argument
837 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_cursor_closer()
840 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_cursor_closer()
844 if (S->stmt) { in pdo_mysql_stmt_cursor_closer()
845 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_cursor_closer()
851 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_cursor_closer()