Back to index

php5  5.3.10
Defines | Functions | Variables
php_sqlite.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define phpext_sqlite_ptr   &sqlite_module_entry
#define SQLITE_G(v)   (sqlite_globals.v)

Functions

 PHP_MINIT_FUNCTION (sqlite)
 PHP_MSHUTDOWN_FUNCTION (sqlite)
 PHP_RSHUTDOWN_FUNCTION (sqlite)
 PHP_MINFO_FUNCTION (sqlite)
 PHP_FUNCTION (sqlite_open)
 PHP_FUNCTION (sqlite_popen)
 PHP_FUNCTION (sqlite_close)
 PHP_FUNCTION (sqlite_query)
 PHP_FUNCTION (sqlite_exec)
 PHP_FUNCTION (sqlite_unbuffered_query)
 PHP_FUNCTION (sqlite_array_query)
 PHP_FUNCTION (sqlite_single_query)
 PHP_FUNCTION (sqlite_fetch_array)
 PHP_FUNCTION (sqlite_fetch_object)
 PHP_FUNCTION (sqlite_fetch_single)
 PHP_FUNCTION (sqlite_fetch_all)
 PHP_FUNCTION (sqlite_current)
 PHP_FUNCTION (sqlite_column)
 PHP_FUNCTION (sqlite_num_rows)
 PHP_FUNCTION (sqlite_num_fields)
 PHP_FUNCTION (sqlite_field_name)
 PHP_FUNCTION (sqlite_seek)
 PHP_FUNCTION (sqlite_rewind)
 PHP_FUNCTION (sqlite_next)
 PHP_FUNCTION (sqlite_prev)
 PHP_FUNCTION (sqlite_key)
 PHP_FUNCTION (sqlite_valid)
 PHP_FUNCTION (sqlite_has_prev)
 PHP_FUNCTION (sqlite_libversion)
 PHP_FUNCTION (sqlite_libencoding)
 PHP_FUNCTION (sqlite_changes)
 PHP_FUNCTION (sqlite_last_insert_rowid)
 PHP_FUNCTION (sqlite_escape_string)
 PHP_FUNCTION (sqlite_busy_timeout)
 PHP_FUNCTION (sqlite_last_error)
 PHP_FUNCTION (sqlite_error_string)
 PHP_FUNCTION (sqlite_create_aggregate)
 PHP_FUNCTION (sqlite_create_function)
 PHP_FUNCTION (sqlite_udf_decode_binary)
 PHP_FUNCTION (sqlite_udf_encode_binary)
 PHP_FUNCTION (sqlite_factory)
 PHP_FUNCTION (sqlite_fetch_column_types)

Variables

zend_module_entry sqlite_module_entry
long assoc_case

Define Documentation

Definition at line 27 of file php_sqlite.h.

#define SQLITE_G (   v)    (sqlite_globals.v)

Definition at line 95 of file php_sqlite.h.


Function Documentation

Definition at line 1623 of file sqlite.c.

{
       long mode = 0666;
       char *filename, *fullpath = NULL;
       int filename_len;
       zval *errmsg = NULL;
       zval *object = getThis();
       zend_error_handling error_handling;

       zend_replace_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception, &error_handling TSRMLS_CC);
       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
                            &filename, &filename_len, &mode, &errmsg)) {
              zend_restore_error_handling(&error_handling TSRMLS_CC);
              return;
       }
       if (errmsg) {
              zval_dtor(errmsg);
              ZVAL_NULL(errmsg);
       }

       if (strlen(filename) != filename_len) {
              zend_restore_error_handling(&error_handling TSRMLS_CC);
              RETURN_FALSE;
       }

       if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
              /* resolve the fully-qualified path name to use as the hash key */
              if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
                     zend_restore_error_handling(&error_handling TSRMLS_CC);
                     if (object) {
                            RETURN_NULL();
                     } else {
                            RETURN_FALSE;
                     }
              }

              if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) ||
                            php_check_open_basedir(fullpath TSRMLS_CC)) {
                     efree(fullpath);
                     zend_restore_error_handling(&error_handling TSRMLS_CC);
                     if (object) {
                            RETURN_NULL();
                     } else {
                            RETURN_FALSE;
                     }
              }
       }

       php_sqlite_open(fullpath ? fullpath : filename, (int)mode, NULL, return_value, errmsg, object TSRMLS_CC);

       if (fullpath) {
              efree(fullpath);
       }
       zend_restore_error_handling(&error_handling TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_popen  )

Definition at line 1545 of file sqlite.c.

