Skip to content

@dpb587 /DBAL202.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
<?php
##
# http://www.doctrine-project.org/jira/browse/DBAL-202
# Scenario where PDO and DBAL behavior differ
#
# pdo: 0
# dbal: 1
##
require_once __DIR__ . '/tests/Doctrine/Tests/TestInit.php';
error_reporting(-1);
$ref = array(
'dbname' => null,
'dbuser' => null,
'dbpass' => null,
'setup' => 'CREATE TABLE TABLE1 ( COLUMN1 NUMBER )',
'cleanup' => 'DROP TABLE TABLE1',
'dml' => 'INSERT INTO TABLE1 VALUES ( :value )',
'test' => 'SELECT COUNT(1) FROM TABLE1',
);
// pdo
$dbh = new PDO('oci:dbname=' . $ref['dbname'], $ref['dbuser'], $ref['dbpass']);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->exec($ref['setup']);
$stmt = $dbh->prepare($ref['dml']);
$dbh->beginTransaction();
$stmt->execute(array('value' => 1234));
$dbh->rollBack();
fwrite(STDOUT, 'pdo: ' . $dbh->query($ref['test'])->fetchColumn() . "\n");
$dbh->exec($ref['cleanup']);
unset($stmt, $dbh);
// dbal
$dbh = \Doctrine\DBAL\DriverManager::getConnection(array('driver' => 'oci8',
'user' => $ref['dbuser'], 'password' => $ref['dbpass'], 'dbname' => $ref['dbname']
));
$dbh->executeQuery($ref['setup']);
$stmt = $dbh->prepare($ref['dml']);
$dbh->beginTransaction();
$stmt->execute(array('value' => 1234));
$dbh->rollback();
fwrite(STDOUT, 'dbal: ' . $dbh->query($ref['test'])->fetchColumn() . "\n");
$dbh->exec($ref['cleanup']);
unset($stmt, $dbh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.