Lines Matching refs:stmt

34 #	define pdo_mysql_stmt_execute_prepared(stmt) pdo_mysql_stmt_execute_prepared_mysqlnd(stmt)  argument
36 # define pdo_mysql_stmt_close(stmt) mysqlnd_stmt_close(stmt, 0) argument
38 # define pdo_mysql_stmt_execute_prepared(stmt) pdo_mysql_stmt_execute_prepared_libmysql(stmt) argument
40 # define pdo_mysql_stmt_close(stmt) mysql_stmt_close(stmt) argument
45 static int pdo_mysql_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_dtor() argument
47 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_dtor()
50 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_dtor()
57 pefree(S->einfo.errmsg, stmt->dbh->is_persistent); in pdo_mysql_stmt_dtor()
60 if (S->stmt) { in pdo_mysql_stmt_dtor()
61 pdo_mysql_stmt_close(S->stmt); in pdo_mysql_stmt_dtor()
62 S->stmt = NULL; in pdo_mysql_stmt_dtor()
79 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_dtor()
89 if (!Z_ISUNDEF(stmt->database_object_handle) in pdo_mysql_stmt_dtor()
90 && IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)]) in pdo_mysql_stmt_dtor()
91 && (!(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED))) { in pdo_mysql_stmt_dtor()
106 if (!S->stmt && S->current_data) { in pdo_mysql_stmt_dtor()
116 static void pdo_mysql_stmt_set_row_count(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_set_row_count() argument
119 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_set_row_count()
120 row_count = (zend_long) mysql_stmt_affected_rows(S->stmt); in pdo_mysql_stmt_set_row_count()
122 stmt->row_count = row_count; in pdo_mysql_stmt_set_row_count()
127 static int pdo_mysql_fill_stmt_from_result(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_fill_stmt_from_result() argument
129 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_fill_stmt_from_result()
144 pdo_mysql_error_stmt(stmt); in pdo_mysql_fill_stmt_from_result()
148 stmt->row_count = (zend_long) mysql_num_rows(S->result); in pdo_mysql_fill_stmt_from_result()
149 stmt->column_count = (int) mysql_num_fields(S->result); in pdo_mysql_fill_stmt_from_result()
153 stmt->row_count = (zend_long) row_count; in pdo_mysql_fill_stmt_from_result()
161 static int pdo_mysql_stmt_execute_prepared_libmysql(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_libmysql() argument
163 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_libmysql()
169 if (mysql_stmt_bind_param(S->stmt, S->params) || mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_libmysql()
173 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
174 if (mysql_stmt_errno(S->stmt) == 2057) { in pdo_mysql_stmt_execute_prepared_libmysql()
176 S->stmt = NULL; in pdo_mysql_stmt_execute_prepared_libmysql()
185 S->result = mysql_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
191 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_execute_prepared_libmysql()
199 stmt->column_count = (int)mysql_num_fields(S->result); in pdo_mysql_stmt_execute_prepared_libmysql()
200 S->bound_result = ecalloc(stmt->column_count, sizeof(MYSQL_BIND)); in pdo_mysql_stmt_execute_prepared_libmysql()
201 S->out_null = ecalloc(stmt->column_count, sizeof(my_bool)); in pdo_mysql_stmt_execute_prepared_libmysql()
202 S->out_length = ecalloc(stmt->column_count, sizeof(zend_ulong)); in pdo_mysql_stmt_execute_prepared_libmysql()
205 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_execute_prepared_libmysql()
208 mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on); in pdo_mysql_stmt_execute_prepared_libmysql()
253 if (mysql_stmt_bind_result(S->stmt, S->bound_result)) { in pdo_mysql_stmt_execute_prepared_libmysql()
254 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
260 mysql_stmt_store_result(S->stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
265 pdo_mysql_stmt_set_row_count(stmt); in pdo_mysql_stmt_execute_prepared_libmysql()
272 static int pdo_mysql_stmt_execute_prepared_mysqlnd(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute_prepared_mysqlnd() argument
274 pdo_mysql_stmt *S = stmt->driver_data; in pdo_mysql_stmt_execute_prepared_mysqlnd()
280 if (mysql_stmt_execute(S->stmt)) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
281 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
292 stmt->column_count = mysql_stmt_field_count(S->stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
293 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
294 mysqlnd_stmt_bind_one_result(S->stmt, i); in pdo_mysql_stmt_execute_prepared_mysqlnd()
297 S->result = mysqlnd_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
302 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_execute_prepared_mysqlnd()
308 pdo_mysql_stmt_set_row_count(stmt); in pdo_mysql_stmt_execute_prepared_mysqlnd()
314 static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_execute() argument
316 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_execute()
319 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_execute()
321 if (S->stmt) { in pdo_mysql_stmt_execute()
322 PDO_DBG_RETURN(pdo_mysql_stmt_execute_prepared(stmt)); in pdo_mysql_stmt_execute()
331 if (mysql_real_query(H->server, stmt->active_query_string, stmt->active_query_stringlen) != 0) { in pdo_mysql_stmt_execute()
332 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_execute()
336 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_execute()
340 static int pdo_mysql_stmt_next_rowset(pdo_stmt_t *stmt) /* {{{ */ in pdo_mysql_stmt_next_rowset() argument
342 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_next_rowset()
348 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_next_rowset()
352 if (!mysqlnd_stmt_more_results(S->stmt)) { in pdo_mysql_stmt_next_rowset()
355 if (mysqlnd_stmt_next_result(S->stmt)) { in pdo_mysql_stmt_next_rowset()
359 if (!mysqlnd_stmt_more_results(S->stmt)) { in pdo_mysql_stmt_next_rowset()
378 stmt->column_count = mysql_stmt_field_count(S->stmt); in pdo_mysql_stmt_next_rowset()
379 for (i = 0; i < stmt->column_count; i++) { in pdo_mysql_stmt_next_rowset()
380 mysqlnd_stmt_bind_one_result(S->stmt, i); in pdo_mysql_stmt_next_rowset()
384 S->result = mysqlnd_stmt_result_metadata(S->stmt); in pdo_mysql_stmt_next_rowset()
390 if (mysql_stmt_store_result(S->stmt)) { in pdo_mysql_stmt_next_rowset()
395 row_count = (zend_long) mysql_stmt_affected_rows(S->stmt); in pdo_mysql_stmt_next_rowset()
397 stmt->row_count = row_count; in pdo_mysql_stmt_next_rowset()
405 if (S->stmt) { in pdo_mysql_stmt_next_rowset()
407 stmt->column_count = (int)mysql_num_fields(S->result); in pdo_mysql_stmt_next_rowset()
409 mysql_stmt_free_result(S->stmt); in pdo_mysql_stmt_next_rowset()
423 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
426 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_next_rowset()
430 pdo_mysql_error_stmt(stmt); in pdo_mysql_stmt_next_rowset()
433 PDO_DBG_RETURN(pdo_mysql_fill_stmt_from_result(stmt)); in pdo_mysql_stmt_next_rowset()
452 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
458 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data; in pdo_mysql_stmt_param_hook()
461 PDO_DBG_INF_FMT("stmt=%p", S->stmt); in pdo_mysql_stmt_param_hook()
463 if (S->stmt && param->is_param) { in pdo_mysql_stmt_param_hook()
468 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_param_hook()
486 strcpy(stmt->error_code, "HY093"); in pdo_mysql_stmt_param_hook()
498 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_NULL); in pdo_mysql_stmt_param_hook()
532 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_mysql_stmt_param_hook()
552 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_VAR_STRING); in pdo_mysql_stmt_param_hook()
556 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONGLONG); in pdo_mysql_stmt_param_hook()
558 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_LONG); in pdo_mysql_stmt_param_hook()
563 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_TINY); in pdo_mysql_stmt_param_hook()
566 mysqlnd_stmt_bind_one_param(S->stmt, param->paramno, parameter, MYSQL_TYPE_DOUBLE); in pdo_mysql_stmt_param_hook()
616 static int pdo_mysql_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori, zend_long offset)… argument
618 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
623 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
624 if (S->stmt) {
625 if (FAIL == mysqlnd_stmt_fetch(S->stmt, &fetched_anything) || fetched_anything == FALSE) {
634 if (S->stmt) {
635 ret = mysql_stmt_fetch(S->stmt);
645 pdo_mysql_error_stmt(stmt);
655 strcpy(stmt->error_code, "HY000");
659 if (!S->stmt && S->current_data) {
670 pdo_mysql_error_stmt(stmt);
680 static int pdo_mysql_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */ argument
682 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
683 struct pdo_column_data *cols = stmt->columns;
687 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
692 if (colno >= stmt->column_count) {
703 for (i = 0; i < stmt->column_count; i++) {
715 if (S->stmt) {
727 static int pdo_mysql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, size_t *len, int *caller… argument
729 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
732 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
738 if (!S->stmt) {
744 if (colno >= stmt->column_count) {
749 if (S->stmt) {
750 Z_TRY_ADDREF(S->stmt->data->result_bind[colno].zv);
751 *ptr = (char*)&S->stmt->data->result_bind[colno].zv;
756 if (S->stmt) {
765 strcpy(stmt->error_code, "01004"); /* truncated */
828 static int pdo_mysql_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) /* {{{ */ argument
830 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
836 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
840 if (colno >= stmt->column_count) {
898 static int pdo_mysql_stmt_cursor_closer(pdo_stmt_t *stmt) /* {{{ */ argument
900 pdo_mysql_stmt *S = (pdo_mysql_stmt*)stmt->driver_data;
903 PDO_DBG_INF_FMT("stmt=%p", S->stmt);
908 if (S->stmt) {
910 retval = mysql_stmt_free_result(S->stmt);