Skip to content

Commit 6726111

Browse files
committed
Import our own home-grown sqlite extension.
# This took less than 2 hours to implement "by hand"!
0 parents  commit 6726111

File tree

7 files changed

+564
-0
lines changed

7 files changed

+564
-0
lines changed

ext/sqlite/CREDITS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sqlite
2+
Wez Furlong

ext/sqlite/EXPERIMENTAL

Whitespace-only changes.

ext/sqlite/config.m4

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
dnl $Id$
2+
dnl config.m4 for extension sqlite
3+
4+
PHP_ARG_WITH(sqlite, for sqlite support,
5+
[ --with-sqlite Include sqlite support])
6+
7+
if test "$PHP_SQLITE" != "no"; then
8+
SEARCH_PATH="/usr/local /usr"
9+
SEARCH_FOR="/include/sqlite.h"
10+
if test -r $PHP_SQLITE/; then # path given as parameter
11+
SQLITE_DIR=$PHP_SQLITE
12+
else # search default path list
13+
AC_MSG_CHECKING([for sqlite files in default path])
14+
for i in $SEARCH_PATH ; do
15+
if test -r $i/$SEARCH_FOR; then
16+
SQLITE_DIR=$i
17+
AC_MSG_RESULT(found in $i)
18+
fi
19+
done
20+
fi
21+
22+
if test -z "$SQLITE_DIR"; then
23+
AC_MSG_RESULT([not found])
24+
AC_MSG_ERROR([Please reinstall the sqlite distribution])
25+
fi
26+
27+
PHP_ADD_INCLUDE($SQLITE_DIR/include)
28+
29+
LIBNAME=sqlite
30+
LIBSYMBOL=sqlite_open
31+
32+
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
33+
[
34+
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $SQLITE_DIR/lib, SQLITE_SHARED_LIBADD)
35+
AC_DEFINE(HAVE_SQLITELIB,1,[ ])
36+
],[
37+
AC_MSG_ERROR([wrong sqlite lib version or lib not found])
38+
],[
39+
-L$SQLITE_DIR/lib -lm -ldl
40+
])
41+
42+
PHP_SUBST(SQLITE_SHARED_LIBADD)
43+
44+
PHP_NEW_EXTENSION(sqlite, sqlite.c, $ext_shared)
45+
fi

ext/sqlite/php_sqlite.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| PHP Version 4 |
4+
+----------------------------------------------------------------------+
5+
| Copyright (c) 1997-2002 The PHP Group |
6+
+----------------------------------------------------------------------+
7+
| This source file is subject to version 2.02 of the PHP license, |
8+
| that is bundled with this package in the file LICENSE, and is |
9+
| available at through the world-wide-web at |
10+
| http://www.php.net/license/2_02.txt. |
11+
| If you did not receive a copy of the PHP license and are unable to |
12+
| obtain it through the world-wide-web, please send a note to |
13+
| license@php.net so we can mail you a copy immediately. |
14+
+----------------------------------------------------------------------+
15+
| Author: |
16+
+----------------------------------------------------------------------+
17+
18+
$Id$
19+
*/
20+
21+
#ifndef PHP_SQLITE_H
22+
#define PHP_SQLITE_H
23+
24+
extern zend_module_entry sqlite_module_entry;
25+
#define phpext_sqlite_ptr &sqlite_module_entry
26+
27+
#ifdef PHP_WIN32
28+
#define PHP_SQLITE_API __declspec(dllexport)
29+
#else
30+
#define PHP_SQLITE_API
31+
#endif
32+
33+
#ifdef ZTS
34+
#include "TSRM.h"
35+
#endif
36+
37+
PHP_MINIT_FUNCTION(sqlite);
38+
PHP_MSHUTDOWN_FUNCTION(sqlite);
39+
PHP_RINIT_FUNCTION(sqlite);
40+
PHP_RSHUTDOWN_FUNCTION(sqlite);
41+
PHP_MINFO_FUNCTION(sqlite);
42+
43+
PHP_FUNCTION(sqlite_open);
44+
PHP_FUNCTION(sqlite_close);
45+
PHP_FUNCTION(sqlite_query);
46+
PHP_FUNCTION(sqlite_fetch_array);
47+
48+
PHP_FUNCTION(sqlite_num_rows);
49+
PHP_FUNCTION(sqlite_num_fields);
50+
PHP_FUNCTION(sqlite_field_name);
51+
PHP_FUNCTION(sqlite_seek);
52+
53+
PHP_FUNCTION(sqlite_libversion);
54+
PHP_FUNCTION(sqlite_libencoding);
55+
56+
PHP_FUNCTION(sqlite_changes);
57+
PHP_FUNCTION(sqlite_last_insert_rowid);
58+
59+
#ifdef ZTS
60+
#define SQLITE_G(v) TSRMG(sqlite_globals_id, zend_sqlite_globals *, v)
61+
#else
62+
#define SQLITE_G(v) (sqlite_globals.v)
63+
#endif
64+
65+
#endif
66+
67+
68+
/*
69+
* Local variables:
70+
* tab-width: 4
71+
* c-basic-offset: 4
72+
* indent-tabs-mode: t
73+
* End:
74+
*/

0 commit comments

Comments
 (0)