{
       long mode = 0666;
       char *filename, *fullpath, *hashkey;
       int filename_len, hashkeylen;
       zval *errmsg = NULL;
       struct php_sqlite_db *db = NULL;
       zend_rsrc_list_entry *le;

       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
                            &filename, &filename_len, &mode, &errmsg)) {
              return;
       }
       if (errmsg) {
              zval_dtor(errmsg);
              ZVAL_NULL(errmsg);
       }

       if (strlen(filename) != filename_len) {
              RETURN_FALSE;
       }
       if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
              /* resolve the fully-qualified path name to use as the hash key */
              if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
                     RETURN_FALSE;
              }

              if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || 
                            php_check_open_basedir(fullpath TSRMLS_CC)) {
                     efree(fullpath);
                     RETURN_FALSE;
              }
       } else {
              fullpath = estrndup(filename, filename_len);
       }

       hashkeylen = spprintf(&hashkey, 0, "sqlite_pdb_%s:%ld", fullpath, mode);

       /* do we have an existing persistent connection ? */
       if (SUCCESS == zend_hash_find(&EG(persistent_list), hashkey, hashkeylen+1, (void*)&le)) {
              if (Z_TYPE_P(le) == le_sqlite_pdb) {
                     db = (struct php_sqlite_db*)le->ptr;

                     if (db->rsrc_id == FAILURE) {
                            /* give it a valid resource id for this request */
                            db->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, db, le_sqlite_pdb);
                     } else {
                            int type;
                            /* sanity check to ensure that the resource is still a valid regular resource
                             * number */
                            if (zend_list_find(db->rsrc_id, &type) == db) {
                                   /* already accessed this request; map it */
                                   zend_list_addref(db->rsrc_id);
                                   ZVAL_RESOURCE(return_value, db->rsrc_id);
                            } else {
                                   db->rsrc_id = ZEND_REGISTER_RESOURCE(return_value, db, le_sqlite_pdb);
                            }
                     }

                     /* all set */
                     goto done;
              }

              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Some other type of persistent resource is using this hash key!?");
              RETVAL_FALSE;
              goto done;
       }

       /* now we need to open the database */
       php_sqlite_open(fullpath, (int)mode, hashkey, return_value, errmsg, NULL TSRMLS_CC);
done:
       efree(fullpath);
       efree(hashkey);
}

Here is the call graph for this function:

Definition at line 1756 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       zval *object = getThis();

       if (object) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Ignored, you must destruct the object instead");
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zdb)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       zend_hash_apply_with_argument(&EG(regular_list),
              (apply_func_arg_t) _clean_unfinished_results,
              db TSRMLS_CC);

       zend_list_delete(Z_RESVAL_P(zdb));
}

Here is the call graph for this function:

Definition at line 2066 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       char *sql;
       int sql_len;
       long mode = PHPSQLITE_BOTH;
       char *errtext = NULL;
       zval *errmsg = NULL;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/", &sql, &sql_len, &mode, &errmsg)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
                            ZEND_NUM_ARGS() TSRMLS_CC, "sr|lz/", &sql, &sql_len, &zdb, &mode, &errmsg) &&
                     FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|lz/", &zdb, &sql, &sql_len, &mode, &errmsg)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       if (errmsg) {
              zval_dtor(errmsg);
              ZVAL_NULL(errmsg);
       }

       PHP_SQLITE_EMPTY_QUERY;

       /* avoid doing work if we can */
       if (!return_value_used) {
              db->last_err_code = sqlite_exec(db->db, sql, NULL, NULL, &errtext);

              if (db->last_err_code != SQLITE_OK) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
                     if (errmsg) {
                            ZVAL_STRING(errmsg, errtext, 1);
                     }
                     sqlite_freemem(errtext);
              }
              return;
       }

       sqlite_query(object, db, sql, sql_len, (int)mode, 1, return_value, NULL, errmsg TSRMLS_CC);
}

Here is the call graph for this function:

Definition at line 2118 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       char *sql;
       int sql_len;
       char *errtext = NULL;
       zval *errmsg = NULL;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z/", &sql, &sql_len, &errmsg)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if(FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
                     ZEND_NUM_ARGS() TSRMLS_CC, "sr", &sql, &sql_len, &zdb) &&
                 FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|z/", &zdb, &sql, &sql_len, &errmsg)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       if (errmsg) {
              zval_dtor(errmsg);
              ZVAL_NULL(errmsg);
       }

       PHP_SQLITE_EMPTY_QUERY;

       db->last_err_code = sqlite_exec(db->db, sql, NULL, NULL, &errtext);

       if (db->last_err_code != SQLITE_OK) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
              if (errmsg) {
                     ZVAL_STRING(errmsg, errtext, 1);
              }
              sqlite_freemem(errtext);
              RETURN_FALSE;
       }

       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_unbuffered_query  )

