mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
ext/pdo_mysql: Optimize tests (#12751)
This commit is contained in:
@@ -18,7 +18,7 @@ try {
|
||||
}
|
||||
|
||||
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc');
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/inc/mysql_pdo_test.inc');
|
||||
if (false === MySQLPDOTest::detect_transactional_mysql_engine($db)) {
|
||||
die('skip your mysql configuration does not support working transactions');
|
||||
}
|
||||
@@ -31,7 +31,7 @@ require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
|
||||
$db = PDOTest::factory();
|
||||
|
||||
if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/mysql_pdo_test.inc');
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . '../../pdo_mysql/tests/inc/mysql_pdo_test.inc');
|
||||
$suf = ' ENGINE=' . MySQLPDOTest::detect_transactional_mysql_engine($db);
|
||||
} else {
|
||||
$suf = '';
|
||||
|
||||
@@ -4,16 +4,13 @@ Bug #41125 (PDO mysql + quote() + prepare() can result in seg fault)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$search = "o'";
|
||||
$sql = "SELECT 1 FROM DUAL WHERE 'o''riley' LIKE " . $db->quote('%' . $search . '%');
|
||||
|
||||
@@ -4,13 +4,12 @@ Bug #44327 (PDORow::queryString property & numeric offsets / Crash)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
@@ -38,11 +37,10 @@ $db = MySQLPDOTest::factory();
|
||||
@$stmt->execute();
|
||||
$row = $stmt->fetch();
|
||||
var_dump($row->queryString);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec("DROP TABLE test_44327");
|
||||
?>
|
||||
|
||||
@@ -4,16 +4,14 @@ Bug #46292 (PDO::setFetchMode() shouldn't requires the 2nd arg when using FETCH_
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdoDb = MySQLPDOTest::factory();
|
||||
|
||||
|
||||
class myclass {
|
||||
public $value;
|
||||
|
||||
@@ -42,7 +40,7 @@ MySQLPDOTest::skip();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_46292');
|
||||
?>
|
||||
|
||||
@@ -4,31 +4,29 @@ Bug #44327 (PDORow::queryString property & numeric offsets / Crash)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
|
||||
|
||||
$createSql = "CREATE TABLE `bug53551` (
|
||||
`count` bigint(20) unsigned NOT NULL DEFAULT '0'
|
||||
`count` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'
|
||||
)";
|
||||
|
||||
$db->exec('drop table if exists bug53551');
|
||||
$db->exec($createSql);
|
||||
$db->exec("insert into bug53551 set `count` = 1 ");
|
||||
$db->exec("INSERT INTO bug53551 SET `count` = 1 ");
|
||||
$db->exec("SET sql_mode = 'Traditional'");
|
||||
$sql = 'UPDATE bug53551 SET `count` = :count';
|
||||
$stmt = $db->prepare($sql);
|
||||
|
||||
$values = array (
|
||||
'count' => NULL,
|
||||
);
|
||||
$values = [
|
||||
'count' => null,
|
||||
];
|
||||
|
||||
echo "1\n";
|
||||
$stmt->execute($values);
|
||||
@@ -39,11 +37,10 @@ $stmt->execute($values);
|
||||
var_dump($stmt->errorInfo());
|
||||
|
||||
echo "\ndone\n";
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS bug53551');
|
||||
?>
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
--TEST--
|
||||
PDO MySQL Bug #53782 (foreach throws irrelevant exception)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$conn = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$conn = MySQLPDOTest::factory();
|
||||
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
@@ -31,11 +28,6 @@ foreach ($res as $k => $v) {
|
||||
|
||||
echo "DONE";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
?>
|
||||
--EXPECTF--
|
||||
Caught: SQLSTATE[42000]: %s
|
||||
Value: 0
|
||||
|
||||
@@ -4,38 +4,34 @@ Bug #54929 (Parse error with single quote in sql comment (pdo-mysql))
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
$pdodb = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdodb = MySQLPDOTest::factory();
|
||||
|
||||
function testQuery($query) {
|
||||
global $pdodb;
|
||||
$stmt = $pdodb->prepare($query);
|
||||
|
||||
if (!$stmt->execute(array("foo"))) {
|
||||
if (!$stmt->execute(["foo"])) {
|
||||
var_dump($stmt->errorInfo());
|
||||
} else{
|
||||
var_dump($stmt->fetch(PDO::FETCH_ASSOC));
|
||||
}
|
||||
}
|
||||
|
||||
testQuery("/* ' */ select ? as f1 /* ' */");
|
||||
testQuery("/* '-- */ select ? as f1 /* *' */");
|
||||
testQuery("/* ' */ select ? as f1 --';");
|
||||
testQuery("/* ' */ select ? as f1 -- 'a;");
|
||||
testQuery("/*'**/ select ? as f1 /* ' */");
|
||||
testQuery("/*'***/ select ? as f1 /* ' */");
|
||||
testQuery("/* ' */ SELECT ? AS f1 /* ' */");
|
||||
testQuery("/* '-- */ SELECT ? AS f1 /* *' */");
|
||||
testQuery("/* ' */ SELECT ? AS f1 --';");
|
||||
testQuery("/* ' */ SELECT ? AS f1 -- 'a;");
|
||||
testQuery("/*'**/ SELECT ? AS f1 /* ' */");
|
||||
testQuery("/*'***/ SELECT ? AS f1 /* ' */");
|
||||
testQuery("/*'**a ***b / ****
|
||||
******
|
||||
**/ select ? as f1 /* ' */");
|
||||
**/ SELECT ? AS f1 /* ' */");
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
@@ -4,12 +4,13 @@ Bug #63176 (Segmentation fault when instantiate 2 persistent PDO to the same db
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require(__DIR__. DIRECTORY_SEPARATOR . 'config.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
class PDO2 extends PDO {
|
||||
protected $transLevel;
|
||||
}
|
||||
@@ -18,15 +19,14 @@ class PDO3 extends PDO {
|
||||
protected $tomato;
|
||||
}
|
||||
|
||||
|
||||
class ModelA {
|
||||
public $db;
|
||||
public function __construct($h) {
|
||||
var_dump($h);
|
||||
if ($h) {
|
||||
$this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
|
||||
$this->db = new PDO2(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [PDO::ATTR_PERSISTENT => true]);
|
||||
} else {
|
||||
$this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
|
||||
$this->db = new PDO3(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [PDO::ATTR_PERSISTENT => true]);
|
||||
}
|
||||
$this->db->query('SELECT 1')->fetchAll();
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
--TEST--
|
||||
Bug #63185: nextRowset() ignores MySQL errors with native prepared statements
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$pdo->exec('DROP PROCEDURE IF EXISTS test_procedure_error_at_second');
|
||||
$pdo->exec('CREATE PROCEDURE test_procedure_error_at_second ()
|
||||
$procedure = 'test_procedure_error_at_second_63185';
|
||||
|
||||
$pdo->exec("CREATE PROCEDURE {$procedure} ()
|
||||
BEGIN
|
||||
SELECT "x" as foo;
|
||||
SELECT 'x' AS foo;
|
||||
SELECT * FROM no_such_table;
|
||||
END');
|
||||
END");
|
||||
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
||||
$st = $pdo->query('CALL test_procedure_error_at_second()');
|
||||
$st = $pdo->query("CALL {$procedure}()");
|
||||
var_dump($st->fetchAll());
|
||||
try {
|
||||
var_dump($st->nextRowset());
|
||||
@@ -33,7 +33,7 @@ try {
|
||||
unset($st);
|
||||
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$st = $pdo->query('CALL test_procedure_error_at_second()');
|
||||
$st = $pdo->query("CALL {$procedure}()");
|
||||
var_dump($st->fetchAll());
|
||||
try {
|
||||
var_dump($st->nextRowset());
|
||||
@@ -41,13 +41,12 @@ try {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
var_dump($st->fetchAll());
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->query('DROP PROCEDURE IF EXISTS test_procedure_error_at_second');
|
||||
$pdo->query('DROP PROCEDURE IF EXISTS test_procedure_error_at_second_63185');
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(1) {
|
||||
|
||||
@@ -4,12 +4,12 @@ Bug #66141 (mysqlnd quote function is wrong with NO_BACKSLASH_ESCAPES after fail
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
include __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$input = 'Something\', 1 as one, 2 as two FROM dual; -- f';
|
||||
|
||||
@@ -1,22 +1,21 @@
|
||||
--TEST--
|
||||
Bug #66528: No PDOException or errorCode if database becomes unavailable before PDO::commit
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$dbh = MySQLPDOTest::factory();
|
||||
|
||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
|
||||
|
||||
$dbh->exec('CREATE TABLE test_66528 (a int) engine=innodb');
|
||||
$dbh->exec('CREATE TABLE test_66528 (a INT) ENGINE=InnoDB');
|
||||
$dbh->beginTransaction();
|
||||
$dbh->exec('INSERT INTO test_66528 (a) VALUES (1), (2)');
|
||||
$stmt = $dbh->query('SELECT * FROM test_66528');
|
||||
@@ -42,8 +41,9 @@ try {
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable(NULL, 'test_66528');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_66528');
|
||||
?>
|
||||
--EXPECT--
|
||||
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
|
||||
|
||||
@@ -4,13 +4,12 @@ Bug #66878: Multiple rowsets not returned unless PDO statement object is unset()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$sql = 'SELECT 123; SELECT 42; SELECT 999';
|
||||
|
||||
@@ -4,14 +4,14 @@ Bug #67004: Executing PDOStatement::fetch() more than once prevents releasing re
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$dbh = MySQLPDOTest::factory();
|
||||
|
||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$dbh->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
|
||||
|
||||
@@ -4,43 +4,43 @@ PDO MySQL Bug #38671 (PDO#getAttribute() cannot be called with platform-specific
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$attrs = array(
|
||||
$attrs = [
|
||||
// Extensive test: default value and set+get values
|
||||
PDO::ATTR_EMULATE_PREPARES => array(null, 1, 0),
|
||||
PDO::MYSQL_ATTR_DIRECT_QUERY => array(null, 0, 1),
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, false, true),
|
||||
|
||||
// Just test the default
|
||||
PDO::ATTR_AUTOCOMMIT => array(null),
|
||||
PDO::ATTR_PREFETCH => array(null),
|
||||
PDO::ATTR_TIMEOUT => array(null),
|
||||
PDO::ATTR_ERRMODE => array(null),
|
||||
PDO::ATTR_SERVER_VERSION => array(null),
|
||||
PDO::ATTR_CLIENT_VERSION => array(null),
|
||||
PDO::ATTR_SERVER_INFO => array(null),
|
||||
PDO::ATTR_CONNECTION_STATUS => array(null),
|
||||
PDO::ATTR_CASE => array(null),
|
||||
PDO::ATTR_CURSOR_NAME => array(null),
|
||||
PDO::ATTR_CURSOR => array(null),
|
||||
PDO::ATTR_ORACLE_NULLS => array(null),
|
||||
PDO::ATTR_PERSISTENT => array(null),
|
||||
PDO::ATTR_STATEMENT_CLASS => array(null),
|
||||
PDO::ATTR_FETCH_TABLE_NAMES => array(null),
|
||||
PDO::ATTR_FETCH_CATALOG_NAMES => array(null),
|
||||
PDO::ATTR_DRIVER_NAME => array(null),
|
||||
PDO::ATTR_STRINGIFY_FETCHES => array(null),
|
||||
PDO::ATTR_MAX_COLUMN_LEN => array(null),
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => array(null),
|
||||
);
|
||||
PDO::ATTR_AUTOCOMMIT => [null],
|
||||
PDO::ATTR_PREFETCH => [null],
|
||||
PDO::ATTR_TIMEOUT => [null],
|
||||
PDO::ATTR_ERRMODE => [null],
|
||||
PDO::ATTR_SERVER_VERSION => [null],
|
||||
PDO::ATTR_CLIENT_VERSION => [null],
|
||||
PDO::ATTR_SERVER_INFO => [null],
|
||||
PDO::ATTR_CONNECTION_STATUS => [null],
|
||||
PDO::ATTR_CASE => [null],
|
||||
PDO::ATTR_CURSOR_NAME => [null],
|
||||
PDO::ATTR_CURSOR => [null],
|
||||
PDO::ATTR_ORACLE_NULLS => [null],
|
||||
PDO::ATTR_PERSISTENT => [null],
|
||||
PDO::ATTR_STATEMENT_CLASS => [null],
|
||||
PDO::ATTR_FETCH_TABLE_NAMES => [null],
|
||||
PDO::ATTR_FETCH_CATALOG_NAMES => [null],
|
||||
PDO::ATTR_DRIVER_NAME => [null],
|
||||
PDO::ATTR_STRINGIFY_FETCHES => [null],
|
||||
PDO::ATTR_MAX_COLUMN_LEN => [null],
|
||||
PDO::ATTR_DEFAULT_FETCH_MODE => [null],
|
||||
];
|
||||
|
||||
foreach ($attrs as $a => $vals) {
|
||||
foreach ($vals as $v) {
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
--TEST--
|
||||
Bug #70066: Unexpected "Cannot execute queries while other unbuffered queries"
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
|
||||
|
||||
@@ -21,7 +19,6 @@ $db = $pdo->query('SELECT DATABASE()')->fetchColumn(0);
|
||||
// USE is not supported in the prepared statement protocol,
|
||||
// so this will fall back to emulation.
|
||||
$pdo->query('USE ' . $db);
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
|
||||
@@ -4,21 +4,19 @@ Bug #70272 (Segfault in pdo_mysql)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--INI--
|
||||
report_memleaks=off
|
||||
--FILE--
|
||||
<?php
|
||||
$a = new Stdclass();
|
||||
$a = new stdClass();
|
||||
$a->a = &$a;
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$dummy = new StdClass();
|
||||
$dummy = new stdClass();
|
||||
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
$dummy = NULL;
|
||||
$db = MySQLPDOTest::factory();
|
||||
$dummy = null;
|
||||
|
||||
$a->c = $db;
|
||||
$a->b = $db->prepare("select 1");
|
||||
|
||||
@@ -4,24 +4,23 @@ Bug #70389 (PDO constructor changes unrelated variables)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require(__DIR__. DIRECTORY_SEPARATOR . 'config.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$flags = [
|
||||
PDO::MYSQL_ATTR_FOUND_ROWS => true,
|
||||
PDO::MYSQL_ATTR_LOCAL_INFILE => true,
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
];
|
||||
|
||||
$std = new StdClass();
|
||||
$std = new stdClass();
|
||||
$std->flags = $flags;
|
||||
|
||||
new PDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, $flags);
|
||||
var_dump($flags);
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
array(3) {
|
||||
|
||||
@@ -4,12 +4,12 @@ MySQL Prepared Statements and BLOBs
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->exec(sprintf('CREATE TABLE test_70862(id INT, label BLOB)'));
|
||||
@@ -38,7 +38,7 @@ MySQLPDOTest::skip();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_70862');
|
||||
?>
|
||||
|
||||
@@ -4,24 +4,21 @@ Bug #71145: Multiple statements in init command triggers unbuffered query error
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
$attr = array(
|
||||
$attr = [
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; SET SESSION sql_mode=traditional',
|
||||
PDO::ATTR_STRINGIFY_FETCHES => true,
|
||||
);
|
||||
putenv('PDOTEST_ATTR=' . serialize($attr));
|
||||
];
|
||||
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo = MySQLPDOTest::factoryWithAttr($attr);
|
||||
var_dump($pdo->query('SELECT 42')->fetchColumn(0));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
string(2) "42"
|
||||
|
||||
@@ -4,12 +4,12 @@ Bug #71569 (#70389 fix causes segmentation fault)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require(__DIR__. DIRECTORY_SEPARATOR . 'config.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
try {
|
||||
new PDO(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, [
|
||||
@@ -18,7 +18,6 @@ try {
|
||||
} catch (PDOException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
SQLSTATE[42000] [1065] Query was empty
|
||||
|
||||
@@ -4,16 +4,16 @@ PDO MySQL Bug #75177 Type 'bit' is fetched as unexpected string
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (!MySQLPDOTest::isPDOMySQLnd()) die('skip only for mysqlnd');
|
||||
MySQLPDOTest::skipNotMySQLnd();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$pdo->query("CREATE TABLE test_75177 (`bit` bit(8)) ENGINE=InnoDB");
|
||||
$pdo->query("CREATE TABLE test_75177 (`bit` BIT(8)) ENGINE=InnoDB");
|
||||
$pdo->query("INSERT INTO test_75177 (`bit`) VALUES (1), (0b011), (0b01100)");
|
||||
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
||||
@@ -27,12 +27,12 @@ $ret = $pdo->query("SELECT * FROM test_75177")->fetchAll();
|
||||
foreach ($ret as $i) {
|
||||
var_dump($i["bit"]);
|
||||
}
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require dirname(__FILE__) . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable(NULL, 'test_75177');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_75177');
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
||||
|
||||
@@ -4,22 +4,23 @@ Bug #76815: PDOStatement cannot be GCed/closeCursor-ed when a PROCEDURE resultse
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$pdo->query('DROP FUNCTION IF EXISTS tst');
|
||||
$pdo->query('DROP PROCEDURE IF EXISTS tst2');
|
||||
$pdo->query('CREATE FUNCTION tst() RETURNS VARCHAR(5) DETERMINISTIC BEGIN RETURN \'x12345\'; END');
|
||||
$pdo->query('CREATE PROCEDURE tst2() BEGIN SELECT tst(); END');
|
||||
$func = 'bug76815_pdo_mysql_f';
|
||||
$procedure = 'bug76815_pdo_mysql_p';
|
||||
|
||||
$st = $pdo->prepare('CALL tst2()');
|
||||
$pdo->query("CREATE FUNCTION {$func}() RETURNS VARCHAR(5) DETERMINISTIC BEGIN RETURN 'x12345'; END");
|
||||
$pdo->query("CREATE PROCEDURE {$procedure}() BEGIN SELECT {$func}(); END");
|
||||
|
||||
$st = $pdo->prepare("CALL {$procedure}()");
|
||||
try {
|
||||
$st->execute();
|
||||
} catch (PDOException $ex) {
|
||||
@@ -27,15 +28,14 @@ try {
|
||||
}
|
||||
unset($st);
|
||||
echo "Ok.\n";
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->query('DROP FUNCTION IF EXISTS tst');
|
||||
$pdo->query('DROP PROCEDURE IF EXISTS tst2');
|
||||
$pdo->query('DROP FUNCTION IF EXISTS bug76815_pdo_mysql_f');
|
||||
$pdo->query('DROP PROCEDURE IF EXISTS bug76815_pdo_mysql_p');
|
||||
?>
|
||||
--EXPECT--
|
||||
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'tst()' at row 1
|
||||
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'bug76815_pdo_mysql_f()' at row 1
|
||||
Ok.
|
||||
|
||||
@@ -4,12 +4,12 @@ Bug #77289: PDO MySQL segfaults with persistent connection
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
@@ -18,7 +18,6 @@ $pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_PERSISTENT => true]);
|
||||
$pdo->exec("DROP TABLE IF EXISTS bug77289");
|
||||
$pdo->exec("CREATE TEMPORARY TABLE bug77289 (x INT)");
|
||||
$pdo->exec("UPDATE bug77289 SET x = x");
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
--EXPECT--
|
||||
|
||||
@@ -4,31 +4,32 @@ Bug #78152: PDO::exec() - Bad error handling with multiple commands
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
|
||||
var_dump($db->exec("INSERT INTO test(id, label) VALUES (41, 'x'); INSERT INTO test_bad(id, label) VALUES (42, 'y')"));
|
||||
$table = 'bug78152_pdo_mysql';
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
|
||||
var_dump($db->exec("INSERT INTO {$table} (id, label) VALUES (41, 'x'); INSERT INTO {$table}_bad (id, label) VALUES (42, 'y')"));
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
try {
|
||||
var_dump($db->exec("INSERT INTO test(id, label) VALUES (42, 'x'); INSERT INTO test_bad(id, label) VALUES (43, 'y')"));
|
||||
var_dump($db->exec("INSERT INTO {$table} (id, label) VALUES (42, 'x'); INSERT INTO {$table}_bad (id, label) VALUES (43, 'y')"));
|
||||
} catch (PDOException $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require dirname(__FILE__) . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS bug78152_pdo_mysql');
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: PDO::exec(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test_bad' doesn't exist in %s on line %d
|
||||
Warning: PDO::exec(): SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.bug78152_pdo_mysql_bad' doesn't exist in %s on line %d
|
||||
bool(false)
|
||||
SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.test_bad' doesn't exist
|
||||
SQLSTATE[42S02]: Base table or view not found: 1146 Table '%s.bug78152_pdo_mysql_bad' doesn't exist
|
||||
|
||||
@@ -4,12 +4,12 @@ Bug #79132: PDO re-uses parameter values from earlier calls to execute()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
@@ -21,7 +21,7 @@ $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
test($pdo);
|
||||
|
||||
function test($pdo) {
|
||||
$stmt = $pdo->prepare('select ? a, ? b');
|
||||
$stmt = $pdo->prepare('SELECT ? a, ? b');
|
||||
|
||||
$set = [
|
||||
['a', 'b'],
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
--TEST--
|
||||
Bug #79375: mysqli_store_result does not report error from lock wait timeout
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function createDB(): PDO {
|
||||
$db = MySQLPDOTest::factory();
|
||||
@@ -22,7 +21,7 @@ function createDB(): PDO {
|
||||
|
||||
$db = createDB();
|
||||
$db2 = createDB();
|
||||
$db->query('CREATE TABLE test_79375 (first int) ENGINE = InnoDB');
|
||||
$db->query('CREATE TABLE test_79375 (first INT) ENGINE = InnoDB');
|
||||
$db->query('INSERT INTO test_79375 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9)');
|
||||
|
||||
function testNormalQuery(PDO $db, string $name) {
|
||||
@@ -94,7 +93,7 @@ echo "\n";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_79375');
|
||||
?>
|
||||
|
||||
@@ -4,14 +4,14 @@ Bug #79596 (MySQL FLOAT truncates to int some locales)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
MySQLPDOTest::skipNotMySQLnd('skip libmysql returns result as string');
|
||||
if (!setlocale(LC_ALL, 'de_DE', 'de-DE')) die('skip German locale not available');
|
||||
if (!MySQLPDOTest::isPDOMySQLnd()) die('skip libmysql returns result as string');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
setlocale(LC_ALL, 'de_DE', 'de-DE');
|
||||
|
||||
@@ -23,8 +23,7 @@ var_dump($pdo->query('SELECT broken FROM bug79596')->fetchColumn(0));
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->exec("DROP TABLE IF EXISTS bug79596");
|
||||
?>
|
||||
|
||||
@@ -4,12 +4,12 @@ Bug #79872: Can't execute query with pending result sets
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
@@ -21,7 +21,6 @@ try {
|
||||
} catch (PDOException $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
SQLSTATE[HY000]: General error: 2014 Cannot execute queries while there are pending result sets. Consider unsetting the previous PDOStatement or calling PDOStatement::closeCursor()
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
--TEST--
|
||||
Bug #80458 PDOStatement::fetchAll() throws for upsert queries
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
$db->query('CREATE TABLE test_80458 (first int) ENGINE = InnoDB');
|
||||
$db->query('CREATE TABLE test_80458 (first INT) ENGINE = InnoDB');
|
||||
$res = $db->query('INSERT INTO test_80458(first) VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13),(14),(15),(16)');
|
||||
var_dump($res->fetchAll());
|
||||
|
||||
@@ -42,19 +41,23 @@ $stmt = $db->prepare('SELECT first FROM test_80458 WHERE first=5');
|
||||
$stmt->execute();
|
||||
var_dump($stmt->fetchAll());
|
||||
|
||||
$db->exec('CREATE PROCEDURE nores() BEGIN DELETE FROM test_80458 WHERE first=6; END;');
|
||||
$stmt4 = $db->prepare('CALL nores()');
|
||||
$procedure_nores = 'nores_bug80458_pdo_mysql_p';
|
||||
|
||||
$db->exec("CREATE PROCEDURE {$procedure_nores}() BEGIN DELETE FROM test_80458 WHERE first=6; END;");
|
||||
$stmt4 = $db->prepare("CALL {$procedure_nores}()");
|
||||
$stmt4->execute();
|
||||
var_dump($stmt4->fetchAll());
|
||||
$db->exec('DROP PROCEDURE IF EXISTS nores');
|
||||
$db->exec("DROP PROCEDURE IF EXISTS {$procedure_nores}");
|
||||
|
||||
$db->exec('CREATE PROCEDURE ret() BEGIN SELECT first FROM test_80458 WHERE first=7; END;');
|
||||
$stmt5 = $db->prepare('CALL ret()');
|
||||
$procedure_ret = 'ret_bug80458_pdo_mysql_p';
|
||||
|
||||
$db->exec("CREATE PROCEDURE {$procedure_ret}() BEGIN SELECT first FROM test_80458 WHERE first=7; END;");
|
||||
$stmt5 = $db->prepare("CALL {$procedure_ret}()");
|
||||
$stmt5->execute();
|
||||
var_dump($stmt5->fetchAll());
|
||||
$stmt5->nextRowset(); // needed to fetch the empty result set of CALL
|
||||
var_dump($stmt5->fetchAll());
|
||||
$db->exec('DROP PROCEDURE IF EXISTS ret');
|
||||
$db->exec("DROP PROCEDURE IF EXISTS {$procedure_ret}");
|
||||
|
||||
/* With emulated prepares */
|
||||
print("Emulated prepares\n");
|
||||
@@ -81,17 +84,17 @@ $stmt = $db->prepare('SELECT first FROM test_80458 WHERE first=12');
|
||||
$stmt->execute();
|
||||
var_dump($stmt->fetchAll());
|
||||
|
||||
$db->exec('CREATE PROCEDURE nores() BEGIN DELETE FROM test_80458 WHERE first=13; END;');
|
||||
$stmt4 = $db->prepare('CALL nores()');
|
||||
$db->exec("CREATE PROCEDURE {$procedure_nores}() BEGIN DELETE FROM test_80458 WHERE first=13; END;");
|
||||
$stmt4 = $db->prepare("CALL {$procedure_nores}()");
|
||||
$stmt4->execute();
|
||||
var_dump($stmt4->fetchAll());
|
||||
$db->exec('CREATE PROCEDURE ret() BEGIN SELECT first FROM test_80458 WHERE first=14; END;');
|
||||
$stmt5 = $db->prepare('CALL ret()');
|
||||
$db->exec("CREATE PROCEDURE {$procedure_ret}() BEGIN SELECT first FROM test_80458 WHERE first=14; END;");
|
||||
$stmt5 = $db->prepare("CALL {$procedure_ret}()");
|
||||
$stmt5->execute();
|
||||
var_dump($stmt5->fetchAll());
|
||||
$stmt5->nextRowset(); // needed to fetch the empty result set of CALL
|
||||
var_dump($stmt5->fetchAll());
|
||||
$db->exec('DROP PROCEDURE IF EXISTS ret');
|
||||
$db->exec("DROP PROCEDURE IF EXISTS {$procedure_ret}");
|
||||
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
|
||||
@@ -103,15 +106,14 @@ var_dump($stmt->fetchAll());
|
||||
$stmt = $db->prepare('SELECT first FROM test_80458 WHERE first=16');
|
||||
$stmt->execute();
|
||||
var_dump($stmt->fetchAll());
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::dropTestTable($db, 'test_80458');
|
||||
$db->exec('DROP PROCEDURE IF EXISTS nores');
|
||||
$db->exec('DROP PROCEDURE IF EXISTS ret');
|
||||
$db->exec('DROP TABLE IF EXISTS test_80458');
|
||||
$db->exec('DROP PROCEDURE IF EXISTS nores_bug80458_pdo_mysql_p');
|
||||
$db->exec('DROP PROCEDURE IF EXISTS ret_bug80458_pdo_mysql_p');
|
||||
?>
|
||||
--EXPECT--
|
||||
array(0) {
|
||||
|
||||
@@ -4,13 +4,12 @@ Bug #80808: PDO returns ZEROFILL integers without leading zeros
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$pdo->exec('CREATE TABLE test_80808 (postcode INT(4) UNSIGNED ZEROFILL)');
|
||||
@@ -20,11 +19,10 @@ $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
||||
var_dump($pdo->query('SELECT * FROM test_80808')->fetchColumn(0));
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
var_dump($pdo->query('SELECT * FROM test_80808')->fetchColumn(0));
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_80808');
|
||||
?>
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
--TEST--
|
||||
Bug #80908: pdo_mysql lastInsertId() return wrong, when table id bigger than the maximum value of int64
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function createDB(): PDO {
|
||||
$db = MySQLPDOTest::factory();
|
||||
@@ -20,13 +19,13 @@ function createDB(): PDO {
|
||||
}
|
||||
|
||||
$db = createDB();
|
||||
$db->exec('CREATE TABLE test_80908 (`id` bigint(20) unsigned AUTO_INCREMENT, `name` varchar(5), primary key (`id`)) ENGINE = InnoDB AUTO_INCREMENT=10376293541461622799');
|
||||
$db->exec('CREATE TABLE test_80908 (`id` BIGINT(20) UNSIGNED AUTO_INCREMENT, `name` VARCHAR(5), PRIMARY KEY (`id`)) ENGINE = InnoDB AUTO_INCREMENT=10376293541461622799');
|
||||
|
||||
function testLastInsertId(PDO $db) {
|
||||
echo "Running test lastInsertId\n";
|
||||
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
|
||||
try {
|
||||
$db->exec("insert into test_80908 (`name`) values ('bar')");
|
||||
$db->exec("INSERT INTO test_80908 (`name`) VALUES ('bar')");
|
||||
$id = $db->lastInsertId();
|
||||
echo "Last insert id is " . $id . "\n";
|
||||
} catch (PDOException $e) {
|
||||
@@ -37,11 +36,10 @@ function testLastInsertId(PDO $db) {
|
||||
testLastInsertId($db);
|
||||
unset($db);
|
||||
echo "\n";
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_80908');
|
||||
?>
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
--TEST--
|
||||
Bug #81037 PDO discards error message text from prepared statement
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
MySQLPDOTest::createTestTable($pdo);
|
||||
|
||||
$sql = "SELECT id FROM test WHERE label = :par";
|
||||
$table = 'bug81037_pdo_mysql';
|
||||
MySQLPDOTest::createTestTable($table, $pdo);
|
||||
|
||||
$sql = "SELECT id FROM {$table} WHERE label = :par";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
try {
|
||||
$stmt->execute();
|
||||
@@ -25,12 +26,12 @@ try {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS bug81037_pdo_mysql');
|
||||
?>
|
||||
--EXPECT--
|
||||
SQLSTATE[HY093]: Invalid parameter number
|
||||
|
||||
@@ -1,29 +1,26 @@
|
||||
--TEST--
|
||||
PDO MySQL Bug #33689 (query() execute() and fetch() return false on valid select queries)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->exec('CREATE TABLE test_33689 (bar INT NOT NULL)');
|
||||
$db->exec('INSERT INTO test_33689 VALUES(1)');
|
||||
|
||||
var_dump($db->query('SELECT * from test_33689'));
|
||||
foreach ($db->query('SELECT * from test_33689') as $row) {
|
||||
var_dump($db->query('SELECT * FROM test_33689'));
|
||||
foreach ($db->query('SELECT * FROM test_33689') as $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
$stmt = $db->prepare('SELECT * from test_33689');
|
||||
$stmt = $db->prepare('SELECT * FROM test_33689');
|
||||
print_r($stmt->getColumnMeta(0));
|
||||
$stmt->execute();
|
||||
$tmp = $stmt->getColumnMeta(0);
|
||||
@@ -39,14 +36,14 @@ print_r($tmp);
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_33689');
|
||||
?>
|
||||
--EXPECTF--
|
||||
object(PDOStatement)#%d (1) {
|
||||
["queryString"]=>
|
||||
string(24) "SELECT * from test_33689"
|
||||
string(24) "SELECT * FROM test_33689"
|
||||
}
|
||||
Array
|
||||
(
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
--TEST--
|
||||
PDO MySQL Bug #37445 (Premature stmt object destruction)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->setAttribute(PDO :: ATTR_EMULATE_PREPARES, true);
|
||||
$stmt = $db->prepare("SELECT 1");
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
--TEST--
|
||||
PDO MySQL Bug #38546 (bindParam incorrect processing of bool types)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require dirname(__FILE__) . '/config.inc';
|
||||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require dirname(__FILE__) . '/config.inc';
|
||||
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
|
||||
@@ -49,7 +46,7 @@ if ($result === false) {
|
||||
print("ok insert\n");
|
||||
}
|
||||
|
||||
foreach ($db->query('SELECT * from test_38546') as $row) {
|
||||
foreach ($db->query('SELECT * FROM test_38546') as $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
@@ -75,7 +72,7 @@ if ($result === false) {
|
||||
print("ok prepare 1\n");
|
||||
}
|
||||
|
||||
foreach ($db->query('SELECT * from test_38546') as $row) {
|
||||
foreach ($db->query('SELECT * FROM test_38546') as $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
@@ -101,7 +98,7 @@ if ($result === false) {
|
||||
print("ok prepare 2\n");
|
||||
}
|
||||
|
||||
foreach ($db->query('SELECT * from test_38546') as $row) {
|
||||
foreach ($db->query('SELECT * FROM test_38546') as $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
@@ -128,7 +125,7 @@ if ($result === false) {
|
||||
print("ok prepare 3\n");
|
||||
}
|
||||
|
||||
foreach ($db->query('SELECT * from test_38546') as $row) {
|
||||
foreach ($db->query('SELECT * FROM test_38546') as $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
@@ -155,7 +152,7 @@ if ($result === false) {
|
||||
print("ok prepare 4\n");
|
||||
}
|
||||
|
||||
foreach ($db->query('SELECT * from test_38546') as $row) {
|
||||
foreach ($db->query('SELECT * FROM test_38546') as $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
@@ -182,14 +179,13 @@ if ($result === false) {
|
||||
print("ok prepare 5\n");
|
||||
}
|
||||
|
||||
foreach ($db->query('SELECT * from test_38546') as $row) {
|
||||
foreach ($db->query('SELECT * FROM test_38546') as $row) {
|
||||
print_r($row);
|
||||
}
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require dirname(__FILE__) . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_38546');
|
||||
?>
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
--TEST--
|
||||
PDO MySQL Bug #39483 (Problem with handling of \ char in prepared statements)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE);
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
|
||||
$stmt = $db->prepare('SELECT UPPER(\'\0:D\0\'),?');
|
||||
$stmt->execute(array(1));
|
||||
$stmt->execute([1]);
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_NUM));
|
||||
?>
|
||||
--EXPECTF--
|
||||
|
||||
@@ -1,35 +1,24 @@
|
||||
--TEST--
|
||||
Bug #39858 (Lost connection to MySQL server during query by a repeated call stored proced)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < 50000)
|
||||
die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
|
||||
$matches[1], $matches[2], $matches[3], $version));
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
function bug_39858($db) {
|
||||
$procedure = 'bug_39858_pdo_mysql_p';
|
||||
|
||||
$db->exec("DROP PROCEDURE IF EXISTS p");
|
||||
$db->exec("DROP PROCEDURE IF EXISTS {$procedure}");
|
||||
$db->exec("
|
||||
CREATE PROCEDURE p()
|
||||
CREATE PROCEDURE {$procedure}()
|
||||
NOT DETERMINISTIC
|
||||
CONTAINS SQL
|
||||
SQL SECURITY DEFINER
|
||||
@@ -38,19 +27,18 @@ function bug_39858($db) {
|
||||
SELECT 2 * 2;
|
||||
END;");
|
||||
|
||||
$stmt = $db->prepare("CALL p()");
|
||||
$stmt = $db->prepare("CALL {$procedure}()");
|
||||
$stmt->execute();
|
||||
do {
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
} while ($stmt->nextRowset());
|
||||
|
||||
$stmt = $db->prepare("CALL p()");
|
||||
$stmt = $db->prepare("CALL {$procedure}()");
|
||||
$stmt->execute();
|
||||
do {
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
} while ($stmt->nextRowset());
|
||||
$stmt->closeCursor();
|
||||
|
||||
}
|
||||
|
||||
printf("Emulated Prepared Statements...\n");
|
||||
@@ -65,9 +53,9 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec("DROP PROCEDURE IF EXISTS p");
|
||||
$db->exec("DROP PROCEDURE IF EXISTS bug_39858_pdo_mysql_p");
|
||||
?>
|
||||
--EXPECT--
|
||||
Emulated Prepared Statements...
|
||||
|
||||
@@ -4,29 +4,24 @@ Bug #41125 (PDO mysql + quote() + prepare() can result in segfault)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < 40100)
|
||||
die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
|
||||
$matches[1], $matches[2], $matches[3], $version));
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
// And now allow the evil to do his work
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
|
||||
$sql = "CREATE TABLE IF NOT EXISTS test_41125(id INT); INSERT INTO test_41125(id) VALUES (1); SELECT * FROM test_41125; INSERT INTO test_41125(id) VALUES (2); SELECT * FROM test_41125;";
|
||||
$sql = <<<SQL
|
||||
CREATE TABLE IF NOT EXISTS test_41125 (id INT);
|
||||
INSERT INTO test_41125 (id) VALUES (1);
|
||||
SELECT * FROM test_41125;
|
||||
INSERT INTO test_41125 (id) VALUES (2);
|
||||
SELECT * FROM test_41125;
|
||||
SQL;
|
||||
$stmt = $db->query($sql);
|
||||
do {
|
||||
var_dump($stmt->fetchAll());
|
||||
@@ -36,7 +31,7 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec("DROP TABLE IF EXISTS test_41125");
|
||||
?>
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
--TEST--
|
||||
PDO MySQL Bug #41698 (float parameters truncated to integer in prepared statements)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
setlocale(LC_ALL, "de","de_DE","de_DE.ISO8859-1","de_DE.ISO_8859-1","de_DE.UTF-8");
|
||||
|
||||
@@ -26,7 +23,7 @@ var_dump($db->query('SELECT * FROM test_41698')->fetchAll(PDO::FETCH_ASSOC));
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec("DROP TABLE IF EXISTS test_41698");
|
||||
?>
|
||||
|
||||
@@ -4,30 +4,20 @@ PDO MySQL Bug #41997 (stored procedure call returning single rowset blocks futur
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < 50000)
|
||||
die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
|
||||
$matches[1], $matches[2], $matches[3], $version));
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
$db->exec('DROP PROCEDURE IF EXISTS p');
|
||||
$db->exec('CREATE PROCEDURE p() BEGIN SELECT 1 AS "one"; END');
|
||||
$procedure = 'bug_41997_pdo_mysql_p';
|
||||
|
||||
$stmt = $db->query("CALL p()");
|
||||
$db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT 1 AS 'one'; END");
|
||||
|
||||
$stmt = $db->query("CALL {$procedure}()");
|
||||
do {
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
} while ($stmt->nextRowset());
|
||||
@@ -40,9 +30,9 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec("DROP PROCEDURE IF EXISTS p");
|
||||
$db->exec("DROP PROCEDURE IF EXISTS bug_41997_pdo_mysql_p");
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
|
||||
@@ -1,33 +1,18 @@
|
||||
--TEST--
|
||||
Bug #42499 (Multi-statement execution via PDO::exec() makes connection unusable)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$stmt = $db->query('SELECT VERSION() as _version');
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < 41000)
|
||||
die(sprintf("skip Need MySQL Server 4.1.0+, found %d.%02d.%02d (%d)\n",
|
||||
$matches[1], $matches[2], $matches[3], $version));
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
function bug_42499($db) {
|
||||
|
||||
$db->exec("DROP TABLE IF EXISTS test_42499");
|
||||
$db->exec("CREATE TABLE test_42499(id CHAR(1)); INSERT INTO test_42499(id) VALUES ('a')");
|
||||
|
||||
@@ -38,7 +23,6 @@ function bug_42499($db) {
|
||||
$db->exec('SELECT id FROM test_42499');
|
||||
// This will bail at you because you have not fetched the SELECT results: this is not a bug!
|
||||
$db->exec("INSERT INTO test_42499(id) VALUES ('b')");
|
||||
|
||||
}
|
||||
|
||||
print "Emulated Prepared Statements...\n";
|
||||
@@ -57,7 +41,7 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec("DROP TABLE IF EXISTS test_42499");
|
||||
?>
|
||||
|
||||
@@ -4,12 +4,12 @@ Bug #43371 (Memory errors in PDO constructor)
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$db = new PDO($dsn, PDO_MYSQL_TEST_USER, PDO_MYSQL_TEST_PASS, array(PDO::ATTR_PERSISTENT => true));
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
--TEST--
|
||||
Bug #44454 (Unexpected exception thrown in foreach() statement)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
function bug_44454($db) {
|
||||
|
||||
try {
|
||||
|
||||
$db->exec('DROP TABLE IF EXISTS test_44454');
|
||||
$db->exec('CREATE TABLE test_44454(a INT, b INT, UNIQUE KEY idx_ab (a, b))');
|
||||
$db->exec('INSERT INTO test_44454(a, b) VALUES (1, 1)');
|
||||
@@ -54,7 +49,6 @@ function bug_44454($db) {
|
||||
printf("... PDO - %s\n", var_export($db->errorInfo(), true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
@@ -71,7 +65,7 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_44454');
|
||||
?>
|
||||
|
||||
@@ -1,34 +1,19 @@
|
||||
--TEST--
|
||||
Bug #44707 (The MySQL PDO driver resets variable content after bindParam on tinyint field)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$stmt = $db->query('SELECT VERSION() as _version');
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < 41000)
|
||||
die(sprintf("skip Will work different with MySQL Server < 4.1.0, found %d.%02d.%02d (%d)\n",
|
||||
$matches[1], $matches[2], $matches[3], $version));
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
function bug_44707($db) {
|
||||
|
||||
$db->exec('CREATE TABLE test_44707(id INT, mybool TINYINT)');
|
||||
|
||||
$id = 1;
|
||||
@@ -54,7 +39,6 @@ function bug_44707($db) {
|
||||
|
||||
$stmt = $db->query('SELECT * FROM test_44707');
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +57,7 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_44707');
|
||||
?>
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
--TEST--
|
||||
Bug #45120 (PDOStatement->execute() returns true then false for same statement)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
function bug_45120($db) {
|
||||
|
||||
$stmt = $db->prepare("SELECT 1 AS 'one'");
|
||||
if (true !== $stmt->execute())
|
||||
printf("[001] Execute has failed: %s\n", var_export($stmt->errorInfo(), true));
|
||||
@@ -31,7 +27,6 @@ function bug_45120($db) {
|
||||
$res = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if ($res['one'] != 1)
|
||||
printf("[004] Wrong results: %s\n", var_export($res, true));
|
||||
|
||||
}
|
||||
|
||||
print "Emulated Prepared Statements\n";
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
--TEST--
|
||||
Bug #50323 (No ability to connect to database named 't;', no chance to escape semicolon)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
function changeDSN($original, $new_options) {
|
||||
$old_options = array();
|
||||
@@ -42,21 +40,21 @@ $db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
}
|
||||
|
||||
|
||||
if (1 === @$db->exec('CREATE DATABASE `crazy;dbname`')) {
|
||||
$dsn = changeDSN(getenv('PDOTEST_DSN'), array('dbname' => 'crazy;;dbname'));
|
||||
$user = getenv('PDOTEST_USER');
|
||||
$pass = getenv('PDOTEST_PASS');
|
||||
if (1 === @$db->exec('CREATE DATABASE `crazy;dbname`')) {
|
||||
$dsn = changeDSN(PDO_MYSQL_TEST_DSN, array('dbname' => 'crazy;;dbname'));
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
|
||||
new PDO($dsn, $user, $pass);
|
||||
}
|
||||
echo 'done!';
|
||||
new PDO($dsn, $user, $pass);
|
||||
}
|
||||
echo 'done!';
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
@$db->exec('DROP DATABASE IF EXISTS `crazy;dbname`');
|
||||
$db->exec('DROP DATABASE IF EXISTS `crazy;dbname`');
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
--TEST--
|
||||
Bug #51670 (getColumnMeta causes segfault when re-executing query after calling nextRowset)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$query = $db->prepare('SELECT 1 AS num');
|
||||
$query->execute();
|
||||
if(!is_array($query->getColumnMeta(0))) die('FAIL!');
|
||||
|
||||
@@ -4,21 +4,20 @@ PDO MySQL Bug #61207 (PDO::nextRowset() after a multi-statement query doesn't al
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
/** @var PDO $db */
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->query('create table `test_61207`( `id` int )');
|
||||
$db->query('CREATE TABLE `test_61207`(`id` INT)');
|
||||
|
||||
$handle1 = $db->prepare('insert into test_61207(id) values(1);
|
||||
select * from test_61207 where id = ?;
|
||||
update test_61207 set id = 2 where id = ?;');
|
||||
$handle1 = $db->prepare('INSERT INTO test_61207(id) VALUES (1);
|
||||
SELECT * FROM test_61207 WHERE id = ?;
|
||||
UPDATE test_61207 SET id = 2 WHERE id = ?;');
|
||||
|
||||
$handle1->bindValue(1, '1');
|
||||
$handle1->bindValue(2, '1');
|
||||
@@ -32,8 +31,8 @@ do {
|
||||
print("Results detected\n");
|
||||
} while($handle1->nextRowset());
|
||||
|
||||
$handle2 = $db->prepare('select * from test_61207 where id = ?;
|
||||
update test_61207 set id = 1 where id = ?;');
|
||||
$handle2 = $db->prepare('SELECT * FROM test_61207 WHERE id = ?;
|
||||
UPDATE test_61207 SET id = 1 WHERE id = ?;');
|
||||
|
||||
$handle2->bindValue(1, '2');
|
||||
$handle2->bindValue(2, '2');
|
||||
@@ -48,8 +47,8 @@ do {
|
||||
print("Results detected\n");
|
||||
} while($handle2->nextRowset());
|
||||
|
||||
$handle3 = $db->prepare('update test_61207 set id = 2 where id = ?;
|
||||
select * from test_61207 where id = ?;');
|
||||
$handle3 = $db->prepare('UPDATE test_61207 SET id = 2 WHERE id = ?;
|
||||
SELECT * FROM test_61207 WHERE id = ?;');
|
||||
|
||||
$handle3->bindValue(1, '1');
|
||||
$handle3->bindValue(2, '2');
|
||||
@@ -64,9 +63,9 @@ do {
|
||||
print("Results detected\n");
|
||||
} while($handle3->nextRowset());
|
||||
|
||||
$handle4 = $db->prepare('insert into test_61207(id) values(3);
|
||||
update test_61207 set id = 2 where id = ?;
|
||||
select * from test_61207 where id = ?;');
|
||||
$handle4 = $db->prepare('INSERT INTO test_61207(id) VALUES (3);
|
||||
UPDATE test_61207 SET id = 2 WHERE id = ?;
|
||||
SELECT * FROM test_61207 WHERE id = ?;');
|
||||
|
||||
$handle4->bindValue(1, '3');
|
||||
$handle4->bindValue(2, '2');
|
||||
@@ -83,7 +82,7 @@ do {
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_61207');
|
||||
?>
|
||||
|
||||
@@ -1,29 +1,17 @@
|
||||
--TEST--
|
||||
Bug #61411 (PDO Segfaults with PERSISTENT == TRUE && EMULATE_PREPARES == FALSE)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < 40106)
|
||||
die(sprintf("skip Need MySQL Server 4.1.6+, found %d.%02d.%02d (%d)\n",
|
||||
$matches[1], $matches[2], $matches[3], $version));
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$attr = getenv('PDOTEST_ATTR');
|
||||
$attr = PDO_MYSQL_TEST_ATTR;
|
||||
if (!$attr) {
|
||||
$attr = array();
|
||||
} else {
|
||||
@@ -32,9 +20,8 @@ if (!$attr) {
|
||||
$attr[PDO::ATTR_PERSISTENT] = true;
|
||||
$attr[PDO::ATTR_EMULATE_PREPARES] = false;
|
||||
$attr[PDO::ATTR_STRINGIFY_FETCHES] = true;
|
||||
putenv('PDOTEST_ATTR='.serialize($attr));
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db = MySQLPDOTest::factoryWithAttr($attr);
|
||||
|
||||
$stmt = $db->prepare("SELECT 1");
|
||||
$stmt->execute();
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
--TEST--
|
||||
Bug #61755 (A parsing bug in the prepared statements can lead to access violations)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
|
||||
@@ -1,26 +1,23 @@
|
||||
--TEST--
|
||||
Bug #74376 (Invalid free of persistent results on error/connection loss)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$attr = getenv('PDOTEST_ATTR');
|
||||
$attr = PDO_MYSQL_TEST_ATTR;
|
||||
$attr = $attr ? unserialize($attr) : [];
|
||||
$attr[PDO::ATTR_PERSISTENT] = true;
|
||||
$attr[PDO::ATTR_EMULATE_PREPARES] = false;
|
||||
|
||||
putenv('PDOTEST_ATTR=' . serialize($attr));
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$stmt = $db->query("select (select 1 union select 2)");
|
||||
$db = MySQLPDOTest::factoryWithAttr($attr);
|
||||
$stmt = $db->query("SELECT (SELECT 1 UNION SELECT 2)");
|
||||
|
||||
print "ok";
|
||||
?>
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
--TEST--
|
||||
PDO MySQL PECL bug #1295 (http://pecl.php.net/bugs/bug.php?id=12925)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
function bug_pecl_1295($db) {
|
||||
|
||||
$db->exec('DROP TABLE IF EXISTS test_12925');
|
||||
$db->exec('CREATE TABLE test_12925(id CHAR(1))');
|
||||
$db->exec("INSERT INTO test_12925(id) VALUES ('a')");
|
||||
@@ -27,7 +24,6 @@ function bug_pecl_1295($db) {
|
||||
$stmt->execute();
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
$stmt->closeCursor();
|
||||
|
||||
}
|
||||
|
||||
printf("Emulated...\n");
|
||||
@@ -44,7 +40,7 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_12925');
|
||||
?>
|
||||
|
||||
@@ -1,42 +1,29 @@
|
||||
--TEST--
|
||||
PECL Bug #7976 (Calling stored procedure several times)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$row = $db->query('SELECT VERSION() as _version')->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < 50000)
|
||||
die(sprintf("skip Need MySQL Server 5.0.0+, found %d.%02d.%02d (%d)\n",
|
||||
$matches[1], $matches[2], $matches[3], $version));
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
function bug_pecl_7976($db) {
|
||||
$procedure = 'bug_pecl_7976_pdo_mysql_p';
|
||||
$db->exec("DROP PROCEDURE IF EXISTS {$procedure}");
|
||||
$db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT '1' AS _one; END;");
|
||||
|
||||
$db->exec('DROP PROCEDURE IF EXISTS p');
|
||||
$db->exec('CREATE PROCEDURE p() BEGIN SELECT "1" AS _one; END;');
|
||||
|
||||
$stmt = $db->query('CALL p()');
|
||||
$stmt = $db->query("CALL {$procedure}()");
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
$stmt->closeCursor();
|
||||
|
||||
$stmt = $db->query('CALL p()');
|
||||
$stmt = $db->query("CALL {$procedure}()");
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
$stmt->closeCursor();
|
||||
|
||||
}
|
||||
|
||||
printf("Emulated...\n");
|
||||
@@ -53,9 +40,9 @@ print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP PROCEDURE IF EXISTS p');
|
||||
$db->exec('DROP PROCEDURE IF EXISTS bug_pecl_7976_pdo_mysql_p');
|
||||
?>
|
||||
--EXPECT--
|
||||
Emulated...
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
--TEST--
|
||||
Change column count after statement has been prepared
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
@@ -31,11 +30,10 @@ var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
|
||||
$db->exec('ALTER TABLE test_change_column_count ADD new_col VARCHAR(255)');
|
||||
$stmt->execute(['id' => 10]);
|
||||
var_dump($stmt->fetchAll(\PDO::FETCH_ASSOC));
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_change_column_count');
|
||||
?>
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
/* Overrule global settings, if need be */
|
||||
|
||||
if (false !== getenv('PDO_MYSQL_TEST_DSN')) {
|
||||
# user set them from their shell
|
||||
$config['ENV']['PDOTEST_DSN'] = getenv('PDO_MYSQL_TEST_DSN');
|
||||
$config['ENV']['PDOTEST_USER'] = getenv('PDO_MYSQL_TEST_USER');
|
||||
$config['ENV']['PDOTEST_PASS'] = getenv('PDO_MYSQL_TEST_PASS');
|
||||
if (false !== getenv('PDO_MYSQL_TEST_ATTR')) {
|
||||
$config['ENV']['PDOTEST_ATTR'] = getenv('PDO_MYSQL_TEST_ATTR');
|
||||
}
|
||||
} else {
|
||||
$config['ENV']['PDOTEST_DSN'] = 'mysql:host=localhost;dbname=test';
|
||||
$config['ENV']['PDOTEST_USER'] = 'root';
|
||||
$config['ENV']['PDOTEST_PASS'] = '';
|
||||
}
|
||||
|
||||
foreach ($config['ENV'] as $k => $v) {
|
||||
putenv("$k=$v");
|
||||
}
|
||||
|
||||
/* MySQL specific settings */
|
||||
define('PDO_MYSQL_TEST_ENGINE', (false !== getenv('PDO_MYSQL_TEST_ENGINE')) ? getenv('PDO_MYSQL_TEST_ENGINE') : 'InnoDB');
|
||||
define('PDO_MYSQL_TEST_HOST', (false !== getenv('PDO_MYSQL_TEST_HOST')) ? getenv('PDO_MYSQL_TEST_HOST') : 'localhost');
|
||||
define('PDO_MYSQL_TEST_PORT', (false !== getenv('PDO_MYSQL_TEST_PORT')) ? getenv('PDO_MYSQL_TEST_PORT') : NULL);
|
||||
define('PDO_MYSQL_TEST_DB', (false !== getenv('PDO_MYSQL_TEST_DB')) ? getenv('PDO_MYSQL_TEST_DB') : 'test');
|
||||
define('PDO_MYSQL_TEST_SOCKET', (false !== getenv('PDO_MYSQL_TEST_SOCKET')) ? getenv('PDO_MYSQL_TEST_SOCKET') : NULL);
|
||||
define('PDO_MYSQL_TEST_DSN', (false !== getenv('PDO_MYSQL_TEST_DSN')) ? getenv('PDO_MYSQL_TEST_DSN') : $config['ENV']['PDOTEST_DSN']);
|
||||
define('PDO_MYSQL_TEST_USER', (false !== getenv('PDO_MYSQL_TEST_USER')) ? getenv('PDO_MYSQL_TEST_USER') : $config['ENV']['PDOTEST_USER']);
|
||||
define('PDO_MYSQL_TEST_PASS', (false !== getenv('PDO_MYSQL_TEST_PASS')) ? getenv('PDO_MYSQL_TEST_PASS') : $config['ENV']['PDOTEST_PASS']);
|
||||
define('PDO_MYSQL_TEST_CHARSET', (false !== getenv('PDO_MYSQL_TEST_CHARSET')) ? getenv('PDO_MYSQL_TEST_CHARSET') : NULL);
|
||||
|
||||
if (!function_exists('sys_get_temp_dir')) {
|
||||
function sys_get_temp_dir() {
|
||||
|
||||
if (!empty($_ENV['TMP']))
|
||||
return realpath( $_ENV['TMP'] );
|
||||
if (!empty($_ENV['TMPDIR']))
|
||||
return realpath( $_ENV['TMPDIR'] );
|
||||
if (!empty($_ENV['TEMP']))
|
||||
return realpath( $_ENV['TEMP'] );
|
||||
|
||||
$temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
|
||||
if ($temp_file) {
|
||||
$temp_dir = realpath(dirname($temp_file));
|
||||
unlink($temp_file);
|
||||
return $temp_dir;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,22 +1,21 @@
|
||||
--TEST--
|
||||
Bug GH-11550 (MySQL Statement has a empty query result when the response field has changed, also Segmentation fault)
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$pdo->exec(<<<'SQL'
|
||||
CREATE TABLE `test_gh11550` (
|
||||
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `name`(`name`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
||||
@@ -25,14 +24,14 @@ $pdo->exec(<<<'SQL'
|
||||
INSERT INTO `test_gh11550` (`name`) VALUES ('test1');
|
||||
SQL);
|
||||
|
||||
$stmt = $pdo->prepare('select * from test_gh11550');
|
||||
$stmt = $pdo->prepare('SELECT * FROM test_gh11550');
|
||||
var_dump('PDO-1:', $stmt->execute(), $stmt->fetchAll());
|
||||
|
||||
$stmt->closeCursor(); // Optional. Segmentation fault (core dumped)
|
||||
|
||||
$pdo->exec(<<<'SQL'
|
||||
ALTER TABLE `test_gh11550`
|
||||
ADD COLUMN `a` varchar(255) NOT NULL DEFAULT '';
|
||||
ADD COLUMN `a` VARCHAR(255) NOT NULL DEFAULT '';
|
||||
SQL);
|
||||
|
||||
var_dump('PDO-2:', $stmt->execute(), $stmt->fetchAll());
|
||||
@@ -40,7 +39,7 @@ echo 'Done';
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
$pdo->query('DROP TABLE IF EXISTS test_gh11550');
|
||||
?>
|
||||
|
||||
@@ -4,13 +4,13 @@ GH-11587 PHP8.1: Fixed the condition for result set values to be of native type,
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (!extension_loaded('mysqlnd')) die('skip: This test requires the loading of mysqlnd');
|
||||
MySQLPDOTest::skipNotMySQLnd();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$createTestTable = <<<SQL
|
||||
@@ -74,7 +74,7 @@ echo 'done!';
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_11587');
|
||||
?>
|
||||
14
ext/pdo_mysql/tests/inc/config.inc
Normal file
14
ext/pdo_mysql/tests/inc/config.inc
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
$env = [
|
||||
'PDO_MYSQL_TEST_DSN' => false !== getenv('PDO_MYSQL_TEST_DSN') ? getenv('PDO_MYSQL_TEST_DSN') : 'mysql:host=localhost;dbname=test',
|
||||
'PDO_MYSQL_TEST_USER' => false !== getenv('PDO_MYSQL_TEST_USER') ? getenv('PDO_MYSQL_TEST_USER') : 'root',
|
||||
'PDO_MYSQL_TEST_PASS' => false !== getenv('PDO_MYSQL_TEST_PASS') ? getenv('PDO_MYSQL_TEST_PASS') : '',
|
||||
'PDO_MYSQL_TEST_ENGINE' => false !== getenv('PDO_MYSQL_TEST_ENGINE') ? getenv('PDO_MYSQL_TEST_ENGINE') : 'InnoDB',
|
||||
'PDO_MYSQL_TEST_HOST' => false !== getenv('PDO_MYSQL_TEST_HOST') ? getenv('PDO_MYSQL_TEST_HOST') : 'localhost',
|
||||
'PDO_MYSQL_TEST_PORT' => false !== getenv('PDO_MYSQL_TEST_PORT') ? getenv('PDO_MYSQL_TEST_PORT') : null,
|
||||
'PDO_MYSQL_TEST_DB' => false !== getenv('PDO_MYSQL_TEST_DB') ? getenv('PDO_MYSQL_TEST_DB') : 'test',
|
||||
'PDO_MYSQL_TEST_SOCKET' => false !== getenv('PDO_MYSQL_TEST_SOCKET') ? getenv('PDO_MYSQL_TEST_SOCKET') : null,
|
||||
'PDO_MYSQL_TEST_CHARSET' => false !== getenv('PDO_MYSQL_TEST_CHARSET') ? getenv('PDO_MYSQL_TEST_CHARSET') : null,
|
||||
'PDO_MYSQL_TEST_ATTR' => false !== getenv('PDO_MYSQL_TEST_ATTR') ? getenv('PDO_MYSQL_TEST_ATTR') : null,
|
||||
];
|
||||
?>
|
||||
@@ -1,25 +1,24 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc');
|
||||
require_once(dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc');
|
||||
require_once __DIR__ . '/config.inc';
|
||||
require_once dirname(__DIR__, 4) . '/ext/pdo/tests/pdo_test.inc';
|
||||
|
||||
foreach ($env as $k => $v) {
|
||||
define($k, $v);
|
||||
}
|
||||
|
||||
class MySQLPDOTest extends PDOTest {
|
||||
|
||||
static function factory($classname = 'PDO', $drop_test_tables = false, $myattr = null, $mydsn = null) {
|
||||
|
||||
static function factory($classname = 'PDO', $mydsn = null, $myAttr = null) {
|
||||
$dsn = self::getDSN($mydsn);
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
$attr = getenv('PDOTEST_ATTR');
|
||||
$attr = PDO_MYSQL_TEST_ATTR;
|
||||
|
||||
if (is_string($attr) && strlen($attr)) {
|
||||
$attr = unserialize($attr);
|
||||
if ($myAttr) {
|
||||
$attr = $myAttr;
|
||||
} else {
|
||||
$attr = null;
|
||||
$attr = is_string($attr) && strlen($attr) ? unserialize($attr) : null;
|
||||
}
|
||||
if ($user === false)
|
||||
$user = NULL;
|
||||
if ($pass === false)
|
||||
$pass = NULL;
|
||||
|
||||
$db = new $classname($dsn, $user, $pass, $attr);
|
||||
if (!$db) {
|
||||
@@ -32,20 +31,23 @@ class MySQLPDOTest extends PDOTest {
|
||||
return $db;
|
||||
}
|
||||
|
||||
static function createTestTable($db, $engine = null) {
|
||||
static function factoryWithAttr($attr) {
|
||||
return self::factory('PDO', null, $attr);
|
||||
}
|
||||
|
||||
static function createTestTable($table, $db, $engine = null) {
|
||||
if (!$engine)
|
||||
$engine = PDO_MYSQL_TEST_ENGINE;
|
||||
|
||||
$db->exec('DROP TABLE IF EXISTS test');
|
||||
$db->exec('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE=' . $engine);
|
||||
$db->exec("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')");
|
||||
$db->exec("DROP TABLE IF EXISTS {$table}");
|
||||
$db->exec("CREATE TABLE {$table} (id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE={$engine}");
|
||||
$db->exec("INSERT INTO {$table} (id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')");
|
||||
}
|
||||
|
||||
static function getTableEngine() {
|
||||
return PDO_MYSQL_TEST_ENGINE;
|
||||
}
|
||||
|
||||
|
||||
static function getDSN($new_options = null, $addition = '') {
|
||||
if (!$new_options)
|
||||
return PDO_MYSQL_TEST_DSN . $addition;
|
||||
@@ -118,27 +120,20 @@ class MySQLPDOTest extends PDOTest {
|
||||
}
|
||||
|
||||
static function getTempDir() {
|
||||
if (!empty($_ENV['TMP']))
|
||||
return realpath( $_ENV['TMP'] );
|
||||
if (!empty($_ENV['TMPDIR']))
|
||||
return realpath( $_ENV['TMPDIR'] );
|
||||
if (!empty($_ENV['TEMP']))
|
||||
return realpath( $_ENV['TEMP'] );
|
||||
|
||||
if (!function_exists('sys_get_temp_dir')) {
|
||||
|
||||
if (!empty($_ENV['TMP']))
|
||||
return realpath( $_ENV['TMP'] );
|
||||
if (!empty($_ENV['TMPDIR']))
|
||||
return realpath( $_ENV['TMPDIR'] );
|
||||
if (!empty($_ENV['TEMP']))
|
||||
return realpath( $_ENV['TEMP'] );
|
||||
|
||||
$temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
|
||||
if ($temp_file) {
|
||||
$temp_dir = realpath(dirname($temp_file));
|
||||
unlink($temp_file);
|
||||
return $temp_dir;
|
||||
}
|
||||
return FALSE;
|
||||
} else {
|
||||
return sys_get_temp_dir();
|
||||
$temp_file = tempnam(md5(uniqid(rand(), TRUE)), '');
|
||||
if ($temp_file) {
|
||||
$temp_dir = realpath(dirname($temp_file));
|
||||
unlink($temp_file);
|
||||
return $temp_dir;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static function detect_transactional_mysql_engine($db) {
|
||||
@@ -158,20 +153,59 @@ class MySQLPDOTest extends PDOTest {
|
||||
}
|
||||
|
||||
static function isPDOMySQLnd() {
|
||||
ob_start();
|
||||
phpinfo();
|
||||
$tmp = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return (preg_match('/PDO Driver for MySQL.*enabled/', $tmp) &&
|
||||
preg_match('/Client API version.*mysqlnd/', $tmp));
|
||||
ob_start();
|
||||
phpinfo();
|
||||
$tmp = ob_get_contents();
|
||||
ob_end_clean();
|
||||
return (preg_match('/PDO Driver for MySQL.*enabled/', $tmp) &&
|
||||
preg_match('/Client API version.*mysqlnd/', $tmp));
|
||||
}
|
||||
|
||||
static function dropTestTable($db = NULL, $tableName = 'test') {
|
||||
if (is_null($db))
|
||||
static function skip() {
|
||||
try {
|
||||
$db = self::factory();
|
||||
|
||||
$db->exec('DROP TABLE IF EXISTS '.$tableName);
|
||||
} catch (PDOException $e) {
|
||||
die('skip could not connect');
|
||||
}
|
||||
}
|
||||
|
||||
static function skipInfileNotAllowed() {
|
||||
$db = self::factory();
|
||||
$stmt = $db->query("SHOW VARIABLES LIKE 'local_infile'");
|
||||
if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != 'ON'))
|
||||
die("skip Server variable 'local_infile' seems not set to 'ON', found '". $row['value'] ."'");
|
||||
}
|
||||
|
||||
static function skipVersionThanLess ($expected_version) {
|
||||
$nums = [
|
||||
(int) substr($expected_version, 0, 1),
|
||||
(int) substr($expected_version, 1, 2),
|
||||
(int) substr($expected_version, 3, 2),
|
||||
];
|
||||
$expected_version_str = implode('.', $nums);
|
||||
|
||||
$db = self::factory();
|
||||
$stmt = $db->query('SELECT VERSION() as _version');
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$matches = array();
|
||||
if (!preg_match('/^(\d+)\.(\d+)\.(\d+)/ismU', $row['_version'], $matches))
|
||||
die(sprintf("skip Cannot determine MySQL Server version\n"));
|
||||
|
||||
$version = $matches[1] * 10000 + $matches[2] * 100 + $matches[3];
|
||||
if ($version < $expected_version)
|
||||
die(sprintf("skip Need MySQL Server %s+, found %d.%02d.%02d (%d)\n",
|
||||
$expected_version_str, $matches[1], $matches[2], $matches[3], $version));
|
||||
}
|
||||
|
||||
static function skipNotMySQLnd(?string $message = null) {
|
||||
$message = $message ?? 'skip only for mysqlnd';
|
||||
if (!self::isPDOMySQLnd()) die($message);
|
||||
}
|
||||
|
||||
static function skipNotTransactionalEngine(?string $message = null) {
|
||||
$db = self::factory();
|
||||
$message = $message ?? 'skip Transactional engine not found';
|
||||
if (false == self::detect_transactional_mysql_engine($db)) die($message);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -1,20 +1,18 @@
|
||||
--TEST--
|
||||
PDO MySQL auto_increment / last insert id
|
||||
--EXTENSIONS--
|
||||
pdo
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require __DIR__ . '/config.inc';
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
PDOTest::skip();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
|
||||
$db = PDOTest::test_factory(__DIR__ . '/common.phpt');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
print_r($db->query("CREATE TABLE test_last_insert_id (id int auto_increment primary key, num int)"));
|
||||
print_r($db->query("CREATE TABLE test_last_insert_id (id INT AUTO_INCREMENT PRIMARY KEY, num INT)"));
|
||||
|
||||
print_r($db->query("INSERT INTO test_last_insert_id (id, num) VALUES (23, 42)"));
|
||||
|
||||
@@ -24,13 +22,14 @@ print_r($db->lastInsertId());
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable(NULL, 'test_last_insert_id');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS test_last_insert_id');
|
||||
?>
|
||||
--EXPECT--
|
||||
PDOStatement Object
|
||||
(
|
||||
[queryString] => CREATE TABLE test_last_insert_id (id int auto_increment primary key, num int)
|
||||
[queryString] => CREATE TABLE test_last_insert_id (id INT AUTO_INCREMENT PRIMARY KEY, num INT)
|
||||
)
|
||||
PDOStatement Object
|
||||
(
|
||||
|
||||
@@ -4,13 +4,13 @@ PDO MySQL should use native types if ATTR_STRINGIFY_FETCHES is not enabled
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (!MySQLPDOTest::isPDOMySQLnd()) die('skip mysqlnd only');
|
||||
MySQLPDOTest::skipNotMySQLnd();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
@@ -26,7 +26,7 @@ var_dump($db->query('SELECT * FROM test_native_types')->fetchAll(PDO::FETCH_ASSO
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_native_types');
|
||||
?>
|
||||
|
||||
@@ -4,16 +4,15 @@ MySQL PDO->__construct() - Generic + DSN
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function tryandcatch($offset, $code) {
|
||||
|
||||
try {
|
||||
eval($code);
|
||||
assert(sprintf("[%03d] Should have failed\n", $offset) != '');
|
||||
@@ -29,7 +28,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
try {
|
||||
if (NULL !== ($db = @new PDO()))
|
||||
printf("[001] Too few parameters\n");
|
||||
@@ -104,7 +102,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) {
|
||||
printf("[017] DSN=%s, %s\n", $dsn, $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// what about long values for a valid option ...
|
||||
@@ -142,7 +139,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
// atoi('abc') = 0, 0 -> fallback to default 3306 -> may or may not fail!
|
||||
} catch (PDOException $e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (PDO_MYSQL_TEST_DB) {
|
||||
@@ -161,7 +157,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) {
|
||||
printf("[023] DSN=%s, %s\n", $dsn, $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (PDO_MYSQL_TEST_SOCKET && (stristr(PDO_MYSQL_TEST_DSN, PDO_MYSQL_TEST_SOCKET) !== false)) {
|
||||
@@ -179,7 +174,6 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
try { $db = @new PDO($dsn, $user, $pass); } catch (PDOException $e) {
|
||||
printf("[025] DSN=%s, %s\n", $dsn, $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$have_charset_support = false;
|
||||
@@ -238,9 +232,7 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
} else {
|
||||
printf("[030] You're trying to run the tests with charset '%s' which seems not supported by the server!", $charset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($have_charset_support) {
|
||||
@@ -282,10 +274,8 @@ if (getenv('CIRCLECI')) die('xfail Broken on CicleCI');
|
||||
} catch (PDOException $e) {
|
||||
printf("[034] %s\n", $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
printf("[001] %s, [%s] %s\n",
|
||||
$e->getMessage(),
|
||||
|
||||
@@ -4,7 +4,7 @@ MySQL PDO->__construct() - URI
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
/* TODO - fix this limitation */
|
||||
if (getenv('PDO_MYSQL_TEST_DSN') !== "mysql:dbname=phptest;unix_socket=/tmp/mysql.sock")
|
||||
@@ -14,7 +14,7 @@ if (getenv('PDO_MYSQL_TEST_DSN') !== "mysql:dbname=phptest;unix_socket=/tmp/mysq
|
||||
pdo.dsn.mysql="mysql:dbname=phptest;socket=/tmp/mysql.sock"
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$found = false;
|
||||
$values = ini_get_all();
|
||||
|
||||
@@ -4,21 +4,20 @@ MySQL PDO->__construct(), options
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function set_option_and_check($offset, $option, $value, $option_desc) {
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
|
||||
try {
|
||||
$db = new PDO($dsn, $user, $pass, array($option => $value));
|
||||
$db = new PDO($dsn, $user, $pass, [$option => $value]);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
|
||||
if (!is_object($db) || ($value !== ($tmp = @$db->getAttribute($option))))
|
||||
printf("[%03d] Expecting '%s'/%s got '%s'/%s' for options '%s'\n",
|
||||
@@ -29,45 +28,43 @@ MySQLPDOTest::skip();
|
||||
} catch (PDOException $e) {
|
||||
printf("[%03d] %s\n", $offset, $e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
|
||||
$valid_options = array(
|
||||
$valid_options = [
|
||||
/* pdo_dbh.c */
|
||||
PDO::ATTR_PERSISTENT => 'PDO::ATTR_PERSISTENT',
|
||||
PDO::ATTR_AUTOCOMMIT => 'PDO::ATTR_AUTOCOMMIT',
|
||||
PDO::ATTR_PERSISTENT => 'PDO::ATTR_PERSISTENT',
|
||||
PDO::ATTR_AUTOCOMMIT => 'PDO::ATTR_AUTOCOMMIT',
|
||||
/* mysql_driver.c */
|
||||
/* TODO Possible bug PDO::ATTR_TIMEOUT != MYSQLI_OPT_CONNECT_TIMEOUT*/
|
||||
PDO::ATTR_TIMEOUT => 'PDO::ATTR_TIMEOUT',
|
||||
PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES',
|
||||
PDO::ATTR_TIMEOUT => 'PDO::ATTR_TIMEOUT',
|
||||
PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES',
|
||||
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY',
|
||||
PDO::MYSQL_ATTR_LOCAL_INFILE => 'PDO::MYSQL_ATTR_LOCAL_INFILE',
|
||||
PDO::MYSQL_ATTR_DIRECT_QUERY => 'PDO::MYSQL_ATTR_DIRECT_QUERY',
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 'PDO::MYSQL_ATTR_USE_BUFFERED_QUERY',
|
||||
PDO::MYSQL_ATTR_LOCAL_INFILE => 'PDO::MYSQL_ATTR_LOCAL_INFILE',
|
||||
PDO::MYSQL_ATTR_DIRECT_QUERY => 'PDO::MYSQL_ATTR_DIRECT_QUERY',
|
||||
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'PDO::MYSQL_ATTR_INIT_COMMAND',
|
||||
PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES',
|
||||
);
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'PDO::MYSQL_ATTR_INIT_COMMAND',
|
||||
PDO::ATTR_EMULATE_PREPARES => 'PDO::ATTR_EMULATE_PREPARES',
|
||||
];
|
||||
|
||||
$defaults = array(
|
||||
PDO::ATTR_PERSISTENT => false,
|
||||
PDO::ATTR_AUTOCOMMIT => 1,
|
||||
$defaults = [
|
||||
PDO::ATTR_PERSISTENT => false,
|
||||
PDO::ATTR_AUTOCOMMIT => 1,
|
||||
/* TODO - why is this a valid option if getAttribute() does not support it?! */
|
||||
PDO::ATTR_TIMEOUT => false,
|
||||
PDO::ATTR_EMULATE_PREPARES => 1,
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
||||
PDO::ATTR_TIMEOUT => false,
|
||||
PDO::ATTR_EMULATE_PREPARES => 1,
|
||||
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
|
||||
/* TODO getAttribute() does not handle it */
|
||||
PDO::MYSQL_ATTR_LOCAL_INFILE => false,
|
||||
PDO::MYSQL_ATTR_LOCAL_INFILE => false,
|
||||
/* TODO getAttribute() does not handle it */
|
||||
PDO::MYSQL_ATTR_DIRECT_QUERY => 1,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => '',
|
||||
);
|
||||
PDO::MYSQL_ATTR_DIRECT_QUERY => 1,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => '',
|
||||
];
|
||||
|
||||
try {
|
||||
if (NULL !== ($db = @new PDO($dsn, $user, $pass, 'wrong type')))
|
||||
|
||||
@@ -4,17 +4,16 @@ MySQL PDO->__construct(), libmysql only options
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (MySQLPDOTest::isPDOMySQLnd())
|
||||
die("skip libmysql only options")
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function set_option_and_check($offset, $option, $value, $option_desc, $ignore_diff = false) {
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
@@ -36,7 +35,7 @@ if (MySQLPDOTest::isPDOMySQLnd())
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
|
||||
$valid_options = array();
|
||||
$valid_options = [];
|
||||
$valid_options[PDO::MYSQL_ATTR_MAX_BUFFER_SIZE] = 'PDO::MYSQL_ATTR_MAX_BUFFER_SIZE';
|
||||
$valid_options[PDO::MYSQL_ATTR_INIT_COMMAND] = 'PDO::MYSQL_ATTR_INIT_COMMAND';
|
||||
$valid_options[PDO::MYSQL_ATTR_READ_DEFAULT_FILE] = 'PDO::MYSQL_ATTR_READ_DEFAULT_FILE';
|
||||
|
||||
@@ -4,17 +4,16 @@ MySQL PDO->__construct() - URI
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
try {
|
||||
|
||||
if ($tmp = MySQLPDOTest::getTempDir()) {
|
||||
|
||||
$file = $tmp . DIRECTORY_SEPARATOR . 'pdomuri.tst';
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
@@ -64,5 +63,5 @@ MySQLPDOTest::skip();
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
--EXPECTF--
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,13 +4,12 @@ PDO::ATTR_AUTOCOMMIT
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
// autocommit should be on by default
|
||||
@@ -51,49 +50,50 @@ $db = MySQLPDOTest::factory();
|
||||
if (1 !== ($tmp = $db->getAttribute(PDO::ATTR_AUTOCOMMIT)))
|
||||
printf("[010] Expecting int/1 got %s\n", var_export($tmp, true));
|
||||
|
||||
$table = 'pdo_mysql_attr_autocommit';
|
||||
if (MySQLPDOTest::detect_transactional_mysql_engine($db)) {
|
||||
// nice, we have a transactional engine to play with
|
||||
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
|
||||
MySQLPDOTest::createTestTable($table, $db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
$row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC);
|
||||
$num = $row['_num'];
|
||||
|
||||
$db->query("INSERT INTO test(id, label) VALUES (100, 'z')");
|
||||
$db->query("INSERT INTO {$table} (id, label) VALUES (100, 'z')");
|
||||
$num++;
|
||||
$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
|
||||
$row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['_num'] != $num)
|
||||
printf("[011] Insert has failed, test will fail\n");
|
||||
|
||||
// autocommit is on, no rollback possible
|
||||
$db->query('ROLLBACK');
|
||||
$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
|
||||
$row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['_num'] != $num)
|
||||
printf("[012] ROLLBACK should not have undone anything\n");
|
||||
|
||||
if (!$db->setAttribute(PDO::ATTR_AUTOCOMMIT, 0))
|
||||
printf("[013] Cannot turn off autocommit\n");
|
||||
|
||||
$db->query('DELETE FROM test WHERE id = 100');
|
||||
$db->query("DELETE FROM {$table} WHERE id = 100");
|
||||
$db->query('ROLLBACK');
|
||||
$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
|
||||
$row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['_num'] != $num)
|
||||
printf("[014] ROLLBACK should have undone the DELETE\n");
|
||||
|
||||
$db->query('DELETE FROM test WHERE id = 100');
|
||||
$db->query("DELETE FROM {$table} WHERE id = 100");
|
||||
$db->query('COMMIT');
|
||||
$num--;
|
||||
$row = $db->query('SELECT COUNT(*) AS _num FROM test')->fetch(PDO::FETCH_ASSOC);
|
||||
$row = $db->query("SELECT COUNT(*) AS _num FROM {$table}")->fetch(PDO::FETCH_ASSOC);
|
||||
if ($row['_num'] != $num)
|
||||
printf("[015] DELETE should have been committed\n");
|
||||
|
||||
}
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
require __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_attr_autocommit');
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,23 +4,24 @@ PDO::ATTR_CASE
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
|
||||
$table = 'pdo_mysql_attr_case';
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
|
||||
$default = $db->getAttribute(PDO::ATTR_CASE);
|
||||
$known = array(
|
||||
$known = [
|
||||
PDO::CASE_LOWER => 'PDO::CASE_LOWER',
|
||||
PDO::CASE_UPPER => 'PDO::CASE_UPPER',
|
||||
PDO::CASE_NATURAL => 'PDO::CASE_NATURAL'
|
||||
);
|
||||
];
|
||||
if (!isset($known[$default]))
|
||||
printf("[001] getAttribute(PDO::ATTR_CASE) returns unknown value '%s'\n",
|
||||
var_export($default, true));
|
||||
@@ -28,7 +29,7 @@ $db = MySQLPDOTest::factory();
|
||||
var_dump($known[$default]);
|
||||
|
||||
// lets see what the default is...
|
||||
if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM test ORDER BY id ASC LIMIT 2")))
|
||||
if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label FROM {$table} ORDER BY id ASC LIMIT 2")))
|
||||
printf("[002] %s - %s\n",
|
||||
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
|
||||
|
||||
@@ -42,15 +43,15 @@ $db = MySQLPDOTest::factory();
|
||||
printf("[004] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
|
||||
var_export($tmp, true));
|
||||
|
||||
if (true === $db->exec('ALTER TABLE test ADD MiXeD CHAR(1)'))
|
||||
if (true === $db->exec("ALTER TABLE {$table} ADD MiXeD CHAR(1)"))
|
||||
printf("[005] Cannot add column %s - %s\n",
|
||||
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
|
||||
|
||||
if (false === $db->exec('ALTER TABLE test ADD MYUPPER CHAR(1)'))
|
||||
if (false === $db->exec("ALTER TABLE {$table} ADD MYUPPER CHAR(1)"))
|
||||
printf("[006] Cannot add column %s - %s\n",
|
||||
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
|
||||
|
||||
if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM test ORDER BY id ASC LIMIT 2")))
|
||||
if (!is_object($stmt = $db->query("SELECT id, id AS 'ID_UPPER', label, MiXeD, MYUPPER FROM {$table} ORDER BY id ASC LIMIT 2")))
|
||||
printf("[007] %s - %s\n",
|
||||
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
|
||||
|
||||
@@ -64,7 +65,7 @@ $db = MySQLPDOTest::factory();
|
||||
printf("[009] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
|
||||
var_export($tmp, true));
|
||||
|
||||
if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM test ORDER BY id ASC LIMIT 1")))
|
||||
if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, MYUPPER AS 'lower' FROM {$table} ORDER BY id ASC LIMIT 1")))
|
||||
printf("[010] %s - %s\n",
|
||||
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
|
||||
|
||||
@@ -78,7 +79,7 @@ $db = MySQLPDOTest::factory();
|
||||
printf("[012] getAttribute(PDO::ATTR_CASE) returns wrong value '%s'\n",
|
||||
var_export($tmp, true));
|
||||
|
||||
if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM test ORDER BY id ASC LIMIT 1")))
|
||||
if (!is_object($stmt = $db->query("SELECT id, label, MiXeD, MYUPPER, id AS 'ID' FROM {$table} ORDER BY id ASC LIMIT 1")))
|
||||
printf("[013] %s - %s\n",
|
||||
var_export($db->errorInfo(), true), var_export($db->errorCode(), true));
|
||||
|
||||
@@ -88,8 +89,9 @@ $db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_attr_case');
|
||||
?>
|
||||
--EXPECT--
|
||||
string(15) "PDO::CASE_LOWER"
|
||||
|
||||
@@ -4,13 +4,12 @@ PDO::ATTR_CLIENT_VERSION
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
assert(('' == $db->errorCode()) || ('00000' == $db->errorCode()));
|
||||
|
||||
@@ -4,13 +4,12 @@ PDO::ATTR_CONNECTION_STATUS
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$status = $db->getAttribute(PDO::ATTR_CONNECTION_STATUS);
|
||||
|
||||
@@ -4,13 +4,12 @@ PDO::ATTR_DRIVER_NAME
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
assert(('' == $db->errorCode()) || ('00000' == $db->errorCode()));
|
||||
|
||||
@@ -4,15 +4,14 @@ PDO::ATTR_ERRMODE
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
try {
|
||||
@@ -74,7 +73,6 @@ error_reporting=E_ALL
|
||||
$line = __LINE__ + 1;
|
||||
$db->query('THIS IS NOT VALID SQL');
|
||||
} catch (PDOException $e) {
|
||||
|
||||
$code = $db->errorCode();
|
||||
$info = $db->errorInfo();
|
||||
|
||||
@@ -107,7 +105,6 @@ error_reporting=E_ALL
|
||||
if ($e->getFile() !== __FILE__)
|
||||
printf("[020] Exception has been thrown in file '%s', exception object reports file '%s'\n",
|
||||
__FILE__, $e->getFile());
|
||||
|
||||
}
|
||||
|
||||
function my_handler($e) {
|
||||
|
||||
@@ -4,32 +4,40 @@ PDO::ATTR_FETCH_TABLE_NAMES
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
|
||||
$table = 'pdo_mysql_attr_fetch_table_names';
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
|
||||
$db->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 1);
|
||||
$stmt = $db->query('SELECT label FROM test LIMIT 1');
|
||||
$stmt = $db->query("SELECT label FROM {$table} LIMIT 1");
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
$stmt->closeCursor();
|
||||
|
||||
$db->setAttribute(PDO::ATTR_FETCH_TABLE_NAMES, 0);
|
||||
$stmt = $db->query('SELECT label FROM test LIMIT 1');
|
||||
$stmt = $db->query("SELECT label FROM {$table} LIMIT 1");
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
$stmt->closeCursor();
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_attr_fetch_table_names');
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
[0]=>
|
||||
array(1) {
|
||||
["test.label"]=>
|
||||
["pdo_mysql_attr_fetch_table_names.label"]=>
|
||||
string(1) "a"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,23 +4,21 @@ PDO::MYSQL_ATTR_INIT_COMMAND
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
|
||||
$table = sprintf("test_%s", md5(mt_rand(0, PHP_INT_MAX)));
|
||||
$table = 'pdo_mysql_attr_init_command';
|
||||
$db = new PDO($dsn, $user, $pass);
|
||||
$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
|
||||
|
||||
$create = sprintf('CREATE TABLE %s(id INT)', $table);
|
||||
var_dump($create);
|
||||
@@ -34,11 +32,16 @@ error_reporting=E_ALL
|
||||
$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
|
||||
$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
|
||||
print "done!";
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(58) "CREATE TABLE test_%s(id INT)"
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_attr_init_command');
|
||||
?>
|
||||
--EXPECT--
|
||||
string(48) "CREATE TABLE pdo_mysql_attr_init_command(id INT)"
|
||||
string(5) "00000"
|
||||
array(1) {
|
||||
[0]=>
|
||||
|
||||
@@ -4,19 +4,17 @@ MySQL PDO->__construct(), PDO::MYSQL_ATTR_MAX_BUFFER_SIZE
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (MySQLPDOTest::isPDOMySQLnd())
|
||||
die("skip PDO::MYSQL_ATTR_MAX_BUFFER_SIZE not supported with mysqlnd");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function try_buffer_size($offset, $buffer_size) {
|
||||
|
||||
try {
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
@@ -68,8 +66,9 @@ if (MySQLPDOTest::isPDOMySQLnd())
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable(NULL, 'test_attr_max_buffer_size');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS test_attr_max_buffer_size');
|
||||
?>
|
||||
--EXPECTF--
|
||||
[001] id = 1, val = 0123456789... (length: %d)
|
||||
|
||||
@@ -4,25 +4,25 @@ PDO::MYSQL_ATTR_MULTI_STATEMENTS
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--INI--
|
||||
error_reporting=E_ALL
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
$pass = PDO_MYSQL_TEST_PASS;
|
||||
|
||||
$table = sprintf("test_%s", md5(mt_rand(0, PHP_INT_MAX)));
|
||||
$table = 'pdo_mysql_attr_multi_statements';
|
||||
|
||||
$db = new PDO($dsn, $user, $pass);
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
|
||||
|
||||
$create = sprintf('CREATE TABLE %s(id INT)', $table);
|
||||
$db->exec($create);
|
||||
$db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
|
||||
@@ -51,9 +51,14 @@ error_reporting=E_ALL
|
||||
$stmt = $db->query('SELECT 1 AS value;');
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
|
||||
$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_attr_multi_statements');
|
||||
?>
|
||||
--EXPECTF--
|
||||
string(5) "00000"
|
||||
array(2) {
|
||||
|
||||
@@ -4,14 +4,15 @@ PDO::ATTR_ORACLE_NULLS
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
|
||||
$procedure = 'pdo_mysql_attr_oracle_nulls_p';
|
||||
|
||||
try {
|
||||
$db->setAttribute(PDO::ATTR_ORACLE_NULLS, []);
|
||||
@@ -48,10 +49,10 @@ MySQLPDOTest::skip();
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
|
||||
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
|
||||
|
||||
if ($have_procedures && (false !== $db->exec('DROP PROCEDURE IF EXISTS p')) &&
|
||||
(false !== $db->exec("CREATE PROCEDURE p() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) {
|
||||
if ($have_procedures && (false !== $db->exec("DROP PROCEDURE IF EXISTS {$procedure}")) &&
|
||||
(false !== $db->exec("CREATE PROCEDURE {$procedure}() BEGIN SELECT NULL as z, '' AS a, ' ' AS b, TRIM(' ') as c, ' d' AS d, ' e' AS e; END;"))) {
|
||||
// requires MySQL 5+
|
||||
$stmt = $db->prepare('CALL p()');
|
||||
$stmt = $db->prepare("CALL {$procedure}()");
|
||||
$stmt->execute();
|
||||
do {
|
||||
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||
@@ -64,11 +65,14 @@ MySQLPDOTest::skip();
|
||||
|
||||
}
|
||||
|
||||
if ($have_procedures)
|
||||
@$db->exec('DROP PROCEDURE IF EXISTS p');
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec("DROP PROCEDURE IF EXISTS pdo_mysql_attr_oracle_nulls_p");
|
||||
?>
|
||||
--EXPECTF--
|
||||
Attribute value must be of type int for selected attribute, array given
|
||||
Attribute value must be of type int for selected attribute, stdClass given
|
||||
|
||||
@@ -4,13 +4,12 @@ PDO::ATTR_PREFETCH
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
var_dump($db->getAttribute(PDO::ATTR_PREFETCH));
|
||||
var_dump($db->setAttribute(PDO::ATTR_PREFETCH, true));
|
||||
|
||||
@@ -4,13 +4,12 @@ PDO::ATTR_SERVER_INFO
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
assert(('' == $db->errorCode()) || ('00000' == $db->errorCode()));
|
||||
|
||||
@@ -4,13 +4,12 @@ PDO::ATTR_SERVER_VERSION
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
assert(('' == $db->errorCode()) || ('00000' == $db->errorCode()));
|
||||
|
||||
@@ -4,16 +4,18 @@ PDO::ATTR_STATEMENT_CLASS
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
|
||||
$table = 'pdo_mysql_attr_statement_class';
|
||||
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
|
||||
$default = $db->getAttribute(PDO::ATTR_STATEMENT_CLASS);
|
||||
var_dump($default);
|
||||
@@ -94,7 +96,7 @@ $db = MySQLPDOTest::factory();
|
||||
printf("[008] Expecting boolean/true got %s\n", var_export($tmp, true));
|
||||
|
||||
var_dump($db->getAttribute(PDO::ATTR_STATEMENT_CLASS));
|
||||
$stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2");
|
||||
|
||||
class mystatement5 extends mystatement4 {
|
||||
public function fetchAll($fetch_style = 1, ...$fetch_args): array {
|
||||
@@ -104,13 +106,13 @@ $db = MySQLPDOTest::factory();
|
||||
|
||||
if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('mystatement5', array('mystatement5')))))
|
||||
printf("[009] Expecting boolean/true got %s\n", var_export($tmp, true));
|
||||
$stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 2');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 2");
|
||||
var_dump($stmt->fetchAll());
|
||||
|
||||
if (true !== ($tmp = $db->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement'))))
|
||||
printf("[010] Expecting boolean/true got %s\n", var_export($tmp, true));
|
||||
|
||||
$stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 1");
|
||||
var_dump($stmt->fetchAll());
|
||||
|
||||
// Yes, this is a fatal error and I want it to fail.
|
||||
@@ -118,11 +120,16 @@ $db = MySQLPDOTest::factory();
|
||||
}
|
||||
try {
|
||||
$db->setAttribute(PDO::ATTR_STATEMENT_CLASS, ['mystatement6', ['mystatement6']]);
|
||||
$stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC LIMIT 1');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC LIMIT 1");
|
||||
} catch (\Error $e) {
|
||||
echo get_class($e), ': ', $e->getMessage(), \PHP_EOL;
|
||||
}
|
||||
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_attr_statement_class');
|
||||
?>
|
||||
--EXPECT--
|
||||
array(1) {
|
||||
|
||||
@@ -4,18 +4,17 @@ PDO->beginTransaction()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
die("skip Transactional engine not found");
|
||||
?>
|
||||
MySQLPDOTest::skipNotTransactionalEngine();
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
$table = 'pdo_mysql_begintransaction';
|
||||
|
||||
MySQLPDOTest::createTestTable($table, $db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
|
||||
if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
|
||||
printf("[001] Autocommit should be on by default\n");
|
||||
@@ -27,7 +26,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
|
||||
printf("[003] Autocommit should be on by default, beginTransaction() shall not impact it\n");
|
||||
|
||||
if (0 == $db->exec('DELETE FROM test'))
|
||||
if (0 == $db->exec("DELETE FROM {$table}"))
|
||||
printf("[004] No rows deleted, can't be true.\n");
|
||||
|
||||
/* This is the PDO way to close a connection */
|
||||
@@ -36,7 +35,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
/* Autocommit was off - by definition. Commit was not issued. DELETE should have been rolled back. */
|
||||
if (!($stmt = $db->query('SELECT id, label FROM test ORDER BY id ASC')))
|
||||
if (!($stmt = $db->query("SELECT id, label FROM {$table} ORDER BY id ASC")))
|
||||
printf("[005] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@@ -45,7 +44,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (!$db->beginTransaction())
|
||||
printf("[006] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id'])))
|
||||
if (1 !== $db->exec(sprintf('DELETE FROM %s WHERE id = %d', $table, $row['id'])))
|
||||
printf("[007] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
if (!$db->commit())
|
||||
@@ -54,7 +53,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
|
||||
printf("[009] Autocommit should be on after commit()\n");
|
||||
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id']))))
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id']))))
|
||||
printf("[010] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
var_dump($stmt->fetch(PDO::FETCH_ASSOC));
|
||||
@@ -62,9 +61,9 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (!$db->beginTransaction())
|
||||
printf("[011] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
$db->exec(sprintf("INSERT INTO test(id, label) VALUES (%d, 'z')", $row['id']));
|
||||
$db->exec(sprintf("INSERT INTO %s (id, label) VALUES (%d, 'z')", $table, $row['id']));
|
||||
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id']))))
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id']))))
|
||||
printf("[012] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
$new_row1 = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@@ -73,7 +72,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (!$db->commit())
|
||||
printf("[013] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id']))))
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id']))))
|
||||
printf("[014] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
$new_row2 = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@@ -86,7 +85,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (!$db->beginTransaction())
|
||||
printf("[016] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
if (1 !== $db->exec(sprintf('DELETE FROM test WHERE id = %d', $row['id'])))
|
||||
if (1 !== $db->exec(sprintf('DELETE FROM %s WHERE id = %d', $table, $row['id'])))
|
||||
printf("[017] DELETE should have indicated 1 deleted row, [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
if (!$db->rollback())
|
||||
@@ -95,7 +94,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
|
||||
printf("[019] Autocommit should be on after rollback\n");
|
||||
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM test WHERE id = %d', $row['id']))))
|
||||
if (!($stmt = $db->query(sprintf('SELECT id, label FROM %s WHERE id = %d', $table, $row['id']))))
|
||||
printf("[020] [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
$new_row2 = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
@@ -150,7 +149,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
|
||||
// TODO: What about an engine that does not support transactions?
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, 'MyISAM');
|
||||
MySQLPDOTest::createTestTable($table, $db, 'MyISAM');
|
||||
|
||||
if (false == $db->beginTransaction())
|
||||
printf("[031] Cannot start a transaction, [%s] [%s]\n",
|
||||
@@ -159,7 +158,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (1 !== $db->getAttribute(PDO::ATTR_AUTOCOMMIT))
|
||||
printf("[032] Autocommit should be on my default, beginTransaction() should not change that\n");
|
||||
|
||||
if (0 == $db->exec('DELETE FROM test'))
|
||||
if (0 == $db->exec("DELETE FROM {$table}"))
|
||||
printf("[033] No rows deleted, can't be true.\n");
|
||||
|
||||
if (!$db->commit())
|
||||
@@ -169,7 +168,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
printf("[035] Cannot start a transaction, [%s] [%s]\n",
|
||||
$db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
if (0 == $db->exec("INSERT INTO test(id, label) VALUES (1, 'a')"))
|
||||
if (0 == $db->exec("INSERT INTO {$table} (id, label) VALUES (1, 'a')"))
|
||||
printf("[036] Cannot insert data, [%s] [%s]\n",
|
||||
$db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
@@ -179,15 +178,16 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
|
||||
var_dump($db->errorCode());
|
||||
|
||||
if (1 != $db->exec('DELETE FROM test'))
|
||||
if (1 != $db->exec("DELETE FROM {$table}"))
|
||||
printf("[038] No rows deleted, can't be true.\n");
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
require __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_begintransaction');
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
|
||||
@@ -4,7 +4,7 @@ MySQL PDO->exec(), BIT columns - remove after fix!
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (MySQLPDOTest::isPDOMySQLnd())
|
||||
die("skip Known bug - mysqlnd handles BIT incorrectly!");
|
||||
@@ -12,10 +12,9 @@ if (MySQLPDOTest::isPDOMySQLnd())
|
||||
--FILE--
|
||||
<?php
|
||||
/* TODO: remove this test after fix and enable the BIT test in pdo_mysql_types.phpt again */
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function test_type(&$db, $offset, $sql_type, $value, $ret_value = NULL, $pattern = NULL) {
|
||||
|
||||
$sql = sprintf('CREATE TABLE test_mysql_bit(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine());
|
||||
@$db->exec($sql);
|
||||
if ($db->errorCode() != 0) {
|
||||
@@ -49,7 +48,7 @@ if (MySQLPDOTest::isPDOMySQLnd())
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_mysql_bit');
|
||||
?>
|
||||
|
||||
@@ -6,13 +6,13 @@ pdo_mysql
|
||||
<?php
|
||||
if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) {
|
||||
/* Need connection to detect library version */
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
}
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
function get_client_version() {
|
||||
if (extension_loaded('mysqli')) {
|
||||
@@ -24,8 +24,8 @@ if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) {
|
||||
return MySQLPDOTest::getClientVersion(MySQLPDOTest::factory());
|
||||
}
|
||||
|
||||
$expected = array(
|
||||
'MYSQL_ATTR_USE_BUFFERED_QUERY' => true,
|
||||
$expected = [
|
||||
'MYSQL_ATTR_USE_BUFFERED_QUERY' => true,
|
||||
'MYSQL_ATTR_LOCAL_INFILE' => true,
|
||||
'MYSQL_ATTR_DIRECT_QUERY' => true,
|
||||
'MYSQL_ATTR_FOUND_ROWS' => true,
|
||||
@@ -37,8 +37,8 @@ if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) {
|
||||
"MYSQL_ATTR_SSL_CAPATH" => true,
|
||||
"MYSQL_ATTR_SSL_CIPHER" => true,
|
||||
"MYSQL_ATTR_COMPRESS" => true,
|
||||
"MYSQL_ATTR_MULTI_STATEMENTS" => true,
|
||||
);
|
||||
"MYSQL_ATTR_MULTI_STATEMENTS" => true,
|
||||
];
|
||||
|
||||
if (!MySQLPDOTest::isPDOMySQLnd()) {
|
||||
$expected['MYSQL_ATTR_MAX_BUFFER_SIZE'] = true;
|
||||
@@ -71,12 +71,12 @@ if (!extension_loaded('mysqli') && !extension_loaded('mysqlnd')) {
|
||||
*/
|
||||
$ref = new ReflectionClass('PDO');
|
||||
$constants = $ref->getConstants();
|
||||
$values = array();
|
||||
$values = [];
|
||||
|
||||
foreach ($constants as $name => $value)
|
||||
if (substr($name, 0, 11) == 'MYSQL_ATTR_') {
|
||||
if (!isset($values[$value]))
|
||||
$values[$value] = array($name);
|
||||
$values[$value] = [$name];
|
||||
else
|
||||
$values[$value][] = $name;
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ Error during closeCursor() of multi query
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
||||
|
||||
|
||||
@@ -4,26 +4,25 @@ MySQL PDO->commit()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
die("skip Transactional engine not found");
|
||||
?>
|
||||
MySQLPDOTest::skipNotTransactionalEngine();
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
|
||||
$table = 'pdo_mysql_commit';
|
||||
MySQLPDOTest::createTestTable($table, $db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
|
||||
$table2 = 'pdo_mysql_commit_2';
|
||||
try {
|
||||
if (true !== ($tmp = $db->beginTransaction())) {
|
||||
printf("[001] Expecting true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
}
|
||||
|
||||
// DDL will issue an implicit commit
|
||||
$db->exec(sprintf('DROP TABLE IF EXISTS test_commit'));
|
||||
$db->exec(sprintf('CREATE TABLE test_commit(id INT) ENGINE=%s', MySQLPDOTest::detect_transactional_mysql_engine($db)));
|
||||
$db->exec(sprintf('CREATE TABLE %s (id INT) ENGINE=%s', $table2, MySQLPDOTest::detect_transactional_mysql_engine($db)));
|
||||
try {
|
||||
$db->commit();
|
||||
$failed = false;
|
||||
@@ -43,14 +42,14 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
if (true !== ($tmp = $db->beginTransaction()))
|
||||
printf("[004] Expecting true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
|
||||
$db->exec("INSERT INTO test(id, label) VALUES (100, 'z')");
|
||||
$db->exec("INSERT INTO {$table} (id, label) VALUES (100, 'z')");
|
||||
|
||||
if (true !== ($tmp = $db->commit()))
|
||||
printf("[005] No commit allowed? [%s] %s\n",
|
||||
$db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
// a weak test without unicode etc. - lets leave that to dedicated tests
|
||||
$stmt = $db->query('SELECT id, label FROM test WHERE id = 100');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 100");
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) {
|
||||
printf("[006] Record data is strange, dumping rows\n");
|
||||
@@ -60,18 +59,18 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
// Ok, lets check MyISAM resp. any other non-transactional engine
|
||||
// pdo_mysql_begin_transaction has more on this, quick check only
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, 'MyISAM');
|
||||
MySQLPDOTest::createTestTable($table, $db, 'MyISAM');
|
||||
|
||||
if (true !== ($tmp = $db->beginTransaction()))
|
||||
printf("[007] Expecting true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
|
||||
$db->exec("INSERT INTO test(id, label) VALUES (100, 'z')");
|
||||
$db->exec("INSERT INTO {$table} (id, label) VALUES (100, 'z')");
|
||||
if (true !== ($tmp = $db->commit()))
|
||||
printf("[008] No commit allowed? [%s] %s\n",
|
||||
$db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
// a weak test without unicode etc. - lets leave that to dedicated tests
|
||||
$stmt = $db->query('SELECT id, label FROM test WHERE id = 100');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table} WHERE id = 100");
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (!isset($rows[0]['label']) || ($rows[0]['label'] != 'z')) {
|
||||
printf("[009] Record data is strange, dumping rows\n");
|
||||
@@ -88,10 +87,10 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_commit');
|
||||
MySQLPDOTest::dropTestTable($db);
|
||||
$db->exec('DROP TABLE IF EXISTS pdo_mysql_commit');
|
||||
$db->exec('DROP TABLE IF EXISTS pdo_mysql_commit_2');
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,27 +4,26 @@ PDO_MYSQL: check the session_connect_attrs table for connection attributes
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (!MySQLPDOTest::isPDOMySQLnd()) die('skip only for mysqlnd');
|
||||
MySQLPDOTest::skipNotMySQLnd();
|
||||
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
$stmt = $pdo->query("select count(*) from information_schema.tables where table_schema='performance_schema' and table_name='session_connect_attrs'");
|
||||
$stmt = $pdo->query("SELECT COUNT(*) FROM information_schema.tables WHERE table_schema='performance_schema' AND table_name='session_connect_attrs'");
|
||||
if (!$stmt || !$stmt->fetchColumn()) {
|
||||
die("skip mysql does not support session_connect_attrs table yet");
|
||||
}
|
||||
|
||||
$stmt = $pdo->query("show variables like 'performance_schema'");
|
||||
$stmt = $pdo->query("SHOW VARIABLES LIKE 'performance_schema'");
|
||||
if (!$stmt || $stmt->fetchColumn(1) !== 'ON') {
|
||||
die("skip performance_schema is OFF");
|
||||
}
|
||||
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$pdo = MySQLPDOTest::factory();
|
||||
|
||||
if (preg_match('/host=([^;]+)/', PDO_MYSQL_TEST_DSN, $m)) {
|
||||
@@ -33,7 +32,7 @@ if (preg_match('/host=([^;]+)/', PDO_MYSQL_TEST_DSN, $m)) {
|
||||
|
||||
//in case $host is empty, do not test for _server_host field
|
||||
if (isset($host) && $host !== '') {
|
||||
$stmt = $pdo->query("select * from performance_schema.session_connect_attrs where ATTR_NAME='_server_host' and processlist_id = connection_id()");
|
||||
$stmt = $pdo->query("SELECT * FROM performance_schema.session_connect_attrs WHERE ATTR_NAME='_server_host' AND processlist_id = connection_id()");
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
@@ -44,7 +43,7 @@ if (isset($host) && $host !== '') {
|
||||
}
|
||||
}
|
||||
|
||||
$stmt = $pdo->query("select * from performance_schema.session_connect_attrs where ATTR_NAME='_client_name' and processlist_id = connection_id()");
|
||||
$stmt = $pdo->query("SELECT * FROM performance_schema.session_connect_attrs WHERE ATTR_NAME='_client_name' AND processlist_id = connection_id()");
|
||||
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$row || !isset($row['attr_name'])) {
|
||||
@@ -56,4 +55,4 @@ if (!$row || !isset($row['attr_name'])) {
|
||||
printf("done!");
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
done!
|
||||
|
||||
@@ -4,12 +4,12 @@ PDO_MYSQL: Defining a connection charset in the DSN
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
/* Connect to mysql to determine the current charset so we can diffinate it */
|
||||
$link = MySQLPDOTest::factory();
|
||||
@@ -21,7 +21,7 @@ MySQLPDOTest::skip();
|
||||
/* Done with the original connection, create a second link to test the character set being defined */
|
||||
unset($link);
|
||||
|
||||
$link = MySQLPDOTest::factory('PDO', false, null, Array('charset' => $new_charset));
|
||||
$link = MySQLPDOTest::factory('PDO', ['charset' => $new_charset]);
|
||||
$conn_charset = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value;
|
||||
|
||||
if ($charset !== $conn_charset) {
|
||||
|
||||
@@ -4,28 +4,26 @@ MySQL PDO->errorCode()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
|
||||
$table = 'pdo_mysql_errorcode';
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
|
||||
function check_error($offset, &$obj, $expected = '00000') {
|
||||
|
||||
$code = $obj->errorCode();
|
||||
if (($code != $expected) && (($expected != '00000') && ($code != ''))) {
|
||||
printf("[%03d] Expecting error code '%s' got code '%s'\n",
|
||||
$offset, $expected, $code);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
/*
|
||||
If you create a PDOStatement object through PDO->prepare()
|
||||
or PDO->query() and invoke an error on the statement handle,
|
||||
@@ -36,28 +34,28 @@ $db = MySQLPDOTest::factory();
|
||||
$code = $db->errorCode();
|
||||
check_error(2, $db);
|
||||
|
||||
$stmt = $db->query('SELECT id, label FROM test');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table}");
|
||||
$stmt2 = &$stmt;
|
||||
check_error(3, $db);
|
||||
check_error(4, $stmt);
|
||||
|
||||
$db->exec('DROP TABLE IF EXISTS test');
|
||||
$db->exec("DROP TABLE IF EXISTS {$table}");
|
||||
@$stmt->execute();
|
||||
check_error(4, $db);
|
||||
check_error(5, $stmt, '42S02');
|
||||
check_error(6, $stmt2, '42S02');
|
||||
|
||||
$db->exec('DROP TABLE IF EXISTS unknown');
|
||||
@$stmt = $db->query('SELECT id, label FROM unknown');
|
||||
$db->exec('DROP TABLE IF EXISTS pdo_mysql_errorcode_unknown');
|
||||
@$stmt = $db->query('SELECT id, label FROM pdo_mysql_errorcode_unknown');
|
||||
check_error(7, $db, '42S02');
|
||||
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
$stmt = $db->query('SELECT id, label FROM test');
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
$stmt = $db->query("SELECT id, label FROM {$table}");
|
||||
check_error(8, $db);
|
||||
check_error(9, $stmt);
|
||||
|
||||
$db2 = &$db;
|
||||
@$db->query('SELECT id, label FROM unknown');
|
||||
@$db->query('SELECT id, label FROM pdo_mysql_errorcode_unknown');
|
||||
check_error(10, $db, '42S02');
|
||||
check_error(11, $db2, '42S02');
|
||||
check_error(12, $stmt);
|
||||
@@ -80,8 +78,9 @@ $db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_errorcode');
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,15 +4,16 @@ MySQL PDO->errorInfo()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
|
||||
$table = 'pdo_mysql_errorinfo';
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
|
||||
function check_error($offset, &$obj, $expected = '00000') {
|
||||
$info = $obj->errorInfo();
|
||||
@@ -29,13 +30,12 @@ $db = MySQLPDOTest::factory();
|
||||
if (!isset($info[2]) || $info[2] == '')
|
||||
printf("[%03d] Driver-specific error message.not set\n", $offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pdo_mysql_errorinfo($db, $offset) {
|
||||
global $table;
|
||||
|
||||
try {
|
||||
|
||||
/*
|
||||
If you create a PDOStatement object through PDO->prepare()
|
||||
or PDO->query() and invoke an error on the statement handle,
|
||||
@@ -46,12 +46,12 @@ $db = MySQLPDOTest::factory();
|
||||
$code = $db->errorCode();
|
||||
check_error($offset + 2, $db);
|
||||
|
||||
$stmt = $db->query('SELECT id, label FROM test');
|
||||
$stmt = $db->query("SELECT id, label FROM {$table}");
|
||||
$stmt2 = &$stmt;
|
||||
check_error($offset + 3, $db);
|
||||
check_error($offset + 4, $stmt);
|
||||
|
||||
$db->exec('DROP TABLE IF EXISTS test');
|
||||
$db->exec("DROP TABLE IF EXISTS {$table}");
|
||||
@$stmt->execute();
|
||||
check_error($offset + 5, $db);
|
||||
check_error($offset + 6, $stmt, '42S02');
|
||||
@@ -60,14 +60,14 @@ $db = MySQLPDOTest::factory();
|
||||
@$stmt = $db->query('SELECT id, label FROM unknown');
|
||||
check_error($offset + 8, $db, '42S02');
|
||||
|
||||
MySQLPDOTest::createTestTable($db);
|
||||
$stmt = $db->query('SELECT id, label FROM test');
|
||||
MySQLPDOTest::createTestTable($table, $db);
|
||||
$stmt = $db->query("SELECT id, label FROM {$table}");
|
||||
check_error($offset + 9, $db);
|
||||
check_error($offset + 10, $stmt);
|
||||
|
||||
$db2 = &$db;
|
||||
$db->exec('DROP TABLE IF EXISTS unknown');
|
||||
@$db->query('SELECT id, label FROM unknown');
|
||||
$db->exec('DROP TABLE IF EXISTS pdo_mysql_errorinfo_unknown');
|
||||
@$db->query('SELECT id, label FROM pdo_mysql_errorinfo_unknown');
|
||||
check_error($offset + 11, $db, '42S02');
|
||||
check_error($offset + 12, $db2, '42S02');
|
||||
check_error($offset + 13, $stmt);
|
||||
@@ -99,8 +99,9 @@ $db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS pdo_mysql_errorinfo');
|
||||
?>
|
||||
--EXPECT--
|
||||
Emulated Prepared Statements...
|
||||
|
||||
@@ -4,15 +4,13 @@ MySQL PDO->exec(), affected rows
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
function exec_and_count($offset, &$db, $sql, $exp = NULL) {
|
||||
|
||||
try {
|
||||
|
||||
$ret = $db->exec($sql);
|
||||
if (!is_null($exp) && ($ret !== $exp)) {
|
||||
printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n",
|
||||
@@ -20,7 +18,6 @@ MySQLPDOTest::skip();
|
||||
$db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
printf("[%03d] '%s' has failed, [%s] %s\n",
|
||||
$offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
@@ -30,13 +27,13 @@ MySQLPDOTest::skip();
|
||||
return true;
|
||||
}
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
|
||||
$procedure = 'pdo_mysql_exec_p';
|
||||
|
||||
/* affected rows related */
|
||||
try {
|
||||
|
||||
exec_and_count(2, $db, 'DROP TABLE IF EXISTS test_mysql_exec', 0);
|
||||
exec_and_count(3, $db, sprintf('CREATE TABLE test_mysql_exec(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
|
||||
exec_and_count(4, $db, "INSERT INTO test_mysql_exec(id, col1) VALUES (1, 'a')", 1);
|
||||
@@ -59,7 +56,6 @@ MySQLPDOTest::skip();
|
||||
// Results may vary. Typically you will get 1. But the MySQL 5.1 manual states: Truncation operations do not return the number of deleted rows.
|
||||
// Don't rely on any return value!
|
||||
exec_and_count(38, $db, 'TRUNCATE TABLE test_mysql_exec', NULL);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
printf("[001] %s, [%s] %s\n",
|
||||
$e->getMessage(),
|
||||
@@ -72,11 +68,11 @@ MySQLPDOTest::skip();
|
||||
// let's try to play with stored procedures
|
||||
try {
|
||||
$ignore_exception = true;
|
||||
exec_and_count(18, $db, 'DROP PROCEDURE IF EXISTS p', 0);
|
||||
exec_and_count(19, $db, 'CREATE PROCEDURE p(OUT ver_param VARCHAR(255)) BEGIN SELECT VERSION() INTO ver_param; END;', 0);
|
||||
exec_and_count(18, $db, "DROP PROCEDURE IF EXISTS {$procedure}", 0);
|
||||
exec_and_count(19, $db, "CREATE PROCEDURE {$procedure}(OUT ver_param VARCHAR(255)) BEGIN SELECT VERSION() INTO ver_param; END;", 0);
|
||||
// we got this far without problems. If there's an issue from now on, its a failure
|
||||
$ignore_exception = false;
|
||||
exec_and_count(20, $db, 'CALL p(@version)', 1);
|
||||
exec_and_count(20, $db, "CALL {$procedure}(@version)", 1);
|
||||
$stmt = $db->query('SELECT @version AS p_version');
|
||||
$tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($tmp) > 1 || !isset($tmp[0]['p_version'])) {
|
||||
@@ -98,7 +94,7 @@ MySQLPDOTest::skip();
|
||||
$tmp[0]['_version'], gettype($tmp[0]['_version']));
|
||||
}
|
||||
}
|
||||
exec_and_count(25, $db, 'DROP PROCEDURE IF EXISTS p', 0);
|
||||
exec_and_count(25, $db, "DROP PROCEDURE IF EXISTS {$procedure}", 0);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// ignore it, we might not have sufficient permissions
|
||||
@@ -109,13 +105,14 @@ MySQLPDOTest::skip();
|
||||
}
|
||||
|
||||
// stored function
|
||||
$func = 'pdo_mysql_exec_f';
|
||||
try {
|
||||
$ignore_exception = true;
|
||||
exec_and_count(27, $db, 'DROP FUNCTION IF EXISTS f', 0);
|
||||
exec_and_count(28, $db, 'CREATE FUNCTION f( ver_param VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC RETURN ver_param;', 0);
|
||||
exec_and_count(27, $db, "DROP FUNCTION IF EXISTS {$func}", 0);
|
||||
exec_and_count(28, $db, "CREATE FUNCTION {$func}( ver_param VARCHAR(255)) RETURNS VARCHAR(255) DETERMINISTIC RETURN ver_param;", 0);
|
||||
// we got this far without problems. If there's an issue from now on, its a failure
|
||||
$ignore_exception = false;
|
||||
$stmt = $db->query('SELECT f(VERSION()) AS f_version');
|
||||
$stmt = $db->query("SELECT {$func}(VERSION()) AS f_version");
|
||||
$tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (count($tmp) > 1 || !isset($tmp[0]['f_version'])) {
|
||||
printf("[029] Data seems wrong, dumping\n");
|
||||
@@ -135,7 +132,7 @@ MySQLPDOTest::skip();
|
||||
$tmp[0]['_version'], gettype($tmp[0]['_version']));
|
||||
}
|
||||
}
|
||||
exec_and_count(32, $db, 'DROP FUNCTION IF EXISTS f', 0);
|
||||
exec_and_count(32, $db, "DROP FUNCTION IF EXISTS {$func}", 0);
|
||||
|
||||
} catch (PDOException $e) {
|
||||
// ignore it, we might not have sufficient permissions
|
||||
@@ -148,11 +145,10 @@ MySQLPDOTest::skip();
|
||||
|
||||
// multi query
|
||||
try {
|
||||
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
|
||||
$exp = 0;
|
||||
|
||||
$tmp = @$db->exec(sprintf('DROP TABLE IF EXISTS test_mysql_exec; CREATE TABLE test_mysql_exec(id INT) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
|
||||
$tmp = $db->exec(sprintf('DROP TABLE IF EXISTS test_mysql_exec; CREATE TABLE test_mysql_exec(id INT) ENGINE=%s', PDO_MYSQL_TEST_ENGINE));
|
||||
if ($exp !== $tmp)
|
||||
printf("[034] Expecting %s/%s got %s/%s, [%s] %s\n",
|
||||
$exp, gettype($exp),
|
||||
@@ -160,10 +156,8 @@ MySQLPDOTest::skip();
|
||||
$db->errorCode(), var_export($db->errorInfo(), true));
|
||||
|
||||
// this is interesting: if we get sort of affected rows, what will happen now?
|
||||
$tmp = @$db->exec('INSERT INTO test_mysql_exec(id) VALUES (1); INSERT INTO test_mysql_exec(id) VALUES (2)');
|
||||
$tmp = $db->exec('INSERT INTO test_mysql_exec(id) VALUES (1); INSERT INTO test_mysql_exec(id) VALUES (2)');
|
||||
printf("[035] With emulated PS it works but makes no sense given that exec() returns sort of affected rows...\n");
|
||||
|
||||
|
||||
} catch (PDOException $e) {
|
||||
printf("[033] %s, [%s] %s\n",
|
||||
$e->getMessage(),
|
||||
@@ -175,8 +169,11 @@ MySQLPDOTest::skip();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable(NULL, 'test_mysql_exec');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS test_mysql_exec');
|
||||
$db->query('DROP PROCEDURE IF EXISTS pdo_mysql_exec_p');
|
||||
$db->query('DROP FUNCTION IF EXISTS pdo_mysql_exec_f');
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: PDO::exec(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'THIS IS NOT VALID SQL, I HOPE' at line 1 in %s on line %d
|
||||
|
||||
@@ -4,15 +4,13 @@ MySQL PDO->exec(), affected rows
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
function exec_and_count($offset, &$db, $sql, $exp, $suppress_warning = false) {
|
||||
|
||||
try {
|
||||
|
||||
if ($suppress_warning)
|
||||
$ret = @$db->exec($sql);
|
||||
else
|
||||
@@ -34,29 +32,27 @@ MySQLPDOTest::skip();
|
||||
return true;
|
||||
}
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
|
||||
$db_name = 'pdo_mysql_exec_ddl_db';
|
||||
$db_name_2 = 'pdo_mysql_exec_ddl_db_2';
|
||||
$table = 'pdo_mysql_exec_ddl';
|
||||
$table2 = 'pdo_mysql_exec_ddl_2';
|
||||
/* affected rows related */
|
||||
try {
|
||||
|
||||
@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl');
|
||||
@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2');
|
||||
if (1 === @$db->exec('CREATE DATABASE pdo_exec_ddl')) {
|
||||
if (1 === @$db->exec("CREATE DATABASE {$db_name}")) {
|
||||
// yippie - we can create databases etc.
|
||||
exec_and_count(3, $db, 'ALTER DATABASE pdo_exec_ddl CHARACTER SET latin1', 1);
|
||||
exec_and_count(3, $db, "ALTER DATABASE {$db_name} CHARACTER SET latin1", 1);
|
||||
}
|
||||
|
||||
exec_and_count(4, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl', 0);
|
||||
exec_and_count(5, $db, 'DROP TABLE IF EXISTS pdo_exec_ddl2', 0);
|
||||
if (0 === $db->exec('CREATE TABLE pdo_exec_ddl(id INT, col1 CHAR(2))')) {
|
||||
exec_and_count(5, $db, 'CREATE INDEX idx1 ON pdo_exec_ddl(id)', 0);
|
||||
exec_and_count(6, $db, 'DROP INDEX idx1 ON pdo_exec_ddl', 0);
|
||||
exec_and_count(7, $db, 'ALTER TABLE pdo_exec_ddl DROP id', 0);
|
||||
exec_and_count(8, $db, 'ALTER TABLE pdo_exec_ddl ADD id INT', 0);
|
||||
exec_and_count(9, $db, 'ALTER TABLE pdo_exec_ddl ALTER id SET DEFAULT 1', 0);
|
||||
exec_and_count(10, $db, 'RENAME TABLE pdo_exec_ddl TO pdo_exec_ddl2', 0);
|
||||
if (0 === $db->exec("CREATE TABLE {$table} (id INT, col1 CHAR(2))")) {
|
||||
exec_and_count(5, $db, "CREATE INDEX idx1 ON {$table} (id)", 0);
|
||||
exec_and_count(6, $db, "DROP INDEX idx1 ON {$table}", 0);
|
||||
exec_and_count(7, $db, "ALTER TABLE {$table} DROP id", 0);
|
||||
exec_and_count(8, $db, "ALTER TABLE {$table} ADD id INT", 0);
|
||||
exec_and_count(9, $db, "ALTER TABLE {$table} ALTER id SET DEFAULT 1", 0);
|
||||
exec_and_count(10, $db, "RENAME TABLE {$table} TO {$table2}", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -81,14 +77,12 @@ MySQLPDOTest::skip();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::dropTestTable($db);
|
||||
// clean up
|
||||
@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl');
|
||||
@$db->exec('DROP TABLE IF EXISTS pdo_exec_ddl2');
|
||||
@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl');
|
||||
@$db->exec('DROP DATABASE IF EXISTS pdo_exec_ddl2');
|
||||
$db->exec('DROP TABLE IF EXISTS pdo_mysql_exec_ddl');
|
||||
$db->exec('DROP TABLE IF EXISTS pdo_mysql_exec_ddl_2');
|
||||
$db->exec('DROP DATABASE IF EXISTS pdo_mysql_exec_ddl_db');
|
||||
$db->exec('DROP DATABASE IF EXISTS pdo_mysql_exec_ddl_db_2');
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,7 +4,7 @@ MySQL PDO->exec(), affected rows
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
|
||||
// Run test only locally - not against remote hosts
|
||||
@@ -27,86 +27,79 @@ if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) {
|
||||
if (file_exists($filename) && !is_writable($filename))
|
||||
die("skip {$filename} not writable");
|
||||
}
|
||||
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
function exec_and_count($offset, &$db, $sql, $exp) {
|
||||
|
||||
try {
|
||||
|
||||
$ret = $db->exec($sql);
|
||||
if ($ret !== $exp) {
|
||||
printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n",
|
||||
$offset, $exp, gettype($exp), $ret, gettype($ret), $sql,
|
||||
$db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
||||
if (42000 == $db->errorCode()) {
|
||||
// Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND)
|
||||
// Load data infile not allowed
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("[%03d] '%s' has failed, [%s] %s\n",
|
||||
$offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
function exec_and_count($offset, &$db, $sql, $exp) {
|
||||
try {
|
||||
$ret = $db->exec($sql);
|
||||
if ($ret !== $exp) {
|
||||
printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n",
|
||||
$offset, $exp, gettype($exp), $ret, gettype($ret), $sql,
|
||||
$db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
return false;
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
if (42000 == $db->errorCode()) {
|
||||
// Error: 1148 SQLSTATE: 42000 (ER_NOT_ALLOWED_COMMAND)
|
||||
// Load data infile not allowed
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
printf("[%03d] '%s' has failed, [%s] %s\n",
|
||||
$offset, $sql, $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
putenv('PDOTEST_ATTR='.serialize([PDO::MYSQL_ATTR_LOCAL_INFILE=>true]));
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* affected rows related */
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factoryWithAttr([PDO::MYSQL_ATTR_LOCAL_INFILE=>true]);
|
||||
|
||||
exec_and_count(3, $db, sprintf('CREATE TABLE test_mysql_exec_load_data(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
|
||||
/* affected rows related */
|
||||
|
||||
$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
|
||||
if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) {
|
||||
$filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
|
||||
} else {
|
||||
$filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
|
||||
}
|
||||
exec_and_count(3, $db, sprintf('CREATE TABLE test_mysql_exec_load_data(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
|
||||
|
||||
$fp = fopen($filename, "w");
|
||||
fwrite($fp, "1;foo\n");
|
||||
fwrite($fp, "2;bar");
|
||||
fclose($fp);
|
||||
$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
|
||||
if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] != '')) {
|
||||
$filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
|
||||
} else {
|
||||
$filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
|
||||
}
|
||||
|
||||
$sql = sprintf("LOAD DATA LOCAL INFILE %s INTO TABLE test_mysql_exec_load_data FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename));
|
||||
$fp = fopen($filename, "w");
|
||||
fwrite($fp, "1;foo\n");
|
||||
fwrite($fp, "2;bar");
|
||||
fclose($fp);
|
||||
|
||||
if (exec_and_count(4, $db, $sql, 2)) {
|
||||
$sql = sprintf("LOAD DATA LOCAL INFILE %s INTO TABLE test_mysql_exec_load_data FIELDS TERMINATED BY ';' LINES TERMINATED BY '\n'", $db->quote($filename));
|
||||
|
||||
$stmt = $db->query('SELECT id, col1 FROM test_mysql_exec_load_data ORDER BY id ASC');
|
||||
$expected = array(array("id" => 1, "col1" => "foo"), array("id" => 2, "col1" => "bar"));
|
||||
$ret = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($expected as $offset => $exp) {
|
||||
foreach ($exp as $key => $value) {
|
||||
if ($ret[$offset][$key] != $value) {
|
||||
printf("Results seem wrong, check manually\n");
|
||||
var_dump($ret);
|
||||
var_dump($expected);
|
||||
break 2;
|
||||
}
|
||||
if (exec_and_count(4, $db, $sql, 2)) {
|
||||
$stmt = $db->query('SELECT id, col1 FROM test_mysql_exec_load_data ORDER BY id ASC');
|
||||
$expected = array(array("id" => 1, "col1" => "foo"), array("id" => 2, "col1" => "bar"));
|
||||
$ret = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
foreach ($expected as $offset => $exp) {
|
||||
foreach ($exp as $key => $value) {
|
||||
if ($ret[$offset][$key] != $value) {
|
||||
printf("Results seem wrong, check manually\n");
|
||||
var_dump($ret);
|
||||
var_dump($expected);
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unlink($filename);
|
||||
unlink($filename);
|
||||
|
||||
print "done!";
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::factory(NULL, 'test_mysql_exec_load_data');
|
||||
require __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS test_mysql_exec_load_data');
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,15 +4,13 @@ MySQL PDO->exec(), SELECT
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
function exec_and_count($offset, &$db, $sql, $exp) {
|
||||
|
||||
try {
|
||||
|
||||
$ret = $db->exec($sql);
|
||||
if ($ret !== $exp) {
|
||||
printf("[%03d] Expecting '%s'/%s got '%s'/%s when running '%s', [%s] %s\n",
|
||||
@@ -30,9 +28,8 @@ MySQLPDOTest::skip();
|
||||
return true;
|
||||
}
|
||||
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
|
||||
/* affected rows related */
|
||||
try {
|
||||
@@ -55,8 +52,9 @@ MySQLPDOTest::skip();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable(NULL, 'test_mysql_exec_select');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->query('DROP TABLE IF EXISTS test_mysql_exec_select');
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: PDO::exec(): SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute. in %s on line %d
|
||||
|
||||
@@ -4,17 +4,15 @@ MySQL PDOStatement->fetch()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
function fetch($offset, &$db, $query, $expect = null) {
|
||||
|
||||
try {
|
||||
$stmt = $db->query('SELECT 1');
|
||||
$num = $stmt->fetch(PDO::FETCH_NUM);
|
||||
@@ -37,21 +35,15 @@ $db = MySQLPDOTest::factory();
|
||||
var_dump($expect);
|
||||
var_dump($both);
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
|
||||
printf("[%03d] %s, [%s] %s\n",
|
||||
$offset,
|
||||
$e->getMessage(), $db->errroCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
fetch(2, $db, 'SELECT 1', array(0 => '1', '1' => '1'));
|
||||
|
||||
} catch (PDOException $e) {
|
||||
printf("[001] %s [%s] %s\n",
|
||||
$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
|
||||
|
||||
@@ -4,23 +4,17 @@ MySQL PDO->getAttribute()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
die("skip Transactional engine not found");
|
||||
?>
|
||||
MySQLPDOTest::skipNotTransactionalEngine();
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
|
||||
|
||||
function set_and_get($offset, $db, $attribute, $value) {
|
||||
|
||||
$value_type = gettype($value);
|
||||
try {
|
||||
|
||||
if (!$db->setAttribute($attribute, $value)) {
|
||||
printf("[%03d] Cannot set attribute '%s' to value '%s'\n",
|
||||
$offset, $attribute, var_export($tmp, true));
|
||||
@@ -39,7 +33,6 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
$offset, $attribute, var_export($value, true), gettype($value), var_export($tmp, true), gettype($tmp));
|
||||
return false;
|
||||
}
|
||||
|
||||
} catch (PDOException $e) {
|
||||
printf("[%03d] %s, [%s] %s\n",
|
||||
$offset, $e->getMessage(),
|
||||
@@ -51,7 +44,7 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
}
|
||||
|
||||
set_and_get(1, $db, PDO::ATTR_AUTOCOMMIT, 1);
|
||||
/*
|
||||
/*
|
||||
set_and_get(2, $db, PDO::ATTR_AUTOCOMMIT, 0);
|
||||
set_and_get(3, $db, PDO::ATTR_AUTOCOMMIT, -1);
|
||||
$obj = new stdClass();
|
||||
@@ -66,34 +59,28 @@ if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
set_and_get(9, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, '');
|
||||
set_and_get(10, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, 'SOME SQL');
|
||||
set_and_get(11, $db, PPDO::MYSQL_ATTR_INIT_COMMAND, -1);
|
||||
|
||||
*/
|
||||
/*
|
||||
PDO::MYSQL_ATTR_READ_DEFAULT_FILE (integer)
|
||||
*/
|
||||
/*
|
||||
PDO::MYSQL_ATTR_READ_DEFAULT_FILE (integer)
|
||||
|
||||
Read options from the named option file instead of from my.cnf.
|
||||
PDO::MYSQL_ATTR_READ_DEFAULT_GROUP (integer)
|
||||
PDO::MYSQL_ATTR_READ_DEFAULT_GROUP (integer)
|
||||
|
||||
Read options from the named group from my.cnf or the file specified with MYSQL_READ_DEFAULT_FILE.
|
||||
PDO::MYSQL_ATTR_MAX_BUFFER_SIZE (integer)
|
||||
PDO::MYSQL_ATTR_MAX_BUFFER_SIZE (integer)
|
||||
|
||||
Maximum buffer size. Defaults to 1 MiB.
|
||||
PDO::MYSQL_ATTR_DIRECT_QUERY (integer)
|
||||
PDO::MYSQL_ATTR_DIRECT_QUERY (integer)
|
||||
|
||||
Perform direct queries, don't use prepared statements.
|
||||
*/
|
||||
/*
|
||||
TODO - read only
|
||||
PDO::ATTR_CONNECTION_STATUS
|
||||
PDO::ATTR_SERVER_INFO
|
||||
*/
|
||||
*/
|
||||
/*
|
||||
TODO - read only
|
||||
PDO::ATTR_CONNECTION_STATUS
|
||||
PDO::ATTR_SERVER_INFO
|
||||
*/
|
||||
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable();
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,12 +4,12 @@ MySQL PDO class inTransaction
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
const BEGIN = ['BEGIN', 'START TRANSACTION'];
|
||||
const END = ['COMMIT', 'ROLLBACK'];
|
||||
@@ -62,7 +62,7 @@ echo "\n";
|
||||
// DDL query causes an implicit commit.
|
||||
$db->beginTransaction();
|
||||
var_dump($db->inTransaction());
|
||||
$db->exec('DROP TABLE IF EXISTS test');
|
||||
$db->exec('DROP TABLE IF EXISTS pdo_mysql_inTransaction');
|
||||
var_dump($db->inTransaction());
|
||||
|
||||
// We should be able to start a new transaction after the implicit commit.
|
||||
|
||||
@@ -4,34 +4,31 @@ MySQL PDO class interface
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
if (false == MySQLPDOTest::detect_transactional_mysql_engine($db))
|
||||
die("skip Transactional engine not found");
|
||||
?>
|
||||
MySQLPDOTest::skipNotTransactionalEngine();
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
$expected = array(
|
||||
'__construct' => true,
|
||||
$expected = [
|
||||
'__construct' => true,
|
||||
'prepare' => true,
|
||||
'beginTransaction' => true,
|
||||
'beginTransaction' => true,
|
||||
'commit' => true,
|
||||
'rollBack' => true,
|
||||
'setAttribute' => true,
|
||||
'setAttribute' => true,
|
||||
'exec' => true,
|
||||
'query' => true,
|
||||
'lastInsertId' => true,
|
||||
'lastInsertId' => true,
|
||||
'errorCode' => true,
|
||||
'errorInfo' => true,
|
||||
'getAttribute' => true,
|
||||
'getAttribute' => true,
|
||||
'quote' => true,
|
||||
'inTransaction' => true,
|
||||
'getAvailableDrivers' => true,
|
||||
);
|
||||
'inTransaction' => true,
|
||||
'getAvailableDrivers' => true,
|
||||
];
|
||||
$classname = get_class($db);
|
||||
|
||||
$methods = get_class_methods($classname);
|
||||
|
||||
@@ -4,13 +4,12 @@ MySQL PDO->lastInsertId()
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
$db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
|
||||
try {
|
||||
@@ -59,7 +58,7 @@ $db = MySQLPDOTest::factory();
|
||||
if ($next_id <= 101)
|
||||
printf("[009] Expecting at least 102, got %d\n",$next_id);
|
||||
|
||||
$stmt = $db->query('SELECT LAST_INSERT_ID() as _last_id');
|
||||
$stmt = $db->query('SELECT LAST_INSERT_ID() AS _last_id');
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$last_id = $row['_last_id'];
|
||||
if ($next_id != $last_id) {
|
||||
@@ -87,7 +86,7 @@ $db = MySQLPDOTest::factory();
|
||||
$inc = 1;
|
||||
}
|
||||
|
||||
$stmt = $db->query('SELECT LAST_INSERT_ID() as _last_id');
|
||||
$stmt = $db->query('SELECT LAST_INSERT_ID() AS _last_id');
|
||||
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$last_id = $row['_last_id'];
|
||||
|
||||
@@ -112,8 +111,9 @@ $db = MySQLPDOTest::factory();
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require __DIR__ . '/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::dropTestTable(NULL, 'test_pdo_mysql_last_insert_id');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
$db = MySQLPDOTest::factory();
|
||||
$db->exec('DROP TABLE IF EXISTS test_pdo_mysql_last_insert_id');
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
||||
|
||||
@@ -4,7 +4,7 @@ ensure default for local infile is off
|
||||
pdo_mysql
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
MySQLPDOTest::skip();
|
||||
if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) {
|
||||
die("skip No MYSQL_ATTR_LOCAL_INFILE_DIRECTORY support");
|
||||
@@ -12,8 +12,7 @@ if (!defined('PDO::MYSQL_ATTR_LOCAL_INFILE_DIRECTORY')) {
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'config.inc');
|
||||
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
|
||||
require_once __DIR__ . '/inc/mysql_pdo_test.inc';
|
||||
|
||||
$dsn = MySQLPDOTest::getDSN();
|
||||
$user = PDO_MYSQL_TEST_USER;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user