summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_sqlite')
-rw-r--r--ext/pdo_sqlite/config.m42
-rw-r--r--ext/pdo_sqlite/config.w324
-rw-r--r--ext/pdo_sqlite/pdo_sqlite.c4
-rw-r--r--ext/pdo_sqlite/php_pdo_sqlite.h4
-rw-r--r--ext/pdo_sqlite/php_pdo_sqlite_int.h4
-rw-r--r--ext/pdo_sqlite/sqlite_driver.c18
-rw-r--r--ext/pdo_sqlite/sqlite_statement.c4
-rw-r--r--ext/pdo_sqlite/tests/bug50728.phpt16
-rw-r--r--ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt130
9 files changed, 163 insertions, 23 deletions
diff --git a/ext/pdo_sqlite/config.m4 b/ext/pdo_sqlite/config.m4
index 1735f0f47..eceb94d8b 100644
--- a/ext/pdo_sqlite/config.m4
+++ b/ext/pdo_sqlite/config.m4
@@ -1,4 +1,4 @@
-dnl $Id: config.m4 273413 2009-01-13 02:50:54Z scottmac $
+dnl $Id: config.m4 291414 2009-11-29 06:13:22Z rasmus $
dnl config.m4 for extension pdo_sqlite
dnl vim:et:sw=2:ts=2:
diff --git a/ext/pdo_sqlite/config.w32 b/ext/pdo_sqlite/config.w32
index d1f159d4e..6db4e4bcb 100644
--- a/ext/pdo_sqlite/config.w32
+++ b/ext/pdo_sqlite/config.w32
@@ -1,10 +1,10 @@
-// $Id: config.w32 287047 2009-08-10 16:58:53Z kalle $
+// $Id: config.w32 289692 2009-10-16 02:22:48Z scottmac $
// vim:ft=javascript
ARG_WITH("pdo-sqlite", "for pdo_sqlite support", "no");
if (PHP_PDO_SQLITE != "no") {
- EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/DSQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /I" + configure_module_dirname + "/../sqlite3/libsqlite /I" + configure_module_dirname);
+ EXTENSION("pdo_sqlite", "pdo_sqlite.c sqlite_driver.c sqlite_statement.c", null, "/DSQLITE_THREADSAFE=" + (PHP_ZTS == "yes" ? "1" : "0") + " /D SQLITE_ENABLE_FTS3=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_CORE=1 /I" + configure_module_dirname + "/../sqlite3/libsqlite /I" + configure_module_dirname);
ADD_EXTENSION_DEP('pdo_sqlite', 'pdo');
// If pdo_sqlite is static, and sqlite3 is also static, then we don't add a second copy of the sqlite3 libs
diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c
index ba2b697f8..f9735f555 100644
--- a/ext/pdo_sqlite/pdo_sqlite.c
+++ b/ext/pdo_sqlite/pdo_sqlite.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2009 The PHP Group |
+ | Copyright (c) 1997-2010 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 |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pdo_sqlite.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: pdo_sqlite.c 293036 2010-01-03 09:23:27Z sebastian $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/ext/pdo_sqlite/php_pdo_sqlite.h b/ext/pdo_sqlite/php_pdo_sqlite.h
index 36bbb93a9..71813e0a4 100644
--- a/ext/pdo_sqlite/php_pdo_sqlite.h
+++ b/ext/pdo_sqlite/php_pdo_sqlite.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2009 The PHP Group |
+ | Copyright (c) 1997-2010 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 |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_sqlite.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_sqlite.h 293036 2010-01-03 09:23:27Z sebastian $ */
#ifndef PHP_PDO_SQLITE_H
diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
index 4deb99652..eb8329a81 100644
--- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2009 The PHP Group |
+ | Copyright (c) 1997-2010 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 |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_pdo_sqlite_int.h 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: php_pdo_sqlite_int.h 293036 2010-01-03 09:23:27Z sebastian $ */
#ifndef PHP_PDO_SQLITE_INT_H
#define PHP_PDO_SQLITE_INT_H
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index f16e17e06..56d6f3d20 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2009 The PHP Group |
+ | Copyright (c) 1997-2010 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 |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sqlite_driver.c 272370 2008-12-31 11:15:49Z sebastian $ */
+/* $Id: sqlite_driver.c 294444 2010-02-03 19:48:04Z pajoye $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -78,7 +78,7 @@ int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int li
}
if (!dbh->methods) {
- zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
+ zend_throw_exception_ex(php_pdo_get_exception(), einfo->errcode TSRMLS_CC, "SQLSTATE[%s] [%d] %s",
*pdo_err, einfo->errcode, einfo->errmsg);
}
@@ -496,9 +496,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
func->funcname = estrdup(func_name);
MAKE_STD_ZVAL(func->func);
- *(func->func) = *callback;
- zval_copy_ctor(func->func);
- INIT_PZVAL(func->func);
+ MAKE_COPY_ZVAL(&callback, func->func);
func->argc = argc;
@@ -575,14 +573,10 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
func->funcname = estrdup(func_name);
MAKE_STD_ZVAL(func->step);
- *(func->step) = *step_callback;
- zval_copy_ctor(func->step);
- INIT_PZVAL(func->step);
+ MAKE_COPY_ZVAL(&step_callback, func->step);
MAKE_STD_ZVAL(func->fini);
- *(func->fini) = *fini_callback;
- zval_copy_ctor(func->fini);
- INIT_PZVAL(func->fini);
+ MAKE_COPY_ZVAL(&fini_callback, func->fini);
func->argc = argc;
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
index d8e5049df..26e2e5f56 100644
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ b/ext/pdo_sqlite/sqlite_statement.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2009 The PHP Group |
+ | Copyright (c) 1997-2010 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 |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: sqlite_statement.c 280873 2009-05-20 15:05:36Z iliaa $ */
+/* $Id: sqlite_statement.c 293036 2010-01-03 09:23:27Z sebastian $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/ext/pdo_sqlite/tests/bug50728.phpt b/ext/pdo_sqlite/tests/bug50728.phpt
new file mode 100644
index 000000000..3dbbb1fff
--- /dev/null
+++ b/ext/pdo_sqlite/tests/bug50728.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #50728 (All PDOExceptions hardcode 'code' property to 0)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
+?>
+--FILE--
+<?php
+try {
+ $a = new PDO("sqlite:/this/path/should/not/exist.db");
+} catch (PDOException $e) {
+ var_dump($e->getCode());
+}
+?>
+--EXPECTF--
+int(14)
diff --git a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
new file mode 100644
index 000000000..efcb2e7bc
--- /dev/null
+++ b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
@@ -0,0 +1,130 @@
+--TEST--
+Testing several callbacks using PDO::FETCH_FUNC
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
+?>
+--FILE--
+<?php
+
+$db = new PDO('sqlite::memory:');
+$db->exec('CREATE TABLE testing (id INTEGER , name VARCHAR)');
+$db->exec('INSERT INTO testing VALUES(1, "php")');
+$db->exec('INSERT INTO testing VALUES(2, "")');
+
+$st = $db->query('SELECT * FROM testing');
+$st->fetchAll(PDO::FETCH_FUNC, function($x, $y) use ($st) { var_dump($st); print "data: $x, $y\n"; });
+
+$st = $db->query('SELECT name FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, 'strtoupper'));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, 'nothing'));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, ''));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, NULL));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, 1));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
+
+class foo {
+ public function foo($x) {
+ return "--- $x ---";
+ }
+}
+class bar extends foo {
+ public function __construct($db) {
+ $st = $db->query('SELECT * FROM testing');
+ var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::foo')));
+ }
+
+ static public function test($x, $y) {
+ return $x .'---'. $y;
+ }
+
+ private function test2($x, $y) {
+ return $x;
+ }
+
+ public function test3($x, $y) {
+ return $x .'==='. $y;
+ }
+}
+
+new bar($db);
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test')));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test2')));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'test3')));
+
+$st = $db->query('SELECT * FROM testing');
+var_dump($st->fetchAll(PDO::FETCH_FUNC, array('bar', 'inexistent')));
+
+?>
+--EXPECTF--
+object(PDOStatement)#%d (1) {
+ [%u|b%"queryString"]=>
+ %string|unicode%(21) "SELECT * FROM testing"
+}
+data: 1, php
+object(PDOStatement)#%d (1) {
+ [%u|b%"queryString"]=>
+ %string|unicode%(21) "SELECT * FROM testing"
+}
+data: 2,
+array(2) {
+ [0]=>
+ %string|unicode%(3) "PHP"
+ [1]=>
+ %string|unicode%(0) ""
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function 'nothing' not found or invalid function name in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function '' not found or invalid function name in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access self:: when no class scope is active in %s on line %d
+bool(false)
+array(2) {
+ [0]=>
+ %string|unicode%(9) "--- 1 ---"
+ [1]=>
+ %string|unicode%(9) "--- 2 ---"
+}
+array(2) {
+ [0]=>
+ %string|unicode%(7) "1---php"
+ [1]=>
+ %string|unicode%(4) "2---"
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access private method bar::test2() in %s on line %d
+bool(false)
+array(2) {
+ [0]=>
+ %string|unicode%(7) "1===php"
+ [1]=>
+ %string|unicode%(4) "2==="
+}
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'bar' does not have a method 'inexistent' in %s on line %d
+bool(false)