Definition at line 1939 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       char *sql;
       int sql_len;
       long mode = PHPSQLITE_BOTH;
       char *errtext = NULL;
       zval *errmsg = NULL;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/", &sql, &sql_len, &mode, &errmsg)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
                            ZEND_NUM_ARGS() TSRMLS_CC, "sr|lz/", &sql, &sql_len, &zdb, &mode, &errmsg) &&
                     FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|lz/", &zdb, &sql, &sql_len, &mode, &errmsg)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       if (errmsg) {
              zval_dtor(errmsg);
              ZVAL_NULL(errmsg);
       }

       PHP_SQLITE_EMPTY_QUERY;

       /* avoid doing work if we can */
       if (!return_value_used) {
              db->last_err_code = sqlite_exec(db->db, sql, NULL, NULL, &errtext);

              if (db->last_err_code != SQLITE_OK) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
                     if (errmsg) {
                            ZVAL_STRING(errmsg, errtext, 1);
                     }
                     sqlite_freemem(errtext);
              }
              return;
       }

       sqlite_query(object, db, sql, sql_len, (int)mode, 0, return_value, NULL, errmsg TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_array_query  )

Definition at line 2485 of file sqlite.c.

{
       zval *zdb, *ent;
       struct php_sqlite_db *db;
       struct php_sqlite_result *rres;
       char *sql;
       int sql_len;
       long mode = PHPSQLITE_BOTH;
       char *errtext = NULL;
       zend_bool decode_binary = 1;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lb", &sql, &sql_len, &mode, &decode_binary)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
                            ZEND_NUM_ARGS() TSRMLS_CC, "sr|lb", &sql, &sql_len, &zdb, &mode, &decode_binary) &&
                     FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|lb", &zdb, &sql, &sql_len, &mode, &decode_binary)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       PHP_SQLITE_EMPTY_QUERY;

       /* avoid doing work if we can */
       if (!return_value_used) {
              db->last_err_code = sqlite_exec(db->db, sql, NULL, NULL, &errtext);

              if (db->last_err_code != SQLITE_OK) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
                     sqlite_freemem(errtext);
              }
              return;
       }

       rres = (struct php_sqlite_result *)ecalloc(1, sizeof(*rres));
       sqlite_query(NULL, db, sql, sql_len, (int)mode, 0, NULL, &rres, NULL TSRMLS_CC);
       if (db->last_err_code != SQLITE_OK) {
              if (rres) {
                     efree(rres);
              }
              RETURN_FALSE;
       }

       array_init(return_value);

       while (rres->curr_row < rres->nrows) {
              MAKE_STD_ZVAL(ent);
              php_sqlite_fetch_array(rres, mode, decode_binary, 1, ent TSRMLS_CC);
              add_next_index_zval(return_value, ent);
       }
       real_result_dtor(rres TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_single_query  )

Definition at line 2601 of file sqlite.c.

{
       zval *zdb, *ent;
       struct php_sqlite_db *db;
       struct php_sqlite_result *rres;
       char *sql;
       int sql_len;
       char *errtext = NULL;
       zend_bool decode_binary = 1;
       zend_bool srow = 1;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|bb", &sql, &sql_len, &srow, &decode_binary)) {
                     return;
              }
              RES_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
                            ZEND_NUM_ARGS() TSRMLS_CC, "sr|bb", &sql, &sql_len, &zdb, &srow, &decode_binary) &&
                     FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|bb", &zdb, &sql, &sql_len, &srow, &decode_binary)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       PHP_SQLITE_EMPTY_QUERY;

       /* avoid doing work if we can */
       if (!return_value_used) {
              db->last_err_code = sqlite_exec(db->db, sql, NULL, NULL, &errtext);

              if (db->last_err_code != SQLITE_OK) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
                     sqlite_freemem(errtext);
              }
              return;
       }

       rres = (struct php_sqlite_result *)ecalloc(1, sizeof(*rres));
       sqlite_query(NULL, db, sql, sql_len, PHPSQLITE_NUM, 0, NULL, &rres, NULL TSRMLS_CC);
       if (db->last_err_code != SQLITE_OK) {
              if (rres) {
                     efree(rres);
              }
              RETURN_FALSE;
       }

       if (!srow) {
              array_init(return_value);
       }

       while (rres->curr_row < rres->nrows) {
              MAKE_STD_ZVAL(ent);
              php_sqlite_fetch_single(rres, decode_binary, ent TSRMLS_CC);

              /* if set and we only have 1 row in the result set, return the result as a string. */
              if (srow) {
                     if (rres->curr_row == 1 && rres->curr_row >= rres->nrows) {
                            *return_value = *ent;
                            zval_copy_ctor(return_value);
                            zval_dtor(ent);
                            FREE_ZVAL(ent);
                            break;
                     } else {
                            srow = 0;
                            array_init(return_value);
                     }
              }
              add_next_index_zval(return_value, ent);
       }

       real_result_dtor(rres TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_fetch_array  )

Definition at line 2334 of file sqlite.c.

{
       zval *zres;
       long mode = PHPSQLITE_BOTH;
       zend_bool decode_binary = 1;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lb", &mode, &decode_binary)) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
              if (!ZEND_NUM_ARGS()) {
                     mode = res->mode;
              }
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|lb", &zres, &mode, &decode_binary)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
              if (ZEND_NUM_ARGS() < 2) {
                     mode = res->mode;
              }
       }

       php_sqlite_fetch_array(res, mode, decode_binary, 1, return_value TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_fetch_object  )

