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
62 static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_dtor() argument
64 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_dtor()
67 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_dtor()
71 pefree(S->einfo.errmsg, stmt->dbh->is_persistent); in pdo_mysql_stmt_dtor()
74 if (S->stmt) { in pdo_mysql_stmt_dtor()
75 mysql_stmt_close(S->stmt); in pdo_mysql_stmt_dtor()
76 S->stmt = NULL; in pdo_mysql_stmt_dtor()
91 if (!S->done && !Z_ISUNDEF(stmt->database_object_handle) in pdo_mysql_stmt_dtor()
92 && IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)]) in pdo_mysql_stmt_dtor()
93 && (!(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED))) { in pdo_mysql_stmt_dtor()
108 if (!S->stmt && S->current_data) { in pdo_mysql_stmt_dtor()
118 static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_set_row_count() argument
120 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_set_row_count()
121 zend_long row_count = (zend_long) mysql_stmt_affected_rows(S->stmt); in pdo_mysql_stmt_set_row_count()
123 stmt->row_count = row_count; in pdo_mysql_stmt_set_row_count()
128 static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_fill_stmt_from_result() argument
130 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_fill_stmt_from_result()
145 pdo_mysql_error_stmt(stmt); in pdo_mysql_fill_stmt_from_result()
149 stmt->row_count = (zend_long) mysql_num_rows(S->result); in pdo_mysql_fill_stmt_from_result()
150 php_pdo_stmt_set_column_count(stmt, (int) mysql_num_fields(S->result)); in pdo_mysql_fill_stmt_from_result()
154 stmt->row_count = (zend_long) row_count; in pdo_mysql_fill_stmt_from_result()
161 static bool pdo_mysql_stmt_after_execute_prepared(pdo_stmt_t *stmt) { in pdo_mysql_stmt_after_execute_prepared() argument
162 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_after_execute_prepared()
167 php_pdo_stmt_set_column_count(stmt, mysql_stmt_field_count(S->stmt)); in pdo_mysql_stmt_after_execute_prepared()
168 for (int i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_after_execute_prepared()
169 mysqlnd_stmt_bind_one_result(S->stmt, i); in pdo_mysql_stmt_after_execute_prepared()
172 S->result = mysqlnd_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_after_execute_prepared()
177 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_after_execute_prepared()
178 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_after_execute_prepared()
185 S->result = mysql_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_after_execute_prepared()
190 php_pdo_stmt_set_column_count(stmt, (int)mysql_num_fields(S->result)); in pdo_mysql_stmt_after_execute_prepared()
191 S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND)); in pdo_mysql_stmt_after_execute_prepared()
192 S->out_null = ecalloc(stmt->column_count, sizeof(my_bool)); in pdo_mysql_stmt_after_execute_prepared()
193 S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong)); in pdo_mysql_stmt_after_execute_prepared()
196 for (int i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_after_execute_prepared()
199 mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on); in pdo_mysql_stmt_after_execute_prepared()
244 if (mysql_stmt_bind_result(S->stmt, S->bound_result)) { in pdo_mysql_stmt_after_execute_prepared()
245 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_after_execute_prepared()
251 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_after_execute_prepared()
252 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_after_execute_prepared()
259 pdo_mysql_stmt_set_row_count(stmt); in pdo_mysql_stmt_after_execute_prepared()
264 static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_libmysql() argument
266 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_libmysql()
271 if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_libmysql()
275 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
276 if (mysql_stmt_errno(S->stmt) == 2057) { in pdo_mysql_stmt_execute_prepared_libmysql()
278 S->stmt = NULL; in pdo_mysql_stmt_execute_prepared_libmysql()
283 PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt)); in pdo_mysql_stmt_execute_prepared_libmysql()
289 static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_mysqlnd() argument
291 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_mysqlnd()
295 if (mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
296 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
300 PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt)); in pdo_mysql_stmt_execute_prepared_mysqlnd()
305 static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute() argument
307 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_execute()
310 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_execute()
316 if (S->stmt) { in pdo_mysql_stmt_execute()
317 PDO_DBG_RETURN(pdo_mysql_stmt_execute_prepared(stmt)); in pdo_mysql_stmt_execute()
320 if (mysql_real_query(H->server, stmt->active_query_string, stmt->active_query_stringlen) != 0) { in pdo_mysql_stmt_execute()
321 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute()
325 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_execute()
329 static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_next_rowset() argument
331 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_next_rowset()
334 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_next_rowset()
339 if (S->stmt) { in pdo_mysql_stmt_next_rowset()
340 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_next_rowset()
341 if (mysql_stmt_next_result(S->stmt)) { in pdo_mysql_stmt_next_rowset()
342 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
346 PDO_DBG_RETURN(pdo_mysql_stmt_after_execute_prepared(stmt)); in pdo_mysql_stmt_next_rowset()
349 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
353 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_next_rowset()
375 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
381 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_param_hook()
384 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_param_hook()
386 if (S->stmt && param->is_param) { in pdo_mysql_stmt_param_hook()
391 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_param_hook()
405 if (zend_hash_num_elements(stmt->bound_params) < (unsigned int) S->num_params) { in pdo_mysql_stmt_param_hook()
408 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_param_hook()
420 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_NULL); in pdo_mysql_stmt_param_hook()
454 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_mysql_stmt_param_hook()
474 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING); in pdo_mysql_stmt_param_hook()
478 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG); in pdo_mysql_stmt_param_hook()
480 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG); in pdo_mysql_stmt_param_hook()
485 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_TINY); in pdo_mysql_stmt_param_hook()
488 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_DOUBLE); in pdo_mysql_stmt_param_hook()
548 static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset)… in pdo_mysql_stmt_fetch() argument
550 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_fetch()
560 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_fetch()
561 if (S->stmt) { in pdo_mysql_stmt_fetch()
562 if (FAIL == mysqlnd_stmt_fetch(S->stmt, &fetched_anything) || fetched_anything == FALSE) { in pdo_mysql_stmt_fetch()
563 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_fetch()
570 if (!S->stmt && S->current_data) { in pdo_mysql_stmt_fetch()
576 if (S->stmt) { in pdo_mysql_stmt_fetch()
577 ret = mysql_stmt_fetch(S->stmt); in pdo_mysql_stmt_fetch()
587 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_fetch()
598 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_fetch()
608 static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */ in pdo_mysql_stmt_describe() argument
610 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_describe()
611 struct pdo_column_data *cols = stmt->columns; in pdo_mysql_stmt_describe()
615 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_describe()
620 if (colno >= stmt->column_count) { in pdo_mysql_stmt_describe()
631 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_describe()
647 if (S->stmt) { in pdo_mysql_stmt_describe()
659 static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, size_t *len, int *caller… in pdo_mysql_stmt_get_col() argument
661 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_get_col()
664 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_get_col()
670 if (!S->stmt) { in pdo_mysql_stmt_get_col()
676 if (colno >= stmt->column_count) { in pdo_mysql_stmt_get_col()
681 if (S->stmt) { in pdo_mysql_stmt_get_col()
682 Z_TRY_ADDREF(S->stmt->data->result_bind[colno].zv); in pdo_mysql_stmt_get_col()
683 *ptr = (char*)&S->stmt->data->result_bind[colno].zv; in pdo_mysql_stmt_get_col()
688 if (S->stmt) { in pdo_mysql_stmt_get_col()
697 strcpy(stmt->error_code, "01004"); /* truncated */ in pdo_mysql_stmt_get_col()
760 static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) /* {{{ */ in pdo_mysql_stmt_col_meta() argument
762 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_col_meta()
768 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_col_meta()
772 if (colno >= stmt->column_count) { in pdo_mysql_stmt_col_meta()
830 static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_cursor_closer() argument
832 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_cursor_closer()
835 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_cursor_closer()
839 if (S->stmt) { in pdo_mysql_stmt_cursor_closer()
840 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_cursor_closer()
846 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_cursor_closer()