mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Forgot to add these earlier
SQLite3 extension, still has 2 failing tests that will be sorted shortly.
This commit is contained in:
4
ext/sqlite3/CREDITS
Normal file
4
ext/sqlite3/CREDITS
Normal file
@@ -0,0 +1,4 @@
|
||||
SQLite3
|
||||
|
||||
Scott MacVicar
|
||||
|
||||
86
ext/sqlite3/config.m4
Normal file
86
ext/sqlite3/config.m4
Normal file
@@ -0,0 +1,86 @@
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension sqlite3
|
||||
dnl vim:et:ts=2:sw=2
|
||||
|
||||
PHP_ARG_WITH(sqlite3, whether to enable the SQLite3 extension,
|
||||
[ --with-sqlite3[=DIR] Include SQLite3 support. DIR is the prefix to
|
||||
SQLite3 installation directory.], no)
|
||||
|
||||
if test $PHP_SQLITE3 != "no"; then
|
||||
sqlite3_extra_sources=""
|
||||
PHP_SQLITE3_CFLAGS=""
|
||||
|
||||
dnl when running phpize enable_maintainer_zts is not available
|
||||
if test -z "$enable_maintainer_zts"; then
|
||||
if test -f "$phpincludedir/main/php_config.h"; then
|
||||
ZTS=`grep '#define ZTS' $phpincludedir/main/php_config.h|$SED 's/#define ZTS//'`
|
||||
if test "$ZTS" -eq "1"; then
|
||||
enable_maintainer_zts="yes"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $PHP_SQLITE3 != "yes"; then
|
||||
AC_MSG_CHECKING([for sqlite3 files in default path])
|
||||
for i in $PHP_SQLITE3 /usr/local /usr; do
|
||||
if test -r $i/include/sqlite3.h; then
|
||||
SQLITE3_DIR=$i
|
||||
AC_MSG_RESULT(found in $i)
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$SQLITE3_DIR"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please reinstall the sqlite distribution from http://www.sqlite.org])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for SQLite 3.3.9+])
|
||||
PHP_CHECK_LIBRARY(sqlite3, sqlite3_prepare_v2, [
|
||||
AC_MSG_RESULT(found)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(sqlite3, $SQLITE3_DIR/$PHP_LIBDIR, SQLITE3_SHARED_LIBADD)
|
||||
PHP_ADD_INCLUDE($SQLITE3_DIR/include)
|
||||
],[
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please install SQLite 3.3.9 first or check libsqlite3 is present])
|
||||
],[
|
||||
-L$SQLITE3_DIR/$PHP_LIBDIR -lm
|
||||
])
|
||||
|
||||
PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
|
||||
AC_DEFINE(HAVE_SQLITE3_KEY, 1, [have commercial sqlite3 with crypto support])
|
||||
])
|
||||
|
||||
else
|
||||
AC_MSG_CHECKING([built in sqlite3 library])
|
||||
AC_MSG_RESULT([yes])
|
||||
|
||||
sqlite3_extra_sources="libsqlite/sqlite3.c"
|
||||
|
||||
if test "$enable_maintainer_zts" = "yes"; then
|
||||
threadsafe_flags="-DSQLITE_THREADSAFE=1"
|
||||
else
|
||||
threadsafe_flags="-DSQLITE_THREADSAFE=0"
|
||||
fi
|
||||
|
||||
if test "$ZEND_DEBUG" = "yes"; then
|
||||
debug_flags="-DSQLITE_DEBUG=1"
|
||||
fi
|
||||
|
||||
other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_CORE=1"
|
||||
|
||||
dnl if test "$PHP_MAJOR_VERSION" -ge "6"; then
|
||||
dnl other_flags="$other_flags -DSQLITE_ENABLE_ICU=1"
|
||||
dnl fi
|
||||
|
||||
PHP_SQLITE3_CFLAGS="-I@ext_srcdir@/libsqlite -I@ext_builddir@/libsqlite $other_flags $threadsafe_flags $debug_flags"
|
||||
fi
|
||||
|
||||
AC_DEFINE(HAVE_SQLITE3,1,[ ])
|
||||
|
||||
sqlite3_sources="sqlite3.c $sqlite3_extra_sources"
|
||||
|
||||
PHP_NEW_EXTENSION(sqlite3, $sqlite3_sources, $ext_shared, ,$PHP_SQLITE3_CFLAGS)
|
||||
PHP_SUBST(SQLITE3_SHARED_LIBADD)
|
||||
|
||||
fi
|
||||
17
ext/sqlite3/config.w32
Normal file
17
ext/sqlite3/config.w32
Normal file
@@ -0,0 +1,17 @@
|
||||
// $Id$
|
||||
// vim:ft=javascript
|
||||
|
||||
ARG_WITH("sqlite3", "SQLite 3 support", "no");
|
||||
|
||||
if (PHP_SQLITE3 != "no") {
|
||||
ADD_FLAG("CFLAGS_SQLITE3", "/D SQLITE_THREADSAFE=1 /D SQLITE_ENABLE_FTS3=1 /D SQLITE_CORE=1 ");
|
||||
EXTENSION("sqlite3", "sqlite3.c", null, "/I" + configure_module_dirname + "/libsqlite /I" + configure_module_dirname);
|
||||
|
||||
ADD_SOURCES(configure_module_dirname + "/libsqlite", "sqlite3.c", "sqlite3");
|
||||
|
||||
AC_DEFINE("HAVE_SQLITE3", 1, "SQLite support");
|
||||
|
||||
if (!PHP_SQLITE3_SHARED) {
|
||||
ADD_DEF_FILE(configure_module_dirname + "\\php_sqlite3.def");
|
||||
}
|
||||
}
|
||||
86
ext/sqlite3/config0.m4
Normal file
86
ext/sqlite3/config0.m4
Normal file
@@ -0,0 +1,86 @@
|
||||
dnl $Id$
|
||||
dnl config.m4 for extension sqlite3
|
||||
dnl vim:et:ts=2:sw=2
|
||||
|
||||
PHP_ARG_WITH(sqlite3, whether to enable the SQLite3 extension,
|
||||
[ --with-sqlite3[=DIR] Include SQLite3 support. DIR is the prefix to
|
||||
SQLite3 installation directory.], no)
|
||||
|
||||
if test $PHP_SQLITE3 != "no"; then
|
||||
sqlite3_extra_sources=""
|
||||
PHP_SQLITE3_CFLAGS=""
|
||||
|
||||
dnl when running phpize enable_maintainer_zts is not available
|
||||
if test -z "$enable_maintainer_zts"; then
|
||||
if test -f "$phpincludedir/main/php_config.h"; then
|
||||
ZTS=`grep '#define ZTS' $phpincludedir/main/php_config.h|$SED 's/#define ZTS//'`
|
||||
if test "$ZTS" -eq "1"; then
|
||||
enable_maintainer_zts="yes"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $PHP_SQLITE3 != "yes"; then
|
||||
AC_MSG_CHECKING([for sqlite3 files in default path])
|
||||
for i in $PHP_SQLITE3 /usr/local /usr; do
|
||||
if test -r $i/include/sqlite3.h; then
|
||||
SQLITE3_DIR=$i
|
||||
AC_MSG_RESULT(found in $i)
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$SQLITE3_DIR"; then
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please reinstall the sqlite distribution from http://www.sqlite.org])
|
||||
fi
|
||||
|
||||
AC_MSG_CHECKING([for SQLite 3.3.9+])
|
||||
PHP_CHECK_LIBRARY(sqlite3, sqlite3_prepare_v2, [
|
||||
AC_MSG_RESULT(found)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(sqlite3, $SQLITE3_DIR/$PHP_LIBDIR, SQLITE3_SHARED_LIBADD)
|
||||
PHP_ADD_INCLUDE($SQLITE3_DIR/include)
|
||||
],[
|
||||
AC_MSG_RESULT([not found])
|
||||
AC_MSG_ERROR([Please install SQLite 3.3.9 first or check libsqlite3 is present])
|
||||
],[
|
||||
-L$SQLITE3_DIR/$PHP_LIBDIR -lm
|
||||
])
|
||||
|
||||
PHP_CHECK_LIBRARY(sqlite3,sqlite3_key,[
|
||||
AC_DEFINE(HAVE_SQLITE3_KEY, 1, [have commercial sqlite3 with crypto support])
|
||||
])
|
||||
|
||||
else
|
||||
AC_MSG_CHECKING([built in sqlite3 library])
|
||||
AC_MSG_RESULT([yes])
|
||||
|
||||
sqlite3_extra_sources="libsqlite/sqlite3.c"
|
||||
|
||||
if test "$enable_maintainer_zts" = "yes"; then
|
||||
threadsafe_flags="-DSQLITE_THREADSAFE=1"
|
||||
else
|
||||
threadsafe_flags="-DSQLITE_THREADSAFE=0"
|
||||
fi
|
||||
|
||||
if test "$ZEND_DEBUG" = "yes"; then
|
||||
debug_flags="-DSQLITE_DEBUG=1"
|
||||
fi
|
||||
|
||||
other_flags="-DSQLITE_ENABLE_FTS3=1 -DSQLITE_CORE=1"
|
||||
|
||||
dnl if test "$PHP_MAJOR_VERSION" -ge "6"; then
|
||||
dnl other_flags="$other_flags -DSQLITE_ENABLE_ICU=1"
|
||||
dnl fi
|
||||
|
||||
PHP_SQLITE3_CFLAGS="-I@ext_srcdir@/libsqlite -I@ext_builddir@/libsqlite $other_flags $threadsafe_flags $debug_flags"
|
||||
fi
|
||||
|
||||
AC_DEFINE(HAVE_SQLITE3,1,[ ])
|
||||
|
||||
sqlite3_sources="sqlite3.c $sqlite3_extra_sources"
|
||||
|
||||
PHP_NEW_EXTENSION(sqlite3, $sqlite3_sources, $ext_shared, ,$PHP_SQLITE3_CFLAGS)
|
||||
PHP_SUBST(SQLITE3_SHARED_LIBADD)
|
||||
|
||||
fi
|
||||
310
ext/sqlite3/php_sqlite3.h
Normal file
310
ext/sqlite3/php_sqlite3.h
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
| PHP Version 5 |
|
||||
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
| Copyright (c) 1997-2008 The PHP Group |
|
||||
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
| This source file is subject to version 3.01 of the PHP license, |
|
||||
|
||||
| that is bundled with this package in the file LICENSE, and is |
|
||||
|
||||
| available through the world-wide-web at the following url: |
|
||||
|
||||
| http://www.php.net/license/3_01.txt |
|
||||
|
||||
| If you did not receive a copy of the PHP license and are unable to |
|
||||
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
| Authors: Scott MacVicar <scottmac@php.net> |
|
||||
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
|
||||
|
||||
$Id$
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef PHP_SQLITE_H
|
||||
|
||||
#define PHP_SQLITE_H
|
||||
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
|
||||
#include "TSRM.h"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Include PHP Standard Header */
|
||||
|
||||
#include "php.h"
|
||||
|
||||
|
||||
|
||||
/* Include headers */
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
|
||||
|
||||
#define PHP_SQLITE3_VERSION "0.7-dev"
|
||||
|
||||
|
||||
|
||||
extern zend_module_entry sqlite3_module_entry;
|
||||
|
||||
#define phpext_sqlite3_ptr &sqlite3_module_entry
|
||||
|
||||
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(sqlite3)
|
||||
|
||||
char *extension_dir;
|
||||
|
||||
ZEND_END_MODULE_GLOBALS(sqlite3)
|
||||
|
||||
|
||||
|
||||
#ifdef ZTS
|
||||
|
||||
# define SQLITE3G(v) TSRMG(sqlite3_globals_id, zend_sqlite3_globals *, v)
|
||||
|
||||
#else
|
||||
|
||||
# define SQLITE3G(v) (sqlite3_globals.v)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define PHP_SQLITE3_ASSOC 1<<0
|
||||
|
||||
#define PHP_SQLITE3_NUM 1<<1
|
||||
|
||||
#define PHP_SQLITE3_BOTH (PHP_SQLITE3_ASSOC|PHP_SQLITE3_NUM)
|
||||
|
||||
|
||||
|
||||
/* for backwards compatability reasons */
|
||||
|
||||
#ifndef SQLITE_OPEN_READONLY
|
||||
|
||||
#define SQLITE_OPEN_READONLY 0x00000001
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef SQLITE_OPEN_READWRITE
|
||||
|
||||
#define SQLITE_OPEN_READWRITE 0x00000002
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef SQLITE_OPEN_CREATE
|
||||
|
||||
#define SQLITE_OPEN_CREATE 0x00000004
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* Structure for SQLite Statement Parameter. */
|
||||
|
||||
struct php_sqlite3_bound_param {
|
||||
|
||||
long param_number;
|
||||
|
||||
char *name;
|
||||
|
||||
int name_len;
|
||||
|
||||
int type;
|
||||
|
||||
|
||||
|
||||
zval *parameter;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct php_sqlite3_fci {
|
||||
|
||||
zend_fcall_info fci;
|
||||
|
||||
zend_fcall_info_cache fcc;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Structure for SQLite function. */
|
||||
|
||||
typedef struct _php_sqlite3_func {
|
||||
|
||||
struct _php_sqlite3_func *next;
|
||||
|
||||
|
||||
|
||||
const char *func_name;
|
||||
|
||||
int argc;
|
||||
|
||||
|
||||
|
||||
zval *func, *step, *fini;
|
||||
|
||||
struct php_sqlite3_fci afunc, astep, afini;
|
||||
|
||||
} php_sqlite3_func;
|
||||
|
||||
|
||||
|
||||
/* Structure for SQLite Database object. */
|
||||
|
||||
typedef struct _php_sqlite3_db_object {
|
||||
|
||||
zend_object zo;
|
||||
|
||||
int initialised;
|
||||
|
||||
sqlite3 *db;
|
||||
|
||||
php_sqlite3_func *funcs;
|
||||
|
||||
} php_sqlite3_db_object;
|
||||
|
||||
|
||||
|
||||
/*typedef struct _php_sqlite3_stmt {
|
||||
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
int initialised;
|
||||
|
||||
} php_sqlite3_stmt;*/
|
||||
|
||||
|
||||
|
||||
typedef struct _php_sqlite3_stmt_object php_sqlite3_stmt;
|
||||
|
||||
typedef struct _php_sqlite3_result_object php_sqlite3_result;
|
||||
|
||||
|
||||
|
||||
/* sqlite3 objects to be destroyed */
|
||||
|
||||
typedef struct _php_sqlite3_stmt_free_list {
|
||||
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
|
||||
|
||||
zval *statement_object;
|
||||
|
||||
zval *result_object;
|
||||
|
||||
} php_sqlite3_stmt_free_list;
|
||||
|
||||
|
||||
|
||||
/* Structure for SQLite Result object. */
|
||||
|
||||
struct _php_sqlite3_result_object {
|
||||
|
||||
zend_object zo;
|
||||
|
||||
php_sqlite3_db_object *db_obj;
|
||||
|
||||
php_sqlite3_stmt *stmt_obj;
|
||||
|
||||
zval *stmt_obj_zval;
|
||||
|
||||
|
||||
|
||||
int initialised;
|
||||
|
||||
|
||||
|
||||
int is_prepared_statement;
|
||||
|
||||
int complete;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Structure for SQLite Statement object. */
|
||||
|
||||
struct _php_sqlite3_stmt_object {
|
||||
|
||||
zend_object zo;
|
||||
|
||||
sqlite3_stmt *stmt;
|
||||
|
||||
php_sqlite3_db_object *db_obj;
|
||||
|
||||
zval *db_obj_zval;
|
||||
|
||||
|
||||
|
||||
int initialised;
|
||||
|
||||
|
||||
|
||||
/* Keep track of the zvals for bound parameters */
|
||||
|
||||
HashTable *bound_params;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
* Local variables:
|
||||
|
||||
* tab-width: 4
|
||||
|
||||
* c-basic-offset: 4
|
||||
|
||||
* indent-tabs-mode: t
|
||||
|
||||
* End:
|
||||
|
||||
*/
|
||||
|
||||
1901
ext/sqlite3/sqlite3.c
Normal file
1901
ext/sqlite3/sqlite3.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user