Definition at line 2367 of file sqlite.c.

{
       zval *zres;
       zend_bool decode_binary = 1;
       struct php_sqlite_result *res;
       zval *object = getThis();
       char *class_name = NULL;
       int class_name_len;
       zend_class_entry *ce;
       zval dataset;
       zend_fcall_info fci;
       zend_fcall_info_cache fcc;
       zval *retval_ptr;
       zval *ctor_params = NULL;
       zend_error_handling error_handling;

       zend_replace_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception, &error_handling TSRMLS_CC);
       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|szb", &class_name, &class_name_len, &ctor_params, &decode_binary)) {
                     zend_restore_error_handling(&error_handling TSRMLS_CC);
                     return;
              }
              RES_FROM_OBJECT_RESTORE_ERH(res, object, &error_handling);
              if (!class_name) {
                     ce = zend_standard_class_def;
              } else {
                     ce = zend_fetch_class(class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
              }
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|szb", &zres, &class_name, &class_name_len, &ctor_params, &decode_binary)) {
                     zend_restore_error_handling(&error_handling TSRMLS_CC);
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
              if (!class_name) {
                     ce = zend_standard_class_def;
              } else {
                     ce = zend_fetch_class(class_name, class_name_len, ZEND_FETCH_CLASS_AUTO TSRMLS_CC);
              }
       }

       if (!ce) {
              zend_throw_exception_ex(sqlite_ce_exception, 0 TSRMLS_CC, "Could not find class '%s'", class_name);
              zend_restore_error_handling(&error_handling TSRMLS_CC);
              return;
       }

       if (res->curr_row < res->nrows) {
              php_sqlite_fetch_array(res, PHPSQLITE_ASSOC, decode_binary, 1, &dataset TSRMLS_CC);
       } else {
              zend_restore_error_handling(&error_handling TSRMLS_CC);
              RETURN_FALSE;
       }

       object_and_properties_init(return_value, ce, NULL);
       zend_merge_properties(return_value, Z_ARRVAL(dataset), 1 TSRMLS_CC);

       zend_restore_error_handling(&error_handling TSRMLS_CC);

       if (ce->constructor) {
              fci.size = sizeof(fci);
              fci.function_table = &ce->function_table;
              fci.function_name = NULL;
              fci.symbol_table = NULL;
              fci.object_ptr = return_value;
              fci.retval_ptr_ptr = &retval_ptr;
              if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
                     if (Z_TYPE_P(ctor_params) == IS_ARRAY) {
                            HashTable *ht = Z_ARRVAL_P(ctor_params);
                            Bucket *p;

                            fci.param_count = 0;
                            fci.params = safe_emalloc(sizeof(zval*), ht->nNumOfElements, 0);
                            p = ht->pListHead;
                            while (p != NULL) {
                                   fci.params[fci.param_count++] = (zval**)p->pData;
                                   p = p->pListNext;
                            }
                     } else {
                            /* Two problems why we throw exceptions here: PHP is typeless
                             * and hence passing one argument that's not an array could be
                             * by mistake and the other way round is possible, too. The
                             * single value is an array. Also we'd have to make that one
                             * argument passed by reference.
                             */
                            zend_throw_exception(sqlite_ce_exception, "Parameter ctor_params must be an array", 0 TSRMLS_CC);
                            return;
                     }
              } else {
                     fci.param_count = 0;
                     fci.params = NULL;
              }
              fci.no_separation = 1;

              fcc.initialized = 1;
              fcc.function_handler = ce->constructor;
              fcc.calling_scope = EG(scope);
              fcc.called_scope = Z_OBJCE_P(return_value);
              fcc.object_ptr = return_value;

              if (zend_call_function(&fci, &fcc TSRMLS_CC) == FAILURE) {
                     zend_throw_exception_ex(sqlite_ce_exception, 0 TSRMLS_CC, "Could not execute %s::%s()", class_name, ce->constructor->common.function_name);
              } else {
                     if (retval_ptr) {
                            zval_ptr_dtor(&retval_ptr);
                     }
              }
              if (fci.params) {
                     efree(fci.params);
              }
       } else if (ctor_params && Z_TYPE_P(ctor_params) != IS_NULL) {
              zend_throw_exception_ex(sqlite_ce_exception, 0 TSRMLS_CC, "Class %s does not have a constructor, use NULL for parameter ctor_params or omit it", class_name);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_fetch_single  )

Definition at line 2680 of file sqlite.c.

{
       zval *zres;
       zend_bool decode_binary = 1;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &decode_binary)) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|b", &zres, &decode_binary)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       php_sqlite_fetch_single(res, decode_binary, return_value TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_fetch_all  )

