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()
69 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_execute()
74 static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param, in pdo_sqlite_stmt_param_hook() argument
77 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_param_hook()
82 if (stmt->executed && !S->done) { in pdo_sqlite_stmt_param_hook()
83 sqlite3_reset(S->stmt); in pdo_sqlite_stmt_param_hook()
90 param->paramno = sqlite3_bind_parameter_index(S->stmt, ZSTR_VAL(param->name)) - 1; in pdo_sqlite_stmt_param_hook()
98 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
101 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
112 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
118 if (SQLITE_OK == sqlite3_bind_int64(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
122 if (SQLITE_OK == sqlite3_bind_int(S->stmt, param->paramno + 1, Z_LVAL_P(parameter))) { in pdo_sqlite_stmt_param_hook()
127 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
144 pdo_raise_impl_error(stmt->dbh, stmt, "HY105", "Expected a stream resource"); in pdo_sqlite_stmt_param_hook()
148 if (sqlite3_bind_null(S->stmt, param->paramno + 1) == SQLITE_OK) { in pdo_sqlite_stmt_param_hook()
151 pdo_sqlite_error_stmt(stmt); in pdo_sqlite_stmt_param_hook()
159 if (SQLITE_OK == sqlite3_bind_blob(S->stmt, param->paramno + 1, in pdo_sqlite_stmt_param_hook()
175 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 = SIZE_MAX; 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, size_t *len, int *calle… 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_column_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()
355 static int pdo_sqlite_stmt_get_attribute(pdo_stmt_t *stmt, zend_long attr, zval *val) in pdo_sqlite_stmt_get_attribute() argument
357 pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data; in pdo_sqlite_stmt_get_attribute()
364 if (sqlite3_stmt_readonly(S->stmt)) { in pdo_sqlite_stmt_get_attribute()