Lines Matching refs:stmt
34 static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) in pdo_sqlite_stmt_dtor()
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()
46 static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) in pdo_sqlite_stmt_execute()
48 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_execute()
50 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_execute()
51 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
55 switch (sqlite3_step(S->stmt)) { in pdo_sqlite_stmt_execute()
58 stmt->column_count = sqlite3_data_count(S->stmt); in pdo_sqlite_stmt_execute()
62 stmt->column_count = sqlite3_column_count(S->stmt); in pdo_sqlite_stmt_execute()
63 stmt->row_count = sqlite3_changes(S->H->db); in pdo_sqlite_stmt_execute()
64 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
69 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_execute()
73 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_execute()
78 static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, in pdo_sqlite_stmt_param_hook() argument
81 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_param_hook()
85 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_param_hook()
86 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_param_hook()
93 param->paramno = sqlite3_bind_parameter_index(S->stmt, param->name) - 1; in pdo_sqlite_stmt_param_hook()
101 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
104 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
110 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
116 … if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { in pdo_sqlite_stmt_param_hook()
120 if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(param->parameter))) { in pdo_sqlite_stmt_param_hook()
125 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
138 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource" TSRMLS_CC); 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()
151 if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
157 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
163 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
168 if(SQLITE_OK == sqlite3_bind_text(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
175 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
187 static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt, in pdo_sqlite_stmt_fetch() argument
190 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_fetch()
192 if (!S->stmt) { in pdo_sqlite_stmt_fetch()
202 i = sqlite3_step(S->stmt); in pdo_sqlite_stmt_fetch()
209 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
213 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
215 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_fetch()
220 static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) in pdo_sqlite_stmt_describe() argument
222 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_describe()
224 if(colno >= sqlite3_column_count(S->stmt)) { in pdo_sqlite_stmt_describe()
226 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_describe()
230 stmt->columns[colno].name = estrdup(sqlite3_column_name(S->stmt, colno)); in pdo_sqlite_stmt_describe()
231 stmt->columns[colno].namelen = strlen(stmt->columns[colno].name); in pdo_sqlite_stmt_describe()
232 stmt->columns[colno].maxlen = 0xffffffff; in pdo_sqlite_stmt_describe()
233 stmt->columns[colno].precision = 0; in pdo_sqlite_stmt_describe()
235 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_describe()
242 stmt->columns[colno].param_type = PDO_PARAM_STR; in pdo_sqlite_stmt_describe()
249 static int pdo_sqlite_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len, int… in pdo_sqlite_stmt_get_col() argument
251 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_get_col()
252 if (!S->stmt) { in pdo_sqlite_stmt_get_col()
255 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_get_col()
257 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_get_col()
260 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_get_col()
267 *ptr = (char*)sqlite3_column_blob(S->stmt, colno); in pdo_sqlite_stmt_get_col()
268 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
272 *ptr = (char*)sqlite3_column_text(S->stmt, colno); in pdo_sqlite_stmt_get_col()
273 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
278 static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC) in pdo_sqlite_stmt_col_meta() argument
280 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_col_meta()
284 if (!S->stmt) { in pdo_sqlite_stmt_col_meta()
287 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_col_meta()
289 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_col_meta()
297 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_col_meta()
317 str = sqlite3_column_decltype(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
323 str = sqlite3_column_table_name(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
334 static int pdo_sqlite_stmt_cursor_closer(pdo_stmt_t *stmt TSRMLS_DC) in pdo_sqlite_stmt_cursor_closer()
336 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_cursor_closer()
337 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_cursor_closer()