Definition at line 2288 of file sqlite.c.

{
       zval *zres, *ent;
       long mode = PHPSQLITE_BOTH;
       zend_bool decode_binary = 1;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lb", &mode, &decode_binary)) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
              if (!ZEND_NUM_ARGS()) {
                     mode = res->mode;
              }
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|lb", &zres, &mode, &decode_binary)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
              if (ZEND_NUM_ARGS() < 2) {
                     mode = res->mode;
              }
       }

       if (res->curr_row >= res->nrows && res->nrows) {
              if (!res->buffered) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "One or more rowsets were already returned; returning NULL this time");
              } else {
                     res->curr_row = 0;
              }
       }

       array_init(return_value);

       while (res->curr_row < res->nrows) {
              MAKE_STD_ZVAL(ent);
              php_sqlite_fetch_array(res, mode, decode_binary, 1, ent TSRMLS_CC);
              add_next_index_zval(return_value, ent);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_current  )

Definition at line 2705 of file sqlite.c.

{
       zval *zres;
       long mode = PHPSQLITE_BOTH;
       zend_bool decode_binary = 1;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (ZEND_NUM_ARGS() && FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lb", &mode, &decode_binary)) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
              if (!ZEND_NUM_ARGS()) {
                     mode = res->mode;
              }
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|lb", &zres, &mode, &decode_binary)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
              if (ZEND_NUM_ARGS() < 2) {
                     mode = res->mode;
              }
       }

       php_sqlite_fetch_array(res, mode, decode_binary, 0, return_value TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_column  )

Definition at line 2737 of file sqlite.c.

{
       zval *zres;
       zval *which;
       zend_bool decode_binary = 1;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &which, &decode_binary)) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|b", &zres, &which, &decode_binary)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       php_sqlite_fetch_column(res, which, decode_binary, return_value TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_num_rows  )

Definition at line 2851 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       if (res->buffered) {
              RETURN_LONG(res->nrows);
       } else {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Row count is not available for unbuffered queries");
              RETURN_FALSE;
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_num_fields  )

Definition at line 2933 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       RETURN_LONG(res->ncolumns);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_field_name  )

Definition at line 2957 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       long field;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &field)) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zres, &field)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       if (field < 0 || field >= res->ncolumns) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "field %ld out of range", field);
              RETURN_FALSE;
       }

       RETURN_STRING(res->col_names[field], 1);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_seek  )

Definition at line 2987 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       long row;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &row)) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zres, &row)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       if (!res->buffered) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot seek an unbuffered result set");
              RETURN_FALSE;
       }

       if (row < 0 || row >= res->nrows) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "row %ld out of range", row);
              RETURN_FALSE;
       }

       res->curr_row = row;
       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_rewind  )

Definition at line 3023 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       if (!res->buffered) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot rewind an unbuffered result set");
              RETURN_FALSE;
       }

       if (!res->nrows) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "no rows received");
              RETURN_FALSE;
       }

       res->curr_row = 0;
       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_next  )

Definition at line 3058 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       if (!res->buffered && res->vm) {
              php_sqlite_fetch(res TSRMLS_CC);
       }

       if (res->curr_row >= res->nrows) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "no more rows available");
              RETURN_FALSE;
       }

       res->curr_row++;

       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_prev  )

Definition at line 3117 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       if (!res->buffered) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "you cannot use sqlite_prev on unbuffered querys");
              RETURN_FALSE;
       }

       if (res->curr_row <= 0) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "no previous row available");
              RETURN_FALSE;
       }

       res->curr_row--;

       RETURN_TRUE;
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_key  )

Definition at line 3093 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       RETURN_LONG(res->curr_row);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_valid  )

Definition at line 2880 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       RETURN_BOOL(res->curr_row < res->nrows && res->nrows); /* curr_row may be -1 */
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_has_prev  )

Definition at line 2904 of file sqlite.c.

{
       zval *zres;
       struct php_sqlite_result *res;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              RES_FROM_OBJECT(res, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zres)) {
                     return;
              }
              ZEND_FETCH_RESOURCE(res, struct php_sqlite_result *, &zres, -1, "sqlite result", le_sqlite_result);
       }

       if(!res->buffered) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "you cannot use sqlite_has_prev on unbuffered querys");
              RETURN_FALSE;
       }

       RETURN_BOOL(res->curr_row);
}

Here is the call graph for this function:

Definition at line 2763 of file sqlite.c.

{
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }
       RETURN_STRING((char*)sqlite_libversion(), 1);
}

Here is the call graph for this function:

Definition at line 2774 of file sqlite.c.

{
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }
       RETURN_STRING((char*)sqlite_libencoding(), 1);
}

Here is the call graph for this function:

Definition at line 2785 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zdb)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       RETURN_LONG(sqlite_changes(db->db));
}

Here is the call graph for this function:

Definition at line 2809 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zdb)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       RETURN_LONG(sqlite_last_insert_rowid(db->db));
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_escape_string  )

