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()
46 static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt) in pdo_sqlite_stmt_execute() argument
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()
86 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_param_hook()
87 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_param_hook()
94 param->paramno = sqlite3_bind_parameter_index(S->stmt, ZSTR_VAL(param->name)) - 1; in pdo_sqlite_stmt_param_hook()
102 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
105 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
116 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
122 if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
126 if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
131 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
148 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_sqlite_stmt_param_hook()
152 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
155 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
161 if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
177 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
182 if (SQLITE_OK == sqlite3_bind_text(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
189 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
201 static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt, in pdo_sqlite_stmt_fetch() argument
204 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_fetch()
206 if (!S->stmt) { in pdo_sqlite_stmt_fetch()
216 i = sqlite3_step(S->stmt); in pdo_sqlite_stmt_fetch()
223 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
227 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_fetch()
229 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_fetch()
234 static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno) in pdo_sqlite_stmt_describe() argument
236 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_describe()
239 if(colno >= sqlite3_column_count(S->stmt)) { in pdo_sqlite_stmt_describe()
241 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_describe()
245 str = sqlite3_column_name(S->stmt, colno); in pdo_sqlite_stmt_describe()
246 stmt->columns[colno].name = zend_string_init(str, strlen(str), 0); in pdo_sqlite_stmt_describe()
247 stmt->columns[colno].maxlen = 0xffffffff; in pdo_sqlite_stmt_describe()
248 stmt->columns[colno].precision = 0; in pdo_sqlite_stmt_describe()
250 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_describe()
257 stmt->columns[colno].param_type = PDO_PARAM_STR; in pdo_sqlite_stmt_describe()
264 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
266 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_get_col()
267 if (!S->stmt) { in pdo_sqlite_stmt_get_col()
270 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_get_col()
272 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_get_col()
275 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_get_col()
282 *ptr = (char*)sqlite3_column_blob(S->stmt, colno); in pdo_sqlite_stmt_get_col()
283 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
287 *ptr = (char*)sqlite3_column_text(S->stmt, colno); in pdo_sqlite_stmt_get_col()
288 *len = sqlite3_column_bytes(S->stmt, colno); in pdo_sqlite_stmt_get_col()
293 static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, zend_long colno, zval *return_value) in pdo_sqlite_stmt_col_meta() argument
295 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_col_meta()
299 if (!S->stmt) { in pdo_sqlite_stmt_col_meta()
302 if(colno >= sqlite3_data_count(S->stmt)) { in pdo_sqlite_stmt_col_meta()
304 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_col_meta()
311 switch (sqlite3_column_type(S->stmt, colno)) { in pdo_sqlite_stmt_col_meta()
331 str = sqlite3_column_decltype(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
337 str = sqlite3_column_table_name(S->stmt, colno); in pdo_sqlite_stmt_col_meta()
348 static int pdo_sqlite_stmt_cursor_closer(pdo_stmt_t *stmt) in pdo_sqlite_stmt_cursor_closer() argument
350 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_cursor_closer()
351 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_cursor_closer()