Lines Matching refs:stmt
32 static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt) in pdo_sqlite_stmt_dtor() argument
34 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_dtor()
36 if (S->stmt) { in pdo_sqlite_stmt_dtor()
37 sqlite3_finalize(S->stmt); in pdo_sqlite_stmt_dtor()
38 S->stmt = NULL; in pdo_sqlite_stmt_dtor()
52 static void pdo_sqlite_stmt_set_column_count(pdo_stmt_t *stmt, int new_count) in pdo_sqlite_stmt_set_column_count() argument
55 if (!stmt->columns) { in pdo_sqlite_stmt_set_column_count()
56 stmt->column_count = new_count; in pdo_sqlite_stmt_set_column_count()
65 if (new_count == stmt->column_count) { in pdo_sqlite_stmt_set_column_count()
72 for (i = 0; i < stmt->column_count; i++) { in pdo_sqlite_stmt_set_column_count()
73 if (stmt->columns[i].name) { in pdo_sqlite_stmt_set_column_count()
74 zend_string_release(stmt->columns[i].name); in pdo_sqlite_stmt_set_column_count()
75 stmt->columns[i].name = NULL; in pdo_sqlite_stmt_set_column_count()
79 efree(stmt->columns); in pdo_sqlite_stmt_set_column_count()
80 stmt->columns = NULL; in pdo_sqlite_stmt_set_column_count()
81 stmt->column_count = new_count; in pdo_sqlite_stmt_set_column_count()
84 static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt) in pdo_sqlite_stmt_execute() argument
86 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_execute()
88 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_execute()
89 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
93 switch (sqlite3_step(S->stmt)) { in pdo_sqlite_stmt_execute()
96 pdo_sqlite_stmt_set_column_count(stmt, sqlite3_data_count(S->stmt)); in pdo_sqlite_stmt_execute()
100 pdo_sqlite_stmt_set_column_count(stmt, sqlite3_column_count(S->stmt)); in pdo_sqlite_stmt_execute()
101 stmt->row_count = sqlite3_changes(S->H->db); in pdo_sqlite_stmt_execute()
102 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
107 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
111 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_execute()
116 static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, in pdo_sqlite_stmt_param_hook() argument
119 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_param_hook()
124 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_param_hook()
125 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_param_hook()
132 param->paramno = sqlite3_bind_parameter_index(S->stmt, ZSTR_VAL(param->name)) - 1; in pdo_sqlite_stmt_param_hook()
140 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
143 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
154 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
160 if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
164 if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
169 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
186 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_sqlite_stmt_param_hook()
190 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
193 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
199 if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
215 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
220 if (SQLITE_OK == sqlite3_bind_text(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
227 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
239 static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt, in pdo_sqlite_stmt_fetch() argument
242 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_fetch()
244 if (!S->stmt) { in pdo_sqlite_stmt_fetch()
254 i = sqlite3_step(S->stmt); in pdo_sqlite_stmt_fetch()
261 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
265 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
267 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_fetch()
272 static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno) in pdo_sqlite_stmt_describe() argument
274 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_describe()
277 if(colno >= sqlite3_column_count(S->stmt)) { in pdo_sqlite_stmt_describe()
279 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_describe()
283 str = sqlite3_column_name(S->stmt, colno); in pdo_sqlite_stmt_describe()
284 stmt->columns[colno].name = zend_string_init(str, strlen(str), 0); in pdo_sqlite_stmt_describe()
285 stmt->columns[colno].maxlen = SIZE_MAX; in pdo_sqlite_stmt_describe()
286 stmt->columns[colno].precision = 0; in pdo_sqlite_stmt_describe()
288 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_describe()
295 stmt->columns[colno].param_type = PDO_PARAM_STR; in pdo_sqlite_stmt_describe()
302 static int pdo_sqlite_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, zend_ulong *len, int *c… in pdo_sqlite_stmt_get_col() argument
304 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_get_col()
305 if (!S->stmt) { in pdo_sqlite_stmt_get_col()
308 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_get_col()
310 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_get_col()
313 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_get_col()
320 *ptr = (char*)sqlite3_column_blob(S->stmt, colno); in pdo_sqlite_stmt_get_col()
321 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
325 *ptr = (char*)sqlite3_column_text(S->stmt, colno); in pdo_sqlite_stmt_get_col()
326 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
331 static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) in pdo_sqlite_stmt_col_meta() argument
333 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_col_meta()
337 if (!S->stmt) { in pdo_sqlite_stmt_col_meta()
340 if(colno >= sqlite3_column_count(S->stmt)) { in pdo_sqlite_stmt_col_meta()
342 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_col_meta()
349 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_col_meta()
369 str = sqlite3_column_decltype(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
375 str = sqlite3_column_table_name(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
386 static int pdo_sqlite_stmt_cursor_closer(pdo_stmt_t *stmt) in pdo_sqlite_stmt_cursor_closer() argument
388 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_cursor_closer()
389 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_cursor_closer()