Definition at line 3153 of file sqlite.c.

{
       char *string = NULL;
       int stringlen;
       char *ret;

       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &string, &stringlen)) {
              return;
       }

       if (stringlen && (string[0] == '\x01' || memchr(string, '\0', stringlen) != NULL)) {
              /* binary string */
              int enclen;

              ret = safe_emalloc(1 + stringlen / 254, 257, 3);
              ret[0] = '\x01';
              enclen = php_sqlite_encode_binary(string, stringlen, ret+1);
              RETVAL_STRINGL(ret, enclen+1, 0);

       } else if (stringlen) {
              ret = sqlite_mprintf("%q", string);
              if (ret) {
                     RETVAL_STRING(ret, 1);
                     sqlite_freemem(ret);
              }
       } else {
              RETURN_EMPTY_STRING();
       }
}

Here is the call graph for this function:

Definition at line 1731 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       long ms;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ms)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &zdb, &ms)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       sqlite_busy_timeout(db->db, ms);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_last_error  )

Definition at line 3186 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       zval *object = getThis();

       if (object) {
              if (zend_parse_parameters_none() == FAILURE) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zdb)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       RETURN_LONG(db->last_err_code);
}

Here is the call graph for this function:

Definition at line 3210 of file sqlite.c.

{
       long code;
       const char *msg;

       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code)) {
              return;
       }

       msg = sqlite_error_string(code);

       if (msg) {
              RETURN_STRING((char*)msg, 1);
       } else {
              RETURN_NULL();
       }
}

Here is the call graph for this function:

Definition at line 3295 of file sqlite.c.

{
       char *funcname = NULL;
       int funcname_len;
       zval *zstep, *zfinal, *zdb;
       struct php_sqlite_db *db;
       struct php_sqlite_agg_functions *funcs;
       char *callable = NULL;
       long num_args = -1;
       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "szz|l", &funcname, &funcname_len, &zstep, &zfinal, &num_args)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rszz|l", &zdb, &funcname, &funcname_len, &zstep, &zfinal, &num_args)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       if (!zend_is_callable(zstep, 0, &callable TSRMLS_CC)) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "step function `%s' is not callable", callable);
              efree(callable);
              return;
       }
       efree(callable);

       if (!zend_is_callable(zfinal, 0, &callable TSRMLS_CC)) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "finalize function `%s' is not callable", callable);
              efree(callable);
              return;
       }
       efree(callable);


       if (prep_callback_struct(db, 1, funcname, zstep, zfinal, &funcs) == DO_REG) {
              sqlite_create_aggregate(db->db, funcname, num_args,
                            php_sqlite_agg_step_function_callback,
                            php_sqlite_agg_fini_function_callback, funcs);
       }


}

Here is the call graph for this function:

Definition at line 3345 of file sqlite.c.

{
       char *funcname = NULL;
       int funcname_len;
       zval *zcall, *zdb;
       struct php_sqlite_db *db;
       struct php_sqlite_agg_functions *funcs;
       char *callable = NULL;
       long num_args = -1;

       zval *object = getThis();

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz|l", &funcname, &funcname_len, &zcall, &num_args)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsz|l", &zdb, &funcname, &funcname_len, &zcall, &num_args)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       if (!zend_is_callable(zcall, 0, &callable TSRMLS_CC)) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "function `%s' is not callable", callable);
              efree(callable);
              return;
       }
       efree(callable);

       if (prep_callback_struct(db, 0, funcname, zcall, NULL, &funcs) == DO_REG) {
              sqlite_create_function(db->db, funcname, num_args, php_sqlite_function_callback, funcs);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_udf_decode_binary  )

Definition at line 3413 of file sqlite.c.

{
       char *data = NULL;
       int datalen;

       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &data, &datalen)) {
              return;
       }

       if (data == NULL) {
              RETURN_NULL();
       }
       if (datalen && data[0] == '\x01') {
              /* encoded string */
              int enclen;
              char *ret;

              ret = emalloc(datalen);
              enclen = php_sqlite_decode_binary(data+1, ret);
              ret[enclen] = '\0';
              RETVAL_STRINGL(ret, enclen, 0);
       } else {
              RETVAL_STRINGL(data, datalen, 1);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_udf_encode_binary  )

Definition at line 3384 of file sqlite.c.

{
       char *data = NULL;
       int datalen;

       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &data, &datalen)) {
              return;
       }

       if (data == NULL) {
              RETURN_NULL();
       }
       if (datalen && (data[0] == '\x01' || memchr(data, '\0', datalen) != NULL)) {
              /* binary string */
              int enclen;
              char *ret;

              ret = safe_emalloc(1 + datalen / 254, 257, 3);
              ret[0] = '\x01';
              enclen = php_sqlite_encode_binary(data, datalen, ret+1);
              RETVAL_STRINGL(ret, enclen+1, 0);
       } else {
              RETVAL_STRINGL(data, datalen, 1);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_factory  )

