Created
April 28, 2012 02:09
-
-
Save dpb587/2515100 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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