summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite
diff options
context:
space:
mode:
Diffstat (limited to 'ext/pdo_sqlite')
-rw-r--r--ext/pdo_sqlite/pdo_sqlite.c19
-rw-r--r--ext/pdo_sqlite/php_pdo_sqlite.h2
-rw-r--r--ext/pdo_sqlite/php_pdo_sqlite_int.h2
-rw-r--r--ext/pdo_sqlite/sqlite_driver.c83
-rw-r--r--ext/pdo_sqlite/sqlite_driver.stub.php15
-rw-r--r--ext/pdo_sqlite/sqlite_driver_arginfo.h34
-rw-r--r--ext/pdo_sqlite/sqlite_statement.c2
-rw-r--r--ext/pdo_sqlite/tests/bug33841.phpt1
-rw-r--r--ext/pdo_sqlite/tests/bug35336.phpt6
-rw-r--r--ext/pdo_sqlite/tests/bug43831.phpt24
-rw-r--r--ext/pdo_sqlite/tests/bug48773.phpt16
-rw-r--r--ext/pdo_sqlite/tests/bug50728.phpt4
-rw-r--r--ext/pdo_sqlite/tests/bug52487.phpt2
-rw-r--r--ext/pdo_sqlite/tests/bug66033.phpt24
-rw-r--r--ext/pdo_sqlite/tests/bug70862.phpt8
-rw-r--r--ext/pdo_sqlite/tests/bug78192.phpt1
-rw-r--r--ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt75
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt19
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt10
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt2
-rw-r--r--ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt5
25 files changed, 197 insertions, 165 deletions
diff --git a/ext/pdo_sqlite/pdo_sqlite.c b/ext/pdo_sqlite/pdo_sqlite.c
index 5c2fd63cdb..60cd4c3c98 100644
--- a/ext/pdo_sqlite/pdo_sqlite.c
+++ b/ext/pdo_sqlite/pdo_sqlite.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -29,27 +27,19 @@
#include "php_pdo_sqlite_int.h"
#include "zend_exceptions.h"
-/* {{{ pdo_sqlite_functions[] */
-static const zend_function_entry pdo_sqlite_functions[] = {
- PHP_FE_END
-};
-/* }}} */
-
-/* {{{ pdo_sqlite_deps
- */
+/* {{{ pdo_sqlite_deps */
static const zend_module_dep pdo_sqlite_deps[] = {
ZEND_MOD_REQUIRED("pdo")
ZEND_MOD_END
};
/* }}} */
-/* {{{ pdo_sqlite_module_entry
- */
+/* {{{ pdo_sqlite_module_entry */
zend_module_entry pdo_sqlite_module_entry = {
STANDARD_MODULE_HEADER_EX, NULL,
pdo_sqlite_deps,
"pdo_sqlite",
- pdo_sqlite_functions,
+ NULL,
PHP_MINIT(pdo_sqlite),
PHP_MSHUTDOWN(pdo_sqlite),
NULL,
@@ -90,8 +80,7 @@ PHP_MSHUTDOWN_FUNCTION(pdo_sqlite)
}
/* }}} */
-/* {{{ PHP_MINFO_FUNCTION
- */
+/* {{{ PHP_MINFO_FUNCTION */
PHP_MINFO_FUNCTION(pdo_sqlite)
{
php_info_print_table_start();
diff --git a/ext/pdo_sqlite/php_pdo_sqlite.h b/ext/pdo_sqlite/php_pdo_sqlite.h
index 73d8a98675..e9fe2463ff 100644
--- a/ext/pdo_sqlite/php_pdo_sqlite.h
+++ b/ext/pdo_sqlite/php_pdo_sqlite.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/ext/pdo_sqlite/php_pdo_sqlite_int.h b/ext/pdo_sqlite/php_pdo_sqlite_int.h
index c1d3a953a0..31fa7cc9ff 100644
--- a/ext/pdo_sqlite/php_pdo_sqlite_int.h
+++ b/ext/pdo_sqlite/php_pdo_sqlite_int.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/ext/pdo_sqlite/sqlite_driver.c b/ext/pdo_sqlite/sqlite_driver.c
index 83ea2d6083..dcbc604739 100644
--- a/ext/pdo_sqlite/sqlite_driver.c
+++ b/ext/pdo_sqlite/sqlite_driver.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -28,6 +26,7 @@
#include "php_pdo_sqlite.h"
#include "php_pdo_sqlite_int.h"
#include "zend_exceptions.h"
+#include "sqlite_driver_arginfo.h"
int _pdo_sqlite_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line) /* {{{ */
{
@@ -515,12 +514,13 @@ static int php_sqlite3_collation_callback(void *context,
return ret;
}
-/* {{{ bool SQLite::sqliteCreateFunction(string name, mixed callback [, int argcount, int flags])
+/* {{{ bool SQLite::sqliteCreateFunction(string name, callable callback [, int argcount, int flags])
Registers a UDF with the sqlite db handle */
-static PHP_METHOD(SQLite, sqliteCreateFunction)
+PHP_METHOD(PDO_SQLite_Ext, sqliteCreateFunction)
{
struct pdo_sqlite_func *func;
- zval *callback;
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
char *func_name;
size_t func_name_len;
zend_long argc = -1;
@@ -531,22 +531,15 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
ZEND_PARSE_PARAMETERS_START(2, 4)
Z_PARAM_STRING(func_name, func_name_len)
- Z_PARAM_ZVAL(callback)
+ Z_PARAM_FUNC(fci, fcc)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(argc)
Z_PARAM_LONG(flags)
- ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+ ZEND_PARSE_PARAMETERS_END();
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
- if (!zend_is_callable(callback, 0, NULL)) {
- zend_string *cbname = zend_get_callable_name(callback);
- php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname));
- zend_string_release_ex(cbname, 0);
- RETURN_FALSE;
- }
-
H = (pdo_sqlite_db_handle *)dbh->driver_data;
func = (struct pdo_sqlite_func*)ecalloc(1, sizeof(*func));
@@ -556,7 +549,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
if (ret == SQLITE_OK) {
func->funcname = estrdup(func_name);
- ZVAL_COPY(&func->func, callback);
+ ZVAL_COPY(&func->func, &fci.function_name);
func->argc = argc;
@@ -571,7 +564,7 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
}
/* }}} */
-/* {{{ bool SQLite::sqliteCreateAggregate(string name, mixed step, mixed fini [, int argcount])
+/* {{{ bool SQLite::sqliteCreateAggregate(string name, callable step, callable fini [, int argcount])
Registers a UDF with the sqlite db handle */
/* The step function should have the prototype:
@@ -590,10 +583,11 @@ static PHP_METHOD(SQLite, sqliteCreateFunction)
aggregate UDF.
*/
-static PHP_METHOD(SQLite, sqliteCreateAggregate)
+PHP_METHOD(PDO_SQLite_Ext, sqliteCreateAggregate)
{
struct pdo_sqlite_func *func;
- zval *step_callback, *fini_callback;
+ zend_fcall_info step_fci, fini_fci;
+ zend_fcall_info_cache step_fcc, fini_fcc;
char *func_name;
size_t func_name_len;
zend_long argc = -1;
@@ -603,29 +597,15 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
ZEND_PARSE_PARAMETERS_START(3, 4)
Z_PARAM_STRING(func_name, func_name_len)
- Z_PARAM_ZVAL(step_callback)
- Z_PARAM_ZVAL(fini_callback)
+ Z_PARAM_FUNC(step_fci, step_fcc)
+ Z_PARAM_FUNC(fini_fci, fini_fcc)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(argc)
- ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+ ZEND_PARSE_PARAMETERS_END();
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
- if (!zend_is_callable(step_callback, 0, NULL)) {
- zend_string *cbname = zend_get_callable_name(step_callback);
- php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname));
- zend_string_release_ex(cbname, 0);
- RETURN_FALSE;
- }
-
- if (!zend_is_callable(fini_callback, 0, NULL)) {
- zend_string *cbname = zend_get_callable_name(fini_callback);
- php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname));
- zend_string_release_ex(cbname, 0);
- RETURN_FALSE;
- }
-
H = (pdo_sqlite_db_handle *)dbh->driver_data;
func = (struct pdo_sqlite_func*)ecalloc(1, sizeof(*func));
@@ -635,9 +615,9 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
if (ret == SQLITE_OK) {
func->funcname = estrdup(func_name);
- ZVAL_COPY(&func->step, step_callback);
+ ZVAL_COPY(&func->step, &step_fci.function_name);
- ZVAL_COPY(&func->fini, fini_callback);
+ ZVAL_COPY(&func->fini, &fini_fci.function_name);
func->argc = argc;
@@ -652,12 +632,13 @@ static PHP_METHOD(SQLite, sqliteCreateAggregate)
}
/* }}} */
-/* {{{ bool SQLite::sqliteCreateCollation(string name, mixed callback)
+/* {{{ bool SQLite::sqliteCreateCollation(string name, callable callback)
Registers a collation with the sqlite db handle */
-static PHP_METHOD(SQLite, sqliteCreateCollation)
+PHP_METHOD(PDO_SQLite_Ext, sqliteCreateCollation)
{
struct pdo_sqlite_collation *collation;
- zval *callback;
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
char *collation_name;
size_t collation_name_len;
pdo_dbh_t *dbh;
@@ -666,19 +647,12 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
ZEND_PARSE_PARAMETERS_START(2, 2)
Z_PARAM_STRING(collation_name, collation_name_len)
- Z_PARAM_ZVAL(callback)
- ZEND_PARSE_PARAMETERS_END_EX(RETURN_FALSE);
+ Z_PARAM_FUNC(fci, fcc)
+ ZEND_PARSE_PARAMETERS_END();
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
- if (!zend_is_callable(callback, 0, NULL)) {
- zend_string *cbname = zend_get_callable_name(callback);
- php_error_docref(NULL, E_WARNING, "function '%s' is not callable", ZSTR_VAL(cbname));
- zend_string_release_ex(cbname, 0);
- RETURN_FALSE;
- }
-
H = (pdo_sqlite_db_handle *)dbh->driver_data;
collation = (struct pdo_sqlite_collation*)ecalloc(1, sizeof(*collation));
@@ -687,7 +661,7 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
if (ret == SQLITE_OK) {
collation->name = estrdup(collation_name);
- ZVAL_COPY(&collation->callback, callback);
+ ZVAL_COPY(&collation->callback, &fci.function_name);
collation->next = H->collations;
H->collations = collation;
@@ -700,18 +674,11 @@ static PHP_METHOD(SQLite, sqliteCreateCollation)
}
/* }}} */
-static const zend_function_entry dbh_methods[] = {
- PHP_ME(SQLite, sqliteCreateFunction, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(SQLite, sqliteCreateAggregate, NULL, ZEND_ACC_PUBLIC)
- PHP_ME(SQLite, sqliteCreateCollation, NULL, ZEND_ACC_PUBLIC)
- PHP_FE_END
-};
-
static const zend_function_entry *get_driver_methods(pdo_dbh_t *dbh, int kind)
{
switch (kind) {
case PDO_DBH_DRIVER_METHOD_KIND_DBH:
- return dbh_methods;
+ return class_PDO_SQLite_Ext_methods;
default:
return NULL;
diff --git a/ext/pdo_sqlite/sqlite_driver.stub.php b/ext/pdo_sqlite/sqlite_driver.stub.php
new file mode 100644
index 0000000000..eafd3c0c48
--- /dev/null
+++ b/ext/pdo_sqlite/sqlite_driver.stub.php
@@ -0,0 +1,15 @@
+<?php
+
+/** @generate-function-entries */
+
+// These are extension methods for PDO. This is not a real class.
+class PDO_SQLite_Ext {
+ /** @return bool */
+ public function sqliteCreateFunction(string $function_name, callable $callback, int $num_args = -1, int $flags = 0) {}
+
+ /** @return bool */
+ public function sqliteCreateAggregate(string $function_name, callable $step_func, callable $finalize_func, int $num_args = -1) {}
+
+ /** @return bool */
+ public function sqliteCreateCollation(string $name, callable $callback) {}
+}
diff --git a/ext/pdo_sqlite/sqlite_driver_arginfo.h b/ext/pdo_sqlite/sqlite_driver_arginfo.h
new file mode 100644
index 0000000000..ad3df39bac
--- /dev/null
+++ b/ext/pdo_sqlite/sqlite_driver_arginfo.h
@@ -0,0 +1,34 @@
+/* This is a generated file, edit the .stub.php file instead.
+ * Stub hash: e367675f85371fb06484e39dd6ccb3433766ffb8 */
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateFunction, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_args, IS_LONG, 0, "-1")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "0")
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateAggregate, 0, 0, 3)
+ ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, step_func, IS_CALLABLE, 0)
+ ZEND_ARG_TYPE_INFO(0, finalize_func, IS_CALLABLE, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, num_args, IS_LONG, 0, "-1")
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_SQLite_Ext_sqliteCreateCollation, 0, 0, 2)
+ ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, callback, IS_CALLABLE, 0)
+ZEND_END_ARG_INFO()
+
+
+ZEND_METHOD(PDO_SQLite_Ext, sqliteCreateFunction);
+ZEND_METHOD(PDO_SQLite_Ext, sqliteCreateAggregate);
+ZEND_METHOD(PDO_SQLite_Ext, sqliteCreateCollation);
+
+
+static const zend_function_entry class_PDO_SQLite_Ext_methods[] = {
+ ZEND_ME(PDO_SQLite_Ext, sqliteCreateFunction, arginfo_class_PDO_SQLite_Ext_sqliteCreateFunction, ZEND_ACC_PUBLIC)
+ ZEND_ME(PDO_SQLite_Ext, sqliteCreateAggregate, arginfo_class_PDO_SQLite_Ext_sqliteCreateAggregate, ZEND_ACC_PUBLIC)
+ ZEND_ME(PDO_SQLite_Ext, sqliteCreateCollation, arginfo_class_PDO_SQLite_Ext_sqliteCreateCollation, ZEND_ACC_PUBLIC)
+ ZEND_FE_END
+};
diff --git a/ext/pdo_sqlite/sqlite_statement.c b/ext/pdo_sqlite/sqlite_statement.c
index a8723da640..64a90e0ede 100644
--- a/ext/pdo_sqlite/sqlite_statement.c
+++ b/ext/pdo_sqlite/sqlite_statement.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/ext/pdo_sqlite/tests/bug33841.phpt b/ext/pdo_sqlite/tests/bug33841.phpt
index 1c9fe201f4..2fc6d955b6 100644
--- a/ext/pdo_sqlite/tests/bug33841.phpt
+++ b/ext/pdo_sqlite/tests/bug33841.phpt
@@ -20,6 +20,7 @@ $stmt = $db->prepare("UPDATE test SET text = :text ");
$stmt->bindParam(':text', $name);
$name = 'test2';
var_dump($stmt->execute(), $stmt->rowCount());
+?>
--EXPECT--
bool(true)
int(1)
diff --git a/ext/pdo_sqlite/tests/bug35336.phpt b/ext/pdo_sqlite/tests/bug35336.phpt
index 201429bc4e..52a425b62f 100644
--- a/ext/pdo_sqlite/tests/bug35336.phpt
+++ b/ext/pdo_sqlite/tests/bug35336.phpt
@@ -7,9 +7,9 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
--FILE--
<?php
class EEE {
- function __set ($field, $value) {
- echo "hello world\n";
- }
+ function __set ($field, $value) {
+ echo "hello world\n";
+ }
}
$a = new PDO("sqlite::memory:");// pool ("sqlite::memory:");
diff --git a/ext/pdo_sqlite/tests/bug43831.phpt b/ext/pdo_sqlite/tests/bug43831.phpt
index 4620559da4..bcb09c95a7 100644
--- a/ext/pdo_sqlite/tests/bug43831.phpt
+++ b/ext/pdo_sqlite/tests/bug43831.phpt
@@ -6,23 +6,23 @@ Bug #43831 ($this gets mangled when extending PDO with persistent connection)
<?php
class Foo extends PDO {
- function __construct($dsn) {
- parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
- }
+ function __construct($dsn) {
+ parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
+ }
}
class Baz extends PDO {
- function __construct($dsn) {
- parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
- }
+ function __construct($dsn) {
+ parent::__construct($dsn, null, null, array(PDO::ATTR_PERSISTENT => true));
+ }
}
class Bar extends Baz {
- function quux() {
- echo get_class($this), "\n";
- $foo = new Foo("sqlite::memory:");
- echo get_class($this), "\n";
- }
+ function quux() {
+ echo get_class($this), "\n";
+ $foo = new Foo("sqlite::memory:");
+ echo get_class($this), "\n";
+ }
}
$bar = new Bar("sqlite::memory:");
@@ -49,5 +49,5 @@ object(PDO)#%d (0) {
object(MyPDO)#%d (0) {
}
-Notice: Undefined variable: bar in %s on line %d
+Warning: Undefined variable $bar in %s on line %d
NULL
diff --git a/ext/pdo_sqlite/tests/bug48773.phpt b/ext/pdo_sqlite/tests/bug48773.phpt
index c9a2f64bef..a5f43cdd92 100644
--- a/ext/pdo_sqlite/tests/bug48773.phpt
+++ b/ext/pdo_sqlite/tests/bug48773.phpt
@@ -8,18 +8,18 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
<?php
class bar extends PDOStatement {
- private function __construct() {
- }
+ private function __construct() {
+ }
}
class foo extends PDO {
- public $statementClass = 'bar';
- function __construct($dsn, $username, $password, $driver_options = array()) {
- $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
- parent::__construct($dsn, $username, $password, $driver_options);
+ public $statementClass = 'bar';
+ function __construct($dsn, $username, $password, $driver_options = array()) {
+ $driver_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
+ parent::__construct($dsn, $username, $password, $driver_options);
- $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
- }
+ $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($this->statementClass, array($this)));
+ }
}
$db = new foo('sqlite::memory:', '', '');
diff --git a/ext/pdo_sqlite/tests/bug50728.phpt b/ext/pdo_sqlite/tests/bug50728.phpt
index b00ea50cf0..98f8907f48 100644
--- a/ext/pdo_sqlite/tests/bug50728.phpt
+++ b/ext/pdo_sqlite/tests/bug50728.phpt
@@ -7,9 +7,9 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
--FILE--
<?php
try {
- $a = new PDO("sqlite:/this/path/should/not/exist.db");
+ $a = new PDO("sqlite:/this/path/should/not/exist.db");
} catch (PDOException $e) {
- var_dump($e->getCode());
+ var_dump($e->getCode());
}
?>
--EXPECT--
diff --git a/ext/pdo_sqlite/tests/bug52487.phpt b/ext/pdo_sqlite/tests/bug52487.phpt
index ff586d2f64..17a581296a 100644
--- a/ext/pdo_sqlite/tests/bug52487.phpt
+++ b/ext/pdo_sqlite/tests/bug52487.phpt
@@ -11,7 +11,7 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
$stmt = $db->prepare("select 1 as attr");
for ($i = 0; $i < 10; $i++) {
- $stmt->setFetchMode(PDO::FETCH_INTO, new stdClass);
+ $stmt->setFetchMode(PDO::FETCH_INTO, new stdClass);
}
print "ok\n";
diff --git a/ext/pdo_sqlite/tests/bug66033.phpt b/ext/pdo_sqlite/tests/bug66033.phpt
index ebd519171a..c48ebe41ec 100644
--- a/ext/pdo_sqlite/tests/bug66033.phpt
+++ b/ext/pdo_sqlite/tests/bug66033.phpt
@@ -7,26 +7,26 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
--FILE--
<?php
class DBStatement extends PDOStatement {
- public $dbh;
- protected function __construct($dbh) {
- $this->dbh = $dbh;
- throw new Exception("Blah");
- }
+ public $dbh;
+ protected function __construct($dbh) {
+ $this->dbh = $dbh;
+ throw new Exception("Blah");
+ }
}
$pdo = new PDO('sqlite::memory:', null, null);
$pdo->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('DBStatement',
- array($pdo)));
+ array($pdo)));
$pdo->exec("CREATE TABLE IF NOT EXISTS messages (
- id INTEGER PRIMARY KEY,
- title TEXT,
- message TEXT,
- time INTEGER)");
+ id INTEGER PRIMARY KEY,
+ title TEXT,
+ message TEXT,
+ time INTEGER)");
try {
- $pdoStatement = $pdo->query("select * from messages");
+ $pdoStatement = $pdo->query("select * from messages");
} catch (Exception $e) {
- var_dump($e->getMessage());
+ var_dump($e->getMessage());
}
?>
--EXPECT--
diff --git a/ext/pdo_sqlite/tests/bug70862.phpt b/ext/pdo_sqlite/tests/bug70862.phpt
index d66bb6262f..f676d66387 100644
--- a/ext/pdo_sqlite/tests/bug70862.phpt
+++ b/ext/pdo_sqlite/tests/bug70862.phpt
@@ -14,10 +14,10 @@ $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
class HelloWrapper {
- public function stream_open() { return true; }
- public function stream_eof() { return true; }
- public function stream_read() { return NULL; }
- public function stream_stat() { return array(); }
+ public function stream_open() { return true; }
+ public function stream_eof() { return true; }
+ public function stream_read() { return NULL; }
+ public function stream_stat() { return array(); }
}
stream_wrapper_register("hello", "HelloWrapper");
diff --git a/ext/pdo_sqlite/tests/bug78192.phpt b/ext/pdo_sqlite/tests/bug78192.phpt
index dcf4b749be..defdafb681 100644
--- a/ext/pdo_sqlite/tests/bug78192.phpt
+++ b/ext/pdo_sqlite/tests/bug78192.phpt
@@ -23,6 +23,7 @@ var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
$connection->query('ALTER TABLE user ADD new_col VARCHAR(255)');
$stmt->execute(['id' => 10]);
var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
+?>
--EXPECT--
array(1) {
[0]=>
diff --git a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
index c452d4c34f..2d0dfc3e5d 100644
--- a/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
+++ b/ext/pdo_sqlite/tests/pdo_fetch_func_001.phpt
@@ -8,6 +8,8 @@ if (!extension_loaded('pdo_sqlite')) print 'skip not loaded';
<?php
$db = new PDO('sqlite::memory:');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
+
$db->exec('CREATE TABLE testing (id INTEGER , name VARCHAR)');
$db->exec('INSERT INTO testing VALUES(1, "php")');
$db->exec('INSERT INTO testing VALUES(2, "")');
@@ -34,27 +36,27 @@ $st = $db->query('SELECT * FROM testing');
var_dump($st->fetchAll(PDO::FETCH_FUNC, array('self', 'foo')));
class foo {
- public function method($x) {
- return "--- $x ---";
- }
+ public function method($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::method')));
- }
-
- static public function test($x, $y) {
- return $x .'---'. $y;
- }
-
- private function test2($x, $y) {
- return $x;
- }
-
- public function test3($x, $y) {
- return $x .'==='. $y;
- }
+ public function __construct($db) {
+ $st = $db->query('SELECT * FROM testing');
+ var_dump($st->fetchAll(PDO::FETCH_FUNC, array($this, 'parent::method')));
+ }
+
+ 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);
@@ -90,19 +92,29 @@ array(2) {
string(0) ""
}
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function 'nothing' not found or invalid function name in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function "nothing" not found or invalid function name in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error 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
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: function "" not found or invalid function name in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: no array or string given in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'PDOStatement' does not have a method 'foo' in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class PDOStatement does not have a method "foo" in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
array(2) {
[0]=>
@@ -117,14 +129,17 @@ array(2) {
string(4) "2---"
}
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: cannot access private method bar::test2() in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: non-static method bar::test2() cannot be called statically in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
-array(2) {
- [0]=>
- string(7) "1===php"
- [1]=>
- string(4) "2==="
-}
-Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class 'bar' does not have a method 'inexistent' in %s on line %d
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: non-static method bar::test3() cannot be called statically in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
+bool(false)
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: class bar does not have a method "inexistent" in %s on line %d
+
+Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
bool(false)
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
index c9157d1b05..b21620bee7 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate.phpt
@@ -16,7 +16,7 @@ $db->sqliteCreateAggregate('testing', function(&$a, $b) { $a .= $b; return $a; }
foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
- var_dump($row);
+ var_dump($row);
}
$db->query('DROP TABLE foobar');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt
index 671e4b3454..5660288af3 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt
@@ -7,11 +7,18 @@ PDO_sqlite: Testing invalid callback for sqliteCreateAggregate()
$pdo = new PDO('sqlite::memory:');
-$pdo->sqliteCreateAggregate('foo', 'a', '');
-$pdo->sqliteCreateAggregate('foo', 'strlen', '');
+try {
+ $pdo->sqliteCreateAggregate('foo', 'a', '');
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ $pdo->sqliteCreateAggregate('foo', 'strlen', '');
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: PDO::sqliteCreateAggregate(): function 'a' is not callable in %s on line %d
-
-Warning: PDO::sqliteCreateAggregate(): function '' is not callable in %s on line %d
+--EXPECT--
+PDO::sqliteCreateAggregate(): Argument #2 ($step_func) must be a valid callback, function "a" not found or invalid function name
+PDO::sqliteCreateAggregate(): Argument #3 ($finalize_func) must be a valid callback, function "" not found or invalid function name
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
index fcfc344896..0742d20e84 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
@@ -18,7 +18,7 @@ $db->sqliteCreateCollation('MYCOLLATE', function($a, $b) { return strnatcmp($a,
$result = $db->query('SELECT name FROM foobar ORDER BY name COLLATE MYCOLLATE');
foreach ($result as $row) {
- echo $row['name'] . "\n";
+ echo $row['name'] . "\n";
}
$result = $db->query('SELECT name FROM foobar ORDER BY name');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
index 1e753f3799..45075e9748 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction.phpt
@@ -17,7 +17,7 @@ $db->sqliteCreateFunction('testing', function($v) { return strtolower($v); });
foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
- var_dump($row);
+ var_dump($row);
}
$db->query('DROP TABLE foobar');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt
index a1d890ac1b..958ea0c484 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt
@@ -10,8 +10,12 @@ Chris MacPherson chris@kombine.co.uk
$db = new PDO( 'sqlite::memory:');
-$db->sqliteCreateFunction('bar-alias', 'bar');
+try {
+ $db->sqliteCreateFunction('bar-alias', 'bar');
+} catch (\TypeError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
---EXPECTF--
-Warning: PDO::sqliteCreateFunction(): function 'bar' is not callable in %s on line %d
+--EXPECT--
+PDO::sqliteCreateFunction(): Argument #2 ($callback) must be a valid callback, function "bar" not found or invalid function name
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt
index 5a329a1d97..9cb6ecc02d 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_with_flags.phpt
@@ -20,7 +20,7 @@ $db->sqliteCreateFunction('testing', function($v) { return strtolower($v); }, 1,
foreach ($db->query('SELECT testing(name) FROM foobar') as $row) {
- var_dump($row);
+ var_dump($row);
}
$db->query('DROP TABLE foobar');
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt
index 50b939b6eb..5ea4a2def1 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_extendederror_attr.phpt
@@ -7,6 +7,7 @@ PDO_sqlite: Testing PDO_SQLITE_ATTR_EXTENDED_RESULT_CODES
echo "Creating new PDO" . PHP_EOL;
$db = new PDO('sqlite::memory:');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$db->exec("CREATE TABLE dog ( id INTEGER PRIMARY KEY, name TEXT, annoying INTEGER )");
@@ -23,6 +24,7 @@ echo sprintf("Second Error Info: SQLSTATE Error Code: (%s), Driver Specific Erro
echo "Creating new PDO with Extended Result Codes turned on" . PHP_EOL;
$db = new PDO('sqlite::memory:', '', '', [PDO::SQLITE_ATTR_EXTENDED_RESULT_CODES => TRUE]);
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$db->exec("CREATE TABLE dog ( id INTEGER PRIMARY KEY, name TEXT, annoying INTEGER )");
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
index 493fff78d8..478121e721 100644
--- a/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_transaction.phpt
@@ -6,6 +6,7 @@ PDO_sqlite: Testing transaction
<?php
$db = new PDO('sqlite::memory:');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
$db->beginTransaction();
@@ -24,5 +25,7 @@ var_dump($r->rowCount());
$db->query('DROP TABLE foobar');
?>
---EXPECT--
+--EXPECTF--
int(0)
+
+Warning: PDO::query(): SQLSTATE[HY000]: General error: 6 database table is locked in %s on line %d