Definition at line 1682 of file sqlite.c.

{
       long mode = 0666;
       char *filename, *fullpath = NULL;
       int filename_len;
       zval *errmsg = NULL;
       zend_error_handling error_handling;

       zend_replace_error_handling(EH_THROW, sqlite_ce_exception, &error_handling TSRMLS_CC);
       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
                            &filename, &filename_len, &mode, &errmsg)) {
              zend_restore_error_handling(&error_handling TSRMLS_CC);
              RETURN_NULL();
       }
       if (errmsg) {
              zval_dtor(errmsg);
              ZVAL_NULL(errmsg);
       }

       if (strlen(filename) != filename_len) {
              zend_restore_error_handling(&error_handling TSRMLS_CC);
              RETURN_FALSE;
       }

       if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
              /* resolve the fully-qualified path name to use as the hash key */
              if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
                     zend_restore_error_handling(&error_handling TSRMLS_CC);
                     RETURN_NULL();
              }

              if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) ||
                            php_check_open_basedir(fullpath TSRMLS_CC)) {
                     efree(fullpath);
                     zend_restore_error_handling(&error_handling TSRMLS_CC);
                     RETURN_NULL();
              }
       }

       php_sqlite_open(fullpath ? fullpath : filename, (int)mode, NULL, return_value, errmsg, return_value TSRMLS_CC);
       if (fullpath) {
              efree(fullpath);
       }
       zend_restore_error_handling(&error_handling TSRMLS_CC);
}

Here is the call graph for this function:

PHP_FUNCTION ( sqlite_fetch_column_types  )

Definition at line 1991 of file sqlite.c.

{
       zval *zdb;
       struct php_sqlite_db *db;
       char *tbl, *sql;
       int tbl_len;
       char *errtext = NULL;
       zval *object = getThis();
       struct php_sqlite_result res;
       const char **rowdata, **colnames, *tail;
       int i, ncols;
       long result_type = PHPSQLITE_ASSOC;

       if (object) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &tbl, &tbl_len, &result_type)) {
                     return;
              }
              DB_FROM_OBJECT(db, object);
       } else {
              if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
                            ZEND_NUM_ARGS() TSRMLS_CC, "sr|l", &tbl, &tbl_len, &zdb, &result_type) &&
                     FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &zdb, &tbl, &tbl_len, &result_type)) {
                     return;
              }
              DB_FROM_ZVAL(db, &zdb);
       }

       if (!(sql = sqlite_mprintf("SELECT * FROM '%q' LIMIT 1", tbl))) {
              RETURN_FALSE;
       }

       sqlite_exec(db->db, "PRAGMA show_datatypes = ON", NULL, NULL, NULL);

       db->last_err_code = sqlite_compile(db->db, sql, &tail, &res.vm, &errtext);

       sqlite_freemem(sql);

       if (db->last_err_code != SQLITE_OK) {
              php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errtext);
              sqlite_freemem(errtext);
              RETVAL_FALSE;
              goto done;
       }

       sqlite_step(res.vm, &ncols, &rowdata, &colnames);

       array_init(return_value);

       for (i = 0; i < ncols; i++) {
              if (result_type == PHPSQLITE_ASSOC) {
                     char *colname = estrdup((char *)colnames[i]);

                     if (SQLITE_G(assoc_case) == 1) {
                            php_sqlite_strtoupper(colname);
                     } else if (SQLITE_G(assoc_case) == 2) {
                            php_sqlite_strtolower(colname);
                     }

                     add_assoc_string(return_value, colname, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
                     efree(colname);
              }
              if (result_type == PHPSQLITE_NUM) {
                     add_index_string(return_value, i, colnames[ncols + i] ? (char *)colnames[ncols + i] : "", 1);
              }
       }
       if (res.vm) {
              sqlite_finalize(res.vm, NULL);
       }
done:
       sqlite_exec(db->db, "PRAGMA show_datatypes = OFF", NULL, NULL, NULL);
}

Here is the call graph for this function:

Definition at line 1457 of file sqlite.c.

{
       php_info_print_table_start();
       php_info_print_table_header(2, "SQLite support", "enabled");
       php_info_print_table_row(2, "PECL Module version", PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c 321634 2012-01-01 13:15:04Z felipe $");
       php_info_print_table_row(2, "SQLite Library", sqlite_libversion());
       php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding());
       php_info_print_table_end();

       DISPLAY_INI_ENTRIES();
}

Here is the call graph for this function:

Definition at line 1363 of file sqlite.c.

