30static int pdo_sqlite_stmt_dtor(
pdo_stmt_t *stmt)
35 sqlite3_finalize(
S->stmt);
42static int pdo_sqlite_stmt_execute(
pdo_stmt_t *stmt)
46 if (stmt->executed && !
S->done) {
47 sqlite3_reset(
S->stmt);
51 switch (sqlite3_step(
S->stmt)) {
59 stmt->row_count = sqlite3_changes(
S->H->db);
60 sqlite3_reset(
S->stmt);
65 sqlite3_reset(
S->stmt);
83 if (stmt->executed && !
S->done) {
84 sqlite3_reset(
S->stmt);
88 if (param->is_param) {
90 if (param->paramno == -1) {
91 param->paramno = sqlite3_bind_parameter_index(
S->stmt,
ZSTR_VAL(param->name)) - 1;
99 if (sqlite3_bind_null(
S->stmt, param->paramno + 1) == SQLITE_OK) {
107 if (
Z_ISREF(param->parameter)) {
108 parameter =
Z_REFVAL(param->parameter);
110 parameter = ¶m->parameter;
113 if (sqlite3_bind_null(
S->stmt, param->paramno + 1) == SQLITE_OK) {
118#if ZEND_LONG_MAX > 2147483647
119 if (SQLITE_OK == sqlite3_bind_int64(
S->stmt, param->paramno + 1,
Z_LVAL_P(parameter))) {
123 if (SQLITE_OK == sqlite3_bind_int(
S->stmt, param->paramno + 1,
Z_LVAL_P(parameter))) {
132 if (
Z_ISREF(param->parameter)) {
133 parameter =
Z_REFVAL(param->parameter);
135 parameter = ¶m->parameter;
149 if (sqlite3_bind_null(
S->stmt, param->paramno + 1) == SQLITE_OK) {
155 if (!try_convert_to_string(parameter)) {
160 if (SQLITE_OK == sqlite3_bind_blob(
S->stmt, param->paramno + 1,
170 if (
Z_ISREF(param->parameter)) {
171 parameter =
Z_REFVAL(param->parameter);
173 parameter = ¶m->parameter;
176 if (sqlite3_bind_null(
S->stmt, param->paramno + 1) == SQLITE_OK) {
180 if (!try_convert_to_string(parameter)) {
183 if (SQLITE_OK == sqlite3_bind_text(
S->stmt, param->paramno + 1,
202static int pdo_sqlite_stmt_fetch(
pdo_stmt_t *stmt,
210 if (
S->pre_fetched) {
217 i = sqlite3_step(
S->stmt);
224 sqlite3_reset(
S->stmt);
228 sqlite3_reset(
S->stmt);
236static int pdo_sqlite_stmt_describe(
pdo_stmt_t *stmt,
int colno)
241 if(colno >= sqlite3_column_count(
S->stmt)) {
247 str = sqlite3_column_name(
S->stmt, colno);
248 stmt->columns[colno].name = zend_string_init(str,
strlen(str), 0);
249 stmt->columns[colno].maxlen =
SIZE_MAX;
250 stmt->columns[colno].precision = 0;
255static int pdo_sqlite_stmt_get_col(
262 if(colno >= sqlite3_data_count(
S->stmt)) {
267 switch (sqlite3_column_type(
S->stmt, colno)) {
272 case SQLITE_INTEGER: {
273 int64_t i = sqlite3_column_int64(
S->stmt, colno);
274#if SIZEOF_ZEND_LONG < 8
277 (
char *) sqlite3_column_text(
S->stmt, colno),
278 sqlite3_column_bytes(
S->stmt, colno));
292 sqlite3_column_blob(
S->stmt, colno), sqlite3_column_bytes(
S->stmt, colno));
297 (
char *) sqlite3_column_text(
S->stmt, colno), sqlite3_column_bytes(
S->stmt, colno));
308 if (!
S->stmt || !stmt->executed) {
311 if(colno >= sqlite3_column_count(
S->stmt)) {
320 switch (sqlite3_column_type(
S->stmt, colno)) {
346 str = sqlite3_column_decltype(
S->stmt, colno);
348 add_assoc_string(
return_value,
"sqlite:decl_type", (
char *)str);
351#ifdef HAVE_SQLITE3_COLUMN_TABLE_NAME
352 str = sqlite3_column_table_name(
S->stmt, colno);
363static int pdo_sqlite_stmt_cursor_closer(
pdo_stmt_t *stmt)
366 sqlite3_reset(
S->stmt);
378#if SQLITE_VERSION_NUMBER >= 3007004
379 if (sqlite3_stmt_readonly(
S->stmt)) {
393 pdo_sqlite_stmt_dtor,
394 pdo_sqlite_stmt_execute,
395 pdo_sqlite_stmt_fetch,
396 pdo_sqlite_stmt_describe,
397 pdo_sqlite_stmt_get_col,
398 pdo_sqlite_stmt_param_hook,
400 pdo_sqlite_stmt_get_attribute,
401 pdo_sqlite_stmt_col_meta,
403 pdo_sqlite_stmt_cursor_closer
void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, pdo_error_type sqlstate, const char *supp)
PDO_API void php_pdo_stmt_set_column_count(pdo_stmt_t *stmt, int new_count)
struct _pdo_stmt_t pdo_stmt_t
#define PDO_PARAM_TYPE(x)
#define pdo_sqlite_error_stmt(s)
@ PDO_SQLITE_ATTR_READONLY_STATEMENT
const struct pdo_stmt_methods sqlite_stmt_methods
struct _php_stream php_stream
#define PHP_STREAM_COPY_ALL
#define php_stream_copy_to_mem(src, maxlen, persistent)
#define php_stream_from_zval_no_verify(xstr, pzval)
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
#define ZVAL_STRINGL(z, s, l)
#define ZVAL_STRINGL_FAST(z, s, l)
struct _zend_string zend_string
ZEND_API void ZEND_FASTCALL convert_to_long(zval *op)
#define ZSTR_EMPTY_ALLOC()
#define Z_STRVAL_P(zval_p)
#define Z_STRLEN_P(zval_p)
#define ZVAL_DOUBLE(z, d)
ZEND_API void zval_ptr_dtor(zval *zval_ptr)