Lines Matching refs:stmt

34 static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt)  in pdo_sqlite_stmt_dtor()  argument
36 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_dtor()
38 if (S->stmt) { in pdo_sqlite_stmt_dtor()
39 sqlite3_finalize(S->stmt); in pdo_sqlite_stmt_dtor()
40 S->stmt = NULL; in pdo_sqlite_stmt_dtor()
54 static void pdo_sqlite_stmt_set_column_count(pdo_stmt_t *stmt, int new_count) in pdo_sqlite_stmt_set_column_count() argument
57 if (!stmt->columns) { in pdo_sqlite_stmt_set_column_count()
58 stmt->column_count = new_count; in pdo_sqlite_stmt_set_column_count()
67 if (new_count == stmt->column_count) { in pdo_sqlite_stmt_set_column_count()
74 for (i = 0; i < stmt->column_count; i++) { in pdo_sqlite_stmt_set_column_count()
75 if (stmt->columns[i].name) { in pdo_sqlite_stmt_set_column_count()
76 zend_string_release(stmt->columns[i].name); in pdo_sqlite_stmt_set_column_count()
77 stmt->columns[i].name = NULL; in pdo_sqlite_stmt_set_column_count()
81 efree(stmt->columns); in pdo_sqlite_stmt_set_column_count()
82 stmt->columns = NULL; in pdo_sqlite_stmt_set_column_count()
83 stmt->column_count = new_count; in pdo_sqlite_stmt_set_column_count()
86 static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt) in pdo_sqlite_stmt_execute() argument
88 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_execute()
90 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_execute()
91 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
95 switch (sqlite3_step(S->stmt)) { in pdo_sqlite_stmt_execute()
98 pdo_sqlite_stmt_set_column_count(stmt, sqlite3_data_count(S->stmt)); in pdo_sqlite_stmt_execute()
102 pdo_sqlite_stmt_set_column_count(stmt, sqlite3_column_count(S->stmt)); in pdo_sqlite_stmt_execute()
103 stmt->row_count = sqlite3_changes(S->H->db); in pdo_sqlite_stmt_execute()
104 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
109 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
113 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_execute()
118 static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, in pdo_sqlite_stmt_param_hook() argument
121 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_param_hook()
126 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_param_hook()
127 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_param_hook()
134 param->paramno = sqlite3_bind_parameter_index(S->stmt, ZSTR_VAL(param->name)) - 1; in pdo_sqlite_stmt_param_hook()
142 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
145 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
156 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
162 if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
166 if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
171 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
188 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_sqlite_stmt_param_hook()
192 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
195 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
201 if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
217 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
222 if (SQLITE_OK == sqlite3_bind_text(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
229 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
241 static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt, in pdo_sqlite_stmt_fetch() argument
244 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_fetch()
246 if (!S->stmt) { in pdo_sqlite_stmt_fetch()
256 i = sqlite3_step(S->stmt); in pdo_sqlite_stmt_fetch()
263 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
267 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
269 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_fetch()
274 static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno) in pdo_sqlite_stmt_describe() argument
276 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_describe()
279 if(colno >= sqlite3_column_count(S->stmt)) { in pdo_sqlite_stmt_describe()
281 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_describe()
285 str = sqlite3_column_name(S->stmt, colno); in pdo_sqlite_stmt_describe()
286 stmt->columns[colno].name = zend_string_init(str, strlen(str), 0); in pdo_sqlite_stmt_describe()
287 stmt->columns[colno].maxlen = 0xffffffff; in pdo_sqlite_stmt_describe()
288 stmt->columns[colno].precision = 0; in pdo_sqlite_stmt_describe()
290 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_describe()
297 stmt->columns[colno].param_type = PDO_PARAM_STR; in pdo_sqlite_stmt_describe()
304 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
306 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_get_col()
307 if (!S->stmt) { in pdo_sqlite_stmt_get_col()
310 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_get_col()
312 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_get_col()
315 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_get_col()
322 *ptr = (char*)sqlite3_column_blob(S->stmt, colno); in pdo_sqlite_stmt_get_col()
323 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
327 *ptr = (char*)sqlite3_column_text(S->stmt, colno); in pdo_sqlite_stmt_get_col()
328 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
333 static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) in pdo_sqlite_stmt_col_meta() argument
335 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_col_meta()
339 if (!S->stmt) { in pdo_sqlite_stmt_col_meta()
342 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_col_meta()
344 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_col_meta()
351 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_col_meta()
371 str = sqlite3_column_decltype(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
377 str = sqlite3_column_table_name(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
388 static int pdo_sqlite_stmt_cursor_closer(pdo_stmt_t *stmt) in pdo_sqlite_stmt_cursor_closer() argument
390 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_cursor_closer()
391 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_cursor_closer()