Lines Matching refs:stmt
30 static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt) in pdo_sqlite_stmt_dtor() argument
32 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_dtor()
34 if (S->stmt) { in pdo_sqlite_stmt_dtor()
35 sqlite3_finalize(S->stmt); in pdo_sqlite_stmt_dtor()
36 S->stmt = NULL; in pdo_sqlite_stmt_dtor()
42 static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt) in pdo_sqlite_stmt_execute() argument
44 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_execute()
46 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_execute()
47 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
51 switch (sqlite3_step(S->stmt)) { in pdo_sqlite_stmt_execute()
54 php_pdo_stmt_set_column_count(stmt, sqlite3_data_count(S->stmt)); in pdo_sqlite_stmt_execute()
58 php_pdo_stmt_set_column_count(stmt, sqlite3_column_count(S->stmt)); in pdo_sqlite_stmt_execute()
59 stmt->row_count = sqlite3_changes(S->H->db); in pdo_sqlite_stmt_execute()
60 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
65 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
70 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_execute()
75 static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, in pdo_sqlite_stmt_param_hook() argument
78 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_param_hook()
83 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_param_hook()
84 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_param_hook()
91 param->paramno = sqlite3_bind_parameter_index(S->stmt, ZSTR_VAL(param->name)) - 1; in pdo_sqlite_stmt_param_hook()
99 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
102 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
113 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
119 if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
123 if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
128 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
145 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_sqlite_stmt_param_hook()
149 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
152 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
160 if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
176 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
183 if (SQLITE_OK == sqlite3_bind_text(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
190 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
202 static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt, in pdo_sqlite_stmt_fetch() argument
205 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_fetch()
207 if (!S->stmt) { in pdo_sqlite_stmt_fetch()
217 i = sqlite3_step(S->stmt); in pdo_sqlite_stmt_fetch()
224 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
228 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
231 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_fetch()
236 static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno) in pdo_sqlite_stmt_describe() argument
238 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_describe()
241 if(colno >= sqlite3_column_count(S->stmt)) { in pdo_sqlite_stmt_describe()
243 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_describe()
247 str = sqlite3_column_name(S->stmt, colno); in pdo_sqlite_stmt_describe()
248 stmt->columns[colno].name = zend_string_init(str, strlen(str), 0); in pdo_sqlite_stmt_describe()
249 stmt->columns[colno].maxlen = SIZE_MAX; in pdo_sqlite_stmt_describe()
250 stmt->columns[colno].precision = 0; in pdo_sqlite_stmt_describe()
256 pdo_stmt_t *stmt, int colno, zval *result, enum pdo_param_type *type) in pdo_sqlite_stmt_get_col() argument
258 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_get_col()
259 if (!S->stmt) { in pdo_sqlite_stmt_get_col()
262 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_get_col()
264 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_get_col()
267 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_get_col()
273 int64_t i = sqlite3_column_int64(S->stmt, colno); in pdo_sqlite_stmt_get_col()
277 (char *) sqlite3_column_text(S->stmt, colno), in pdo_sqlite_stmt_get_col()
278 sqlite3_column_bytes(S->stmt, colno)); in pdo_sqlite_stmt_get_col()
287 ZVAL_DOUBLE(result, sqlite3_column_double(S->stmt, colno)); in pdo_sqlite_stmt_get_col()
292 sqlite3_column_blob(S->stmt, colno), sqlite3_column_bytes(S->stmt, colno)); in pdo_sqlite_stmt_get_col()
297 (char *) sqlite3_column_text(S->stmt, colno), sqlite3_column_bytes(S->stmt, colno)); in pdo_sqlite_stmt_get_col()
302 static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) in pdo_sqlite_stmt_col_meta() argument
304 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_col_meta()
308 if (!S->stmt) { in pdo_sqlite_stmt_col_meta()
311 if(colno >= sqlite3_column_count(S->stmt)) { in pdo_sqlite_stmt_col_meta()
313 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_col_meta()
320 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_col_meta()
346 str = sqlite3_column_decltype(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
352 str = sqlite3_column_table_name(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
363 static int pdo_sqlite_stmt_cursor_closer(pdo_stmt_t *stmt) in pdo_sqlite_stmt_cursor_closer() argument
365 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_cursor_closer()
366 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_cursor_closer()
370 static int pdo_sqlite_stmt_get_attribute(pdo_stmt_t *stmt, zend_long attr, zval *val) in pdo_sqlite_stmt_get_attribute() argument
372 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_get_attribute()
379 if (sqlite3_stmt_readonly(S->stmt)) { in pdo_sqlite_stmt_get_attribute()