Lines Matching refs:stmt
36 # define pdo_mysql_stmt_execute_prepared(stmt) pdo_mysql_stmt_execute_prepared_mysqlnd(stmt) argument
38 # define pdo_mysql_stmt_close(stmt) mysqlnd_stmt_close(stmt, 0) argument
40 # define pdo_mysql_stmt_execute_prepared(stmt) pdo_mysql_stmt_execute_prepared_libmysql(stmt) argument
42 # define pdo_mysql_stmt_close(stmt) mysql_stmt_close(stmt) argument
47 static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_dtor() argument
49 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_dtor()
52 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_dtor()
59 pefree(S->einfo.errmsg, stmt->dbh->is_persistent); in pdo_mysql_stmt_dtor()
62 if (S->stmt) { in pdo_mysql_stmt_dtor()
63 pdo_mysql_stmt_close(S->stmt); in pdo_mysql_stmt_dtor()
64 S->stmt = NULL; in pdo_mysql_stmt_dtor()
81 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_dtor()
91 if (!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 && (!(GC_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
121 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_set_row_count()
122 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 stmt->column_count = (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()
163 static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_libmysql() argument
165 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_libmysql()
171 if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_libmysql()
175 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
176 if (mysql_stmt_errno(S->stmt) == 2057) { in pdo_mysql_stmt_execute_prepared_libmysql()
178 S->stmt = NULL; in pdo_mysql_stmt_execute_prepared_libmysql()
187 S->result = mysql_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
193 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_execute_prepared_libmysql()
201 stmt->column_count = (int)mysql_num_fields(S->result); in pdo_mysql_stmt_execute_prepared_libmysql()
202 S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND)); in pdo_mysql_stmt_execute_prepared_libmysql()
203 S->out_null = ecalloc(stmt->column_count, sizeof(my_bool)); in pdo_mysql_stmt_execute_prepared_libmysql()
204 S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong)); in pdo_mysql_stmt_execute_prepared_libmysql()
207 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_execute_prepared_libmysql()
210 mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on); in pdo_mysql_stmt_execute_prepared_libmysql()
255 if (mysql_stmt_bind_result(S->stmt, S->bound_result)) { in pdo_mysql_stmt_execute_prepared_libmysql()
256 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
262 mysql_stmt_store_result(S->stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
267 pdo_mysql_stmt_set_row_count(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
274 static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_mysqlnd() argument
276 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_mysqlnd()
282 if (mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
283 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
294 stmt->column_count = mysql_stmt_field_count(S->stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
295 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
296 mysqlnd_stmt_bind_one_result(S->stmt, i); in pdo_mysql_stmt_execute_prepared_mysqlnd()
299 S->result = mysqlnd_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
304 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
310 pdo_mysql_stmt_set_row_count(stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
316 static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute() argument
318 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_execute()
321 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_execute()
323 if (S->stmt) { in pdo_mysql_stmt_execute()
324 PDO_DBG_RETURN(pdo_mysql_stmt_execute_prepared(stmt)); in pdo_mysql_stmt_execute()
333 if (mysql_real_query(H->server, stmt->active_query_string, stmt->active_query_stringlen) != 0) { in pdo_mysql_stmt_execute()
334 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute()
338 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_execute()
342 static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_next_rowset() argument
344 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_next_rowset()
350 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_next_rowset()
354 if (!mysqlnd_stmt_more_results(S->stmt)) { in pdo_mysql_stmt_next_rowset()
357 if (mysqlnd_stmt_next_result(S->stmt)) { in pdo_mysql_stmt_next_rowset()
361 if (!mysqlnd_stmt_more_results(S->stmt)) { in pdo_mysql_stmt_next_rowset()
380 stmt->column_count = mysql_stmt_field_count(S->stmt); in pdo_mysql_stmt_next_rowset()
381 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_next_rowset()
382 mysqlnd_stmt_bind_one_result(S->stmt, i); in pdo_mysql_stmt_next_rowset()
386 S->result = mysqlnd_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_next_rowset()
392 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_next_rowset()
397 row_count = (zend_long) mysql_stmt_affected_rows(S->stmt); in pdo_mysql_stmt_next_rowset()
399 stmt->row_count = row_count; in pdo_mysql_stmt_next_rowset()
407 if (S->stmt) { in pdo_mysql_stmt_next_rowset()
409 stmt->column_count = (int)mysql_num_fields(S->result); in pdo_mysql_stmt_next_rowset()
411 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_next_rowset()
425 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
428 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_next_rowset()
432 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
435 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_next_rowset()
454 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
460 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_param_hook()
463 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_param_hook()
465 if (S->stmt && param->is_param) { in pdo_mysql_stmt_param_hook()
470 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_param_hook()
488 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_param_hook()
500 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_NULL); in pdo_mysql_stmt_param_hook()
534 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_mysql_stmt_param_hook()
554 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING); in pdo_mysql_stmt_param_hook()
558 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG); in pdo_mysql_stmt_param_hook()
560 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG); in pdo_mysql_stmt_param_hook()
564 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_DOUBLE); in pdo_mysql_stmt_param_hook()
614 static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset)… argument
616 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
621 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
622 if (S->stmt) {
623 if (FAIL == mysqlnd_stmt_fetch(S->stmt, &fetched_anything) || fetched_anything == FALSE) {
632 if (S->stmt) {
633 ret = mysql_stmt_fetch(S->stmt);
643 pdo_mysql_error_stmt(stmt);
653 strcpy(stmt->error_code, "HY000");
657 if (!S->stmt && S->current_data) {
668 pdo_mysql_error_stmt(stmt);
678 static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */ argument
680 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
681 struct pdo_column_data *cols = stmt->columns;
685 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
690 if (colno >= stmt->column_count) {
701 for (i = 0; i < stmt->column_count; i++) {
713 if (S->stmt) {
725 static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, size_t *len, int *caller… argument
727 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
730 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
736 if (!S->stmt) {
742 if (colno >= stmt->column_count) {
747 if (S->stmt) {
748 Z_TRY_ADDREF(S->stmt->data->result_bind[colno].zv);
749 *ptr = (char*)&S->stmt->data->result_bind[colno].zv;
754 if (S->stmt) {
763 strcpy(stmt->error_code, "01004"); /* truncated */
826 static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) /* {{{ */ argument
828 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
834 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
838 if (colno >= stmt->column_count) {
896 static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt) /* {{{ */ argument
898 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
901 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
906 if (S->stmt) {
908 retval = mysql_stmt_free_result(S->stmt);