{
       REGISTER_SQLITE_CLASS(Database,   db,        NULL);
       REGISTER_SQLITE_CLASS(Result,     query,     NULL);
       REGISTER_SQLITE_CLASS(Unbuffered, ub_query,  NULL);
#if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
       REGISTER_SQLITE_CLASS(Exception,  exception, spl_ce_RuntimeException);
#else
       REGISTER_SQLITE_CLASS(Exception,  exception, zend_exception_get_default(TSRMLS_C));
#endif

       sqlite_ce_db->ce_flags &= ~ZEND_ACC_FINAL_CLASS;
       sqlite_ce_db->constructor->common.fn_flags |= ZEND_ACC_FINAL;

       sqlite_object_handlers_query.get_class_entry = sqlite_get_ce_query;
       sqlite_object_handlers_ub_query.get_class_entry = sqlite_get_ce_ub_query;
       sqlite_object_handlers_ub_query.count_elements = sqlite_count_elements;

       sqlite_ce_ub_query->get_iterator = sqlite_get_iterator;
       sqlite_ce_ub_query->iterator_funcs.funcs = &sqlite_ub_query_iterator_funcs;

#if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 1))
       zend_class_implements(sqlite_ce_query TSRMLS_CC, 2, zend_ce_iterator, spl_ce_Countable);
#else
       zend_class_implements(sqlite_ce_query TSRMLS_CC, 1, zend_ce_iterator);
#endif
       sqlite_ce_query->get_iterator = sqlite_get_iterator;
       sqlite_ce_query->iterator_funcs.funcs = &sqlite_query_iterator_funcs;

       REGISTER_INI_ENTRIES();

#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
       php_session_register_module(ps_sqlite_ptr);
#endif

       le_sqlite_db = zend_register_list_destructors_ex(php_sqlite_db_dtor, NULL, "sqlite database", module_number);
       le_sqlite_pdb = zend_register_list_destructors_ex(NULL, php_sqlite_db_dtor, "sqlite database (persistent)", module_number);
       le_sqlite_result = zend_register_list_destructors_ex(php_sqlite_result_dtor, NULL, "sqlite result", module_number);

       REGISTER_LONG_CONSTANT("SQLITE_BOTH",     PHPSQLITE_BOTH, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_NUM",      PHPSQLITE_NUM, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_ASSOC",    PHPSQLITE_ASSOC, CONST_CS|CONST_PERSISTENT);

       REGISTER_LONG_CONSTANT("SQLITE_OK",                            SQLITE_OK, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_ERROR",                  SQLITE_ERROR, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_INTERNAL",        SQLITE_INTERNAL, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_PERM",                   SQLITE_PERM, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_ABORT",                  SQLITE_ABORT, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_BUSY",                   SQLITE_BUSY, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_LOCKED",                 SQLITE_LOCKED, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_NOMEM",                  SQLITE_NOMEM, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_READONLY",        SQLITE_READONLY, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_INTERRUPT",              SQLITE_INTERRUPT, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_IOERR",                  SQLITE_IOERR, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_CORRUPT",         SQLITE_CORRUPT, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_NOTFOUND",        SQLITE_NOTFOUND, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_FULL",                   SQLITE_FULL, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_CANTOPEN",        SQLITE_CANTOPEN, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_PROTOCOL",        SQLITE_PROTOCOL, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_EMPTY",                  SQLITE_EMPTY, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_SCHEMA",                 SQLITE_SCHEMA, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_TOOBIG",                 SQLITE_TOOBIG, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_CONSTRAINT",             SQLITE_CONSTRAINT, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_MISMATCH",        SQLITE_MISMATCH, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_MISUSE",                 SQLITE_MISUSE, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_NOLFS",                  SQLITE_NOLFS, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_AUTH",                   SQLITE_AUTH, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_NOTADB",                 SQLITE_NOTADB, CONST_CS|CONST_PERSISTENT);
#ifdef SQLITE_FORMAT
       REGISTER_LONG_CONSTANT("SQLITE_FORMAT",                 SQLITE_FORMAT, CONST_CS|CONST_PERSISTENT);
#endif
       REGISTER_LONG_CONSTANT("SQLITE_ROW",                    SQLITE_ROW, CONST_CS|CONST_PERSISTENT);
       REGISTER_LONG_CONSTANT("SQLITE_DONE",                   SQLITE_DONE, CONST_CS|CONST_PERSISTENT);

#ifdef PHP_SQLITE2_HAVE_PDO
    if (FAILURE == php_pdo_register_driver(&pdo_sqlite2_driver)) {
       return FAILURE;
    }
#endif

       return SUCCESS;
}

Here is the call graph for this function:

Definition at line 1446 of file sqlite.c.

{
       UNREGISTER_INI_ENTRIES();

#ifdef PHP_SQLITE2_HAVE_PDO
    php_pdo_unregister_driver(&pdo_sqlite2_driver);
#endif

       return SUCCESS;
}

Here is the call graph for this function:

Definition at line 761 of file sqlite.c.

Here is the call graph for this function:


Variable Documentation

long assoc_case

Definition at line 89 of file php_sqlite.h.

zend_module_entry sqlite_module_entry

Definition at line 609 of file sqlite.c.