summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_sqlite')
-rw-r--r--ext/pdo_sqlite/CREDITS2
-rw-r--r--ext/pdo_sqlite/EXPERIMENTAL0
-rw-r--r--ext/pdo_sqlite/config.m455
-rw-r--r--ext/pdo_sqlite/config.w3216
-rwxr-xr-xext/pdo_sqlite/package.xml54
-rw-r--r--ext/pdo_sqlite/pdo_sqlite.c122
-rw-r--r--ext/pdo_sqlite/php_pdo_sqlite.h71
-rw-r--r--ext/pdo_sqlite/php_pdo_sqlite_int.h52
-rw-r--r--ext/pdo_sqlite/sqlite_driver.c357
-rw-r--r--ext/pdo_sqlite/sqlite_statement.c285
10 files changed, 0 insertions, 1014 deletions
diff --git a/ext/pdo_sqlite/CREDITS b/ext/pdo_sqlite/CREDITS
deleted file mode 100644
index 0a6c14588b..0000000000
--- a/ext/pdo_sqlite/CREDITS
+++ /dev/null
@@ -1,2 +0,0 @@
-SQLite 3.x driver for PDO
-Wez Furlong
diff --git a/ext/pdo_sqlite/EXPERIMENTAL b/ext/pdo_sqlite/EXPERIMENTAL
deleted file mode 100644
index e69de29bb2..0000000000
--- a/ext/pdo_sqlite/EXPERIMENTAL
+++ /dev/null
diff --git a/ext/pdo_sqlite/config.m4 b/ext/pdo_sqlite/config.m4
deleted file mode 100644
index ce723c0e3e..0000000000
--- a/ext/pdo_sqlite/config.m4
+++ /dev/null
@@ -1,55 +0,0 @@
-dnl $Id$
-dnl config.m4 for extension pdo_sqlite
-
-PHP_ARG_WITH(pdo-sqlite, for sqlite 3 driver for PDO,
-[ --with-pdo-sqlite Include PDO sqlite 3 support])
-
-if test "$PHP_PDO_SQLITE" != "no"; then
- SEARCH_PATH="/usr/local /usr" # you might want to change this
- SEARCH_FOR="/include/sqlite3.h" # you most likely want to change this
- if test -r $PHP_PDO_SQLITE/$SEARCH_FOR; then # path given as parameter
- PDO_SQLITE_DIR=$PHP_PDO_SQLITE
- else # search default path list
- AC_MSG_CHECKING([for sqlite3 files in default path])
- for i in $SEARCH_PATH ; do
- if test -r $i/$SEARCH_FOR; then
- PDO_SQLITE_DIR=$i
- AC_MSG_RESULT(found in $i)
- fi
- done
- fi
- if test -z "$PDO_SQLITE_DIR"; then
- AC_MSG_RESULT([not found])
- AC_MSG_ERROR([Please reinstall the sqlite3 distribution])
- fi
-
- PHP_ADD_INCLUDE($PDO_SQLITE_DIR/include)
-
- LIBNAME=sqlite3
- LIBSYMBOL=sqlite3_open
-
- PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
- [
- PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $PDO_SQLITE_DIR/lib, PDO_SQLITE_SHARED_LIBADD)
- AC_DEFINE(HAVE_PDO_SQLITELIB,1,[ ])
- ],[
- AC_MSG_ERROR([wrong sqlite lib version or lib not found])
- ],[
- -L$PDO_SQLITE_DIR/lib -lm -ldl
- ])
- PHP_SUBST(PDO_SQLITE_SHARED_LIBADD)
-
- AC_MSG_CHECKING([for PDO includes])
- if test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
- pdo_inc_path=$prefix/include/php/ext
- elif test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
- pdo_inc_path=$abs_srcdir/ext
- elif test -f ext/pdo/php_pdo_driver.h; then
- pdo_inc_path=ext
- else
- AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
- fi
- AC_MSG_RESULT($pdo_inc_path)
-
- PHP_NEW_EXTENSION(pdo_sqlite, pdo_sqlite.c sqlite_driver.c sqlite_statement.c, $ext_shared,,-I$pdo_inc_path)
-fi
diff --git a/ext/pdo_sqlite/config.w32 b/ext/pdo_sqlite/config.w32
deleted file mode 100644
index 049577c7f4..0000000000
--- a/ext/pdo_sqlite/config.w32
+++ /dev/null
@@ -1,16 +0,0 @@
-// $Id$
-// vim:ft=javascript
-
-ARG_WITH("pdo-sqlite", "for pdo_sqlite support", "no");
-
-if (PHP_PDO_SQLITE != "no") {
- if (CHECK_LIB("sqlite3.lib", "pdo_sqlite", PHP_PDO_SQLITE) &&
- CHECK_HEADER_ADD_INCLUDE("sqlite3.h", "CFLAGS_PDO_SQLITE", PHP_PDO_SQLITE + ";" + PHP_PHP_BUILD + "\\include\\sqlite3")) {
- EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c");
- ADD_FLAG('CFLAGS_PDO_SQLITE', "/I ..\\pecl");
- } else {
- WARNING("pdo_sqlite not enabled; libraries and headers not found");
- }
- ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
-}
-
diff --git a/ext/pdo_sqlite/package.xml b/ext/pdo_sqlite/package.xml
deleted file mode 100755
index 2087c27f80..0000000000
--- a/ext/pdo_sqlite/package.xml
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE package SYSTEM "../pear/package.dtd">
-<package version="1.0">
- <name>PDO_SQLITE</name>
- <summary>SQLite v3 Interface driver for PDO</summary>
- <maintainers>
- <maintainer>
- <user>wez</user>
- <name>Wez Furlong</name>
- <email>wez@php.net</email>
- <role>lead</role>
- </maintainer>
- </maintainers>
- <configureoptions>
- <configureoption name="with-pdo-sqlite" prompt="Path to your sqlite3 install"/>
-</configureoptions>
- <description>
- This extension provides an SQLite v3 driver for PDO.
- SQLite V3 is NOT compatible with the bundled SQLite in PHP 5, but is a significant
- step forwards, featuring complete utf-8 support, native support for blobs,
- native support for prepared statements with bound parameters and improved
- concurrency.
- </description>
- <license>PHP</license>
- <release>
- <state>alpha</state>
- <version>0.1</version>
- <date>2004-09-19</date>
-
- <notes>
- You need to install the PDO core module before you can make use of this one.
- You need to download and install SQLite V3 from http://sqlite.org to
- make use of this driver.
-
- There is no windows binary available yet.
- </notes>
-
- <filelist>
- <file role="src" name="config.m4"/>
- <file role="src" name="config.w32"/>
- <file role="src" name="pdo_sqlite.c"/>
- <file role="src" name="sqlite_driver.c"/>
- <file role="src" name="sqlite_statement.c"/>
- <file role="src" name="php_pdo_sqlite.h"/>
- <file role="src" name="php_pdo_sqlite_int.h"/>
-
- <file role="doc" name="CREDITS"/>
- </filelist>
- <deps>
- <dep type="php" rel="ge" version="5.0.1"/>
- <dep type="ext" rel="ge" name="pdo" version="0.1"/>
- </deps>
- </release>
-</package>
diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c
deleted file mode 100644
index 072246f743..0000000000
--- a/ext/pdo_sqlite/pdo_sqlite.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 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_0.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. |
- +----------------------------------------------------------------------+
- | Author: Wez Furlong <wez@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "pdo/php_pdo.h"
-#include "pdo/php_pdo_driver.h"
-#include "php_pdo_sqlite.h"
-#include "php_pdo_sqlite_int.h"
-#include "zend_exceptions.h"
-
-#define PHP_PDO_SQLITE_MODULE_VERSION "0.1-dev"
-
-/* {{{ pdo_sqlite_functions[] */
-function_entry pdo_sqlite_functions[] = {
- {NULL, NULL, NULL}
-};
-/* }}} */
-
-/* {{{ pdo_sqlite_module_entry
- */
-zend_module_entry pdo_sqlite_module_entry = {
- STANDARD_MODULE_HEADER,
- "pdo_sqlite",
- pdo_sqlite_functions,
- PHP_MINIT(pdo_sqlite),
- PHP_MSHUTDOWN(pdo_sqlite),
- PHP_RINIT(pdo_sqlite),
- PHP_RSHUTDOWN(pdo_sqlite),
- PHP_MINFO(pdo_sqlite),
- PHP_PDO_SQLITE_MODULE_VERSION,
- STANDARD_MODULE_PROPERTIES
-};
-/* }}} */
-
-#ifdef COMPILE_DL_PDO_SQLITE
-ZEND_GET_MODULE(pdo_sqlite)
-#endif
-
-/* {{{ PHP_MINIT_FUNCTION */
-PHP_MINIT_FUNCTION(pdo_sqlite)
-{
- /* If you have INI entries, uncomment these lines
- ZEND_INIT_MODULE_GLOBALS(pdo_sqlite, php_pdo_sqlite_init_globals, NULL);
- REGISTER_INI_ENTRIES();
- */
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MSHUTDOWN_FUNCTION
- */
-PHP_MSHUTDOWN_FUNCTION(pdo_sqlite)
-{
- /* uncomment this line if you have INI entries
- UNREGISTER_INI_ENTRIES();
- */
- return SUCCESS;
-}
-/* }}} */
-
-/* Remove if there's nothing to do at request start */
-/* {{{ PHP_RINIT_FUNCTION
- */
-PHP_RINIT_FUNCTION(pdo_sqlite)
-{
- return php_pdo_register_driver(&pdo_sqlite_driver);
-}
-/* }}} */
-
-/* Remove if there's nothing to do at request end */
-/* {{{ PHP_RSHUTDOWN_FUNCTION
- */
-PHP_RSHUTDOWN_FUNCTION(pdo_sqlite)
-{
- php_pdo_unregister_driver(&pdo_sqlite_driver);
- return SUCCESS;
-}
-/* }}} */
-
-/* {{{ PHP_MINFO_FUNCTION
- */
-PHP_MINFO_FUNCTION(pdo_sqlite)
-{
- php_info_print_table_start();
- php_info_print_table_header(2, "PDO Driver for SQLite 3.x", "enabled");
- php_info_print_table_row(2, "PECL Module version", PHP_PDO_SQLITE_MODULE_VERSION " $Id$");
- php_info_print_table_row(2, "SQLite Library", sqlite3_libversion());
- php_info_print_table_end();
-}
-/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/pdo_sqlite/php_pdo_sqlite.h b/ext/pdo_sqlite/php_pdo_sqlite.h
deleted file mode 100644
index 65d0b2349c..0000000000
--- a/ext/pdo_sqlite/php_pdo_sqlite.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 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_0.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. |
- +----------------------------------------------------------------------+
- | Author: Wez Furlong <wez@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-
-#ifndef PHP_PDO_SQLITE_H
-#define PHP_PDO_SQLITE_H
-
-extern zend_module_entry pdo_sqlite_module_entry;
-#define phpext_pdo_sqlite_ptr &pdo_sqlite_module_entry
-
-#ifdef PHP_WIN32
-#define PHP_PDO_SQLITE_API __declspec(dllexport)
-#else
-#define PHP_PDO_SQLITE_API
-#endif
-
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-PHP_MINIT_FUNCTION(pdo_sqlite);
-PHP_MSHUTDOWN_FUNCTION(pdo_sqlite);
-PHP_RINIT_FUNCTION(pdo_sqlite);
-PHP_RSHUTDOWN_FUNCTION(pdo_sqlite);
-PHP_MINFO_FUNCTION(pdo_sqlite);
-
-/*
- Declare any global variables you may need between the BEGIN
- and END macros here:
-
-ZEND_BEGIN_MODULE_GLOBALS(pdo_sqlite)
- long global_value;
- char *global_string;
-ZEND_END_MODULE_GLOBALS(pdo_sqlite)
-*/
-
-/* In every utility function you add that needs to use variables
- in php_pdo_sqlite_globals, call TSRMLS_FETCH(); after declaring other
- variables used by that function, or better yet, pass in TSRMLS_CC
- after the last function argument and declare your utility function
- with TSRMLS_DC after the last declared argument. Always refer to
- the globals in your function as PDO_SQLITE_G(variable). You are
- encouraged to rename these macros something shorter, see
- examples in any other php module directory.
-*/
-
-#ifdef ZTS
-#define PDO_SQLITE_G(v) TSRMG(pdo_sqlite_globals_id, zend_pdo_sqlite_globals *, v)
-#else
-#define PDO_SQLITE_G(v) (pdo_sqlite_globals.v)
-#endif
-
-#endif /* PHP_PDO_SQLITE_H */
-
diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
deleted file mode 100644
index ee57fa378c..0000000000
--- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 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_0.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. |
- +----------------------------------------------------------------------+
- | Author: Wez Furlong <wez@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifndef PHP_PDO_SQLITE_INT_H
-#define PHP_PDO_SQLITE_INT_H
-
-#include <sqlite3.h>
-
-typedef struct {
- const char *file;
- int line;
- unsigned int errcode;
- char *errmsg;
-} pdo_sqlite_error_info;
-
-typedef struct {
- sqlite3 *db;
- pdo_sqlite_error_info einfo;
-} pdo_sqlite_db_handle;
-
-typedef struct {
- pdo_sqlite_db_handle *H;
- sqlite3_stmt *stmt;
- unsigned pre_fetched:1;
- unsigned done:1;
-} pdo_sqlite_stmt;
-
-extern pdo_driver_t pdo_sqlite_driver;
-
-extern int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line TSRMLS_DC);
-#define pdo_sqlite_error(s) _pdo_sqlite_error(s, NULL, __FILE__, __LINE__ TSRMLS_CC)
-#define pdo_sqlite_error_stmt(s) _pdo_sqlite_error(stmt->dbh, stmt, __FILE__, __LINE__ TSRMLS_CC)
-
-extern struct pdo_stmt_methods sqlite_stmt_methods;
-#endif
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
deleted file mode 100644
index ca73ac8b54..0000000000
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 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_0.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. |
- +----------------------------------------------------------------------+
- | Author: Wez Furlong <wez@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "pdo/php_pdo.h"
-#include "pdo/php_pdo_driver.h"
-#include "php_pdo_sqlite.h"
-#include "php_pdo_sqlite_int.h"
-#include "zend_exceptions.h"
-
-int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line TSRMLS_DC) /* {{{ */
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- enum pdo_error_type *pdo_err = stmt ? &stmt->error_code : &dbh->error_code;
- pdo_sqlite_error_info *einfo = &H->einfo;
-
- einfo->errcode = sqlite3_errcode(H->db);
- einfo->file = file;
- einfo->line = line;
-
- if (einfo->errcode != SQLITE_OK) {
- einfo->errmsg = (char*)sqlite3_errmsg(H->db);
- } else { /* no error */
- *pdo_err = PDO_ERR_NONE;
- return 0;
- }
- switch (einfo->errcode) {
- case SQLITE_NOTFOUND:
- *pdo_err = PDO_ERR_NOT_FOUND;
- break;
-
- case SQLITE_INTERRUPT:
- *pdo_err = PDO_ERR_DISCONNECTED;
- break;
-
- case SQLITE_NOLFS:
- *pdo_err = PDO_ERR_NOT_IMPLEMENTED;
- break;
-
- case SQLITE_TOOBIG:
- *pdo_err = PDO_ERR_TRUNCATED;
- break;
-
- case SQLITE_CONSTRAINT:
- *pdo_err = PDO_ERR_CONSTRAINT;
- break;
-
- case SQLITE_ERROR: /* empty query */
- *pdo_err = PDO_ERR_SYNTAX;
- break;
-
- default:
- *pdo_err = PDO_ERR_CANT_MAP;
- break;
- }
-
- if (!dbh->methods) {
- zend_throw_exception_ex(php_pdo_get_exception(), *pdo_err TSRMLS_CC, "[%d] %s",
- einfo->errcode, einfo->errmsg);
- }
-
- return einfo->errcode;
-}
-/* }}} */
-
-static int pdo_sqlite_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- pdo_sqlite_error_info *einfo = &H->einfo;
-
- if (einfo->errcode) {
- add_next_index_long(info, einfo->errcode);
- add_next_index_string(info, einfo->errmsg, 1);
- }
-
- return 1;
-}
-
-static int sqlite_handle_closer(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
-
- if (H) {
- if (H->db) {
- sqlite3_close(H->db);
- H->db = NULL;
- }
- pefree(H, dbh->is_persistent);
- dbh->driver_data = NULL;
- }
- return 0;
-}
-/* }}} */
-
-static int sqlite_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pdo_stmt_t *stmt, long options, zval *driver_options TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- pdo_sqlite_stmt *S = ecalloc(1, sizeof(pdo_sqlite_stmt));
- int i;
- const char *tail;
-
- S->H = H;
- stmt->driver_data = S;
- stmt->methods = &sqlite_stmt_methods;
-
- i = sqlite3_prepare(H->db, sql, sql_len, &S->stmt, &tail);
- if (i == SQLITE_OK)
- return 1;
-
- pdo_sqlite_error(dbh);
-
- return 0;
-}
-
-static long sqlite_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- char *errmsg = NULL;
-
- if (sqlite3_exec(H->db, sql, NULL, NULL, &errmsg) != SQLITE_OK) {
- pdo_sqlite_error(dbh);
- if (errmsg)
- sqlite3_free(errmsg);
-
- return -1;
- } else {
- return sqlite3_changes(H->db);
- }
-}
-
-static long pdo_sqlite_last_insert_id(pdo_dbh_t *dbh TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
-
- return (long) sqlite3_last_insert_rowid(H->db);
-}
-
-/* NB: doesn't handle binary strings... use prepared stmts for that */
-static int sqlite_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, char **quoted, int *quotedlen TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- *quoted = emalloc(2*unquotedlen + 3);
- sqlite3_snprintf(2*unquotedlen + 3, *quoted, "'%q'", unquoted);
- *quotedlen = strlen(*quoted);
- return 1;
-}
-
-static int sqlite_handle_begin(pdo_dbh_t *dbh TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- char *errmsg = NULL;
-
- if (sqlite3_exec(H->db, "BEGIN", NULL, NULL, &errmsg) != SQLITE_OK) {
- pdo_sqlite_error(dbh);
- if (errmsg)
- sqlite3_free(errmsg);
- return 0;
- }
- return 1;
-}
-
-static int sqlite_handle_commit(pdo_dbh_t *dbh TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- char *errmsg = NULL;
-
- if (sqlite3_exec(H->db, "COMMIT", NULL, NULL, &errmsg) != SQLITE_OK) {
- pdo_sqlite_error(dbh);
- if (errmsg)
- sqlite3_free(errmsg);
- return 0;
- }
- return 1;
-}
-
-static int sqlite_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
- char *errmsg = NULL;
-
- if (sqlite3_exec(H->db, "ROLLBACK", NULL, NULL, &errmsg) != SQLITE_OK) {
- pdo_sqlite_error(dbh);
- if (errmsg)
- sqlite3_free(errmsg);
- return 0;
- }
- return 1;
-}
-
-static int pdo_sqlite_get_attribute(pdo_dbh_t *dbh, long attr, zval *return_value TSRMLS_DC)
-{
- pdo_sqlite_db_handle *H = (pdo_sqlite_db_handle *)dbh->driver_data;
-
- switch (attr) {
- case PDO_ATTR_CLIENT_VERSION:
- case PDO_ATTR_SERVER_VERSION:
- ZVAL_STRING(return_value, (char *)sqlite3_libversion(), 1);
- break;
-
- default:
- return 0;
- }
-
- return 1;
-}
-
-static struct pdo_dbh_methods sqlite_methods = {
- sqlite_handle_closer,
- sqlite_handle_preparer,
- sqlite_handle_doer,
- sqlite_handle_quoter,
- sqlite_handle_begin,
- sqlite_handle_commit,
- sqlite_handle_rollback,
- NULL, /* set_attribute */
- pdo_sqlite_last_insert_id,
- pdo_sqlite_fetch_error_func,
- pdo_sqlite_get_attribute,
- NULL /* check_liveness: not needed */
-};
-
-static char *make_filename_safe(const char *filename TSRMLS_DC)
-{
- if (strncmp(filename, ":memory:", sizeof(":memory:")-1)) {
- char *fullpath = expand_filepath(filename, NULL TSRMLS_CC);
-
- if (PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) {
- efree(fullpath);
- return NULL;
- }
-
- if (php_check_open_basedir(fullpath TSRMLS_CC)) {
- efree(fullpath);
- return NULL;
- }
- return fullpath;
- }
- return estrdup(filename);
-}
-
-static int authorizer(void *autharg, int access_type, const char *arg3, const char *arg4,
- const char *arg5, const char *arg6)
-{
- char *filename;
- switch (access_type) {
- case SQLITE_COPY: {
- TSRMLS_FETCH();
- filename = make_filename_safe(arg4 TSRMLS_CC);
- if (!filename) {
- return SQLITE_DENY;
- }
- efree(filename);
- return SQLITE_OK;
- }
-
- case SQLITE_ATTACH: {
- TSRMLS_FETCH();
- filename = make_filename_safe(arg3 TSRMLS_CC);
- if (!filename) {
- return SQLITE_DENY;
- }
- efree(filename);
- return SQLITE_OK;
- }
-
- default:
- /* access allowed */
- return SQLITE_OK;
- }
-}
-
-static int pdo_sqlite_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_DC) /* {{{ */
-{
- pdo_sqlite_db_handle *H;
- int i, ret = 0;
- long timeout = 60;
- char *filename;
-
- H = pecalloc(1, sizeof(pdo_sqlite_db_handle), dbh->is_persistent);
-
- H->einfo.errcode = 0;
- H->einfo.errmsg = NULL;
- dbh->driver_data = H;
-
- filename = make_filename_safe(dbh->data_source TSRMLS_CC);
-
- if (!filename) {
- zend_throw_exception_ex(php_pdo_get_exception(), PDO_ERR_NO_PERM TSRMLS_CC,
- "safe_mode/open_basedir prohibits opening %s",
- dbh->data_source);
- goto cleanup;
- }
-
- i = sqlite3_open(filename, &H->db);
- efree(filename);
-
- if (i != SQLITE_OK) {
- pdo_sqlite_error(dbh);
- goto cleanup;
- }
-
- sqlite3_set_authorizer(H->db, authorizer, NULL);
-
- if (driver_options) {
- timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, timeout TSRMLS_CC);
- }
- sqlite_busy_timeout(H->db, timeout * 1000);
-
- dbh->alloc_own_columns = 1;
- dbh->supports_placeholders = PDO_PLACEHOLDER_POSITIONAL;
- dbh->max_escaped_char_length = 2;
-
- ret = 1;
-
-cleanup:
- dbh->methods = &sqlite_methods;
-
- return ret;
-}
-/* }}} */
-
-pdo_driver_t pdo_sqlite_driver = {
- PDO_DRIVER_HEADER(sqlite),
- pdo_sqlite_handle_factory
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
deleted file mode 100644
index fd61bb78ec..0000000000
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.0 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_0.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. |
- +----------------------------------------------------------------------+
- | Author: Wez Furlong <wez@php.net> |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "pdo/php_pdo.h"
-#include "pdo/php_pdo_driver.h"
-#include "php_pdo_sqlite.h"
-#include "php_pdo_sqlite_int.h"
-
-
-static int pdo_sqlite_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
-{
- pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
- int i;
-
- if (S->stmt) {
- sqlite3_finalize(S->stmt);
- S->stmt = NULL;
- }
- efree(S);
- return 1;
-}
-
-static int pdo_sqlite_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
-{
- pdo_dbh_t *dbh = stmt->dbh;
- pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
- pdo_sqlite_db_handle *H = S->H;
- int i;
-
- if (stmt->executed && !S->done) {
- sqlite3_reset(S->stmt);
- }
-
- S->done = 0;
- i = sqlite3_step(S->stmt);
- switch (i) {
- case SQLITE_ROW:
- S->pre_fetched = 1;
- stmt->column_count = sqlite3_data_count(S->stmt);
- return 1;
-
- case SQLITE_DONE:
- stmt->column_count = sqlite3_data_count(S->stmt);
- sqlite3_reset(S->stmt);
- S->done = 1;
- return 1;
-
- case SQLITE_ERROR:
- case SQLITE_MISUSE:
- case SQLITE_BUSY:
- default:
- pdo_sqlite_error_stmt(stmt);
- return 0;
- }
-}
-
-static int pdo_sqlite_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *param,
- enum pdo_param_event event_type TSRMLS_DC)
-{
- pdo_dbh_t *dbh = stmt->dbh;
- pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
- pdo_sqlite_db_handle *H = S->H;
- int i;
-
- switch (event_type) {
- case PDO_PARAM_EVT_EXEC_PRE:
- if (stmt->executed && !S->done) {
- sqlite3_reset(S->stmt);
- S->done = 1;
- }
-
- if (param->is_param) {
- switch (param->param_type) {
- case PDO_PARAM_LOB:
- case PDO_PARAM_STMT:
- return 0;
- case PDO_PARAM_STR:
- default:
- if (param->paramno == -1) {
- param->paramno = sqlite3_bind_parameter_index(S->stmt, param->name);
- }
- convert_to_string(param->parameter);
- i = sqlite3_bind_blob(S->stmt, param->paramno,
- Z_STRVAL_P(param->parameter),
- Z_STRLEN_P(param->parameter),
- SQLITE_STATIC);
- if (i == SQLITE_OK)
- return 1;
- pdo_sqlite_error_stmt(stmt);
- return 0;
- }
- }
- break;
-
- default:
- ;
- }
- return 1;
-}
-
-static int pdo_sqlite_stmt_fetch(pdo_stmt_t *stmt TSRMLS_DC)
-{
- pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
- int i;
-
- if (!S->stmt) {
- return 0;
- }
- if (S->pre_fetched) {
- S->pre_fetched = 0;
- return 1;
- }
- if (S->done) {
- return 0;
- }
-
- i = sqlite3_step(S->stmt);
- switch (i) {
- case SQLITE_ROW:
- return 1;
-
- case SQLITE_DONE:
- S->done = 1;
- sqlite3_reset(S->stmt);
- return 0;
-
- default:
- pdo_sqlite_error_stmt(stmt);
- return 0;
- }
-}
-
-static int pdo_sqlite_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
-{
- pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
-
- if(colno >= sqlite3_data_count(S->stmt)) {
- /* error invalid column */
- pdo_sqlite_error_stmt(stmt);
- return 0;
- }
-
- stmt->columns[colno].name = estrdup(sqlite3_column_name(S->stmt, colno));
- stmt->columns[colno].namelen = strlen(stmt->columns[colno].name);
- stmt->columns[colno].maxlen = 0xffffffff;
- stmt->columns[colno].precision = 0;
-
- switch (sqlite3_column_type(S->stmt, colno)) {
- case SQLITE_INTEGER:
- case SQLITE_FLOAT:
- case SQLITE_TEXT:
- case SQLITE_BLOB:
- stmt->columns[colno].param_type = PDO_PARAM_STR;
- break;
- case SQLITE_NULL:
- stmt->columns[colno].param_type = PDO_PARAM_NULL;
- break;
- }
-
- return 1;
-}
-
-static int pdo_sqlite_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, unsigned long *len TSRMLS_DC)
-{
- pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
- if (!S->stmt) {
- return 0;
- }
- if(colno >= sqlite3_data_count(S->stmt)) {
- /* error invalid column */
- pdo_sqlite_error_stmt(stmt);
- return 0;
- }
-
- switch (sqlite3_column_type(S->stmt, colno)) {
- case SQLITE_NULL:
- *ptr = NULL;
- *len = 0;
- return 1;
-
- case SQLITE_BLOB:
- *ptr = (char*)sqlite3_column_blob(S->stmt, colno);
- *len = sqlite3_column_bytes(S->stmt, colno);
- return 1;
-
- default:
- *ptr = (char*)sqlite3_column_text(S->stmt, colno);
- *len = strlen(*ptr);
- return 1;
- }
-}
-
-static int pdo_sqlite_stmt_col_meta(pdo_stmt_t *stmt, long colno, zval *return_value TSRMLS_DC)
-{
- pdo_sqlite_stmt *S = (pdo_sqlite_stmt*)stmt->driver_data;
- char *str;
- zval *flags;
-
- if (!S->stmt) {
- return FAILURE;
- }
- if(colno >= sqlite3_data_count(S->stmt)) {
- /* error invalid column */
- pdo_sqlite_error_stmt(stmt);
- return FAILURE;
- }
-
- array_init(return_value);
- MAKE_STD_ZVAL(flags);
- array_init(flags);
-
- switch (sqlite3_column_type(S->stmt, colno)) {
- case SQLITE_NULL:
- add_assoc_string(return_value, "native_type", "null", 1);
- break;
-
- case SQLITE_FLOAT:
- add_assoc_string(return_value, "native_type", "double", 1);
- break;
-
- case SQLITE_BLOB:
- add_next_index_string(flags, "blob", 1);
- case SQLITE_TEXT:
- add_assoc_string(return_value, "native_type", "string", 1);
- break;
-
- case SQLITE_INTEGER:
- add_assoc_string(return_value, "native_type", "integer", 1);
- break;
- }
-
- str = (char*)sqlite3_column_decltype(S->stmt, colno);
- if (str) {
- add_assoc_string(return_value, "sqlite:decl_type", str, 1);
- }
-
- add_assoc_zval(return_value, "flags", flags);
-
- return SUCCESS;
-}
-
-struct pdo_stmt_methods sqlite_stmt_methods = {
- pdo_sqlite_stmt_dtor,
- pdo_sqlite_stmt_execute,
- pdo_sqlite_stmt_fetch,
- pdo_sqlite_stmt_describe,
- pdo_sqlite_stmt_get_col,
- pdo_sqlite_stmt_param_hook,
- NULL, /* set_attr */
- NULL, /* get_attr */
- pdo_sqlite_stmt_col_meta
-};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */