Commit 0af8b665 authored by guilhermeblanco's avatar guilhermeblanco

[2.0][DDC-389] Fixed the PHPDriver that was causing a fatal error when classes...

[2.0][DDC-389] Fixed the PHPDriver that was causing a fatal error when classes uses inheritance type join. Thanks Tiago Ferreira for report and patch.
parent 3eff1d1c
...@@ -99,7 +99,60 @@ class RunSqlTask extends AbstractTask ...@@ -99,7 +99,60 @@ class RunSqlTask extends AbstractTask
$arguments = $this->getArguments(); $arguments = $this->getArguments();
if (isset($arguments['file'])) { if (isset($arguments['file'])) {
//TODO $em = $this->getConfiguration()->getAttribute('em');
$conn = $em->getConnection();
$printer = $this->getPrinter();
$fileNames = (array) $arguments['file'];
foreach ($fileNames as $fileName) {
if ( ! file_exists($fileName)) {
throw new CliException(sprintf('The SQL file [%s] does not exist.', $fileName));
} else if ( ! is_readable($fileName)) {
throw new CliException(sprintf('The SQL file [%s] does not have read permissions.', $fileName));
}
$printer->write('Processing file [' . $fileName . ']... ');
$sql = file_get_contents($fileName);
if ($conn instanceof \Doctrine\DBAL\Driver\PDOConnection) {
// PDO Drivers
try {
$lines = 0;
$stmt = $conn->prepare($sql);
$stmt->execute();
do {
// Required due to "MySQL has gone away!" issue
$stmt->fetch();
$stmt->closeCursor();
$lines++;
} while ($stmt->nextRowset());
$printer->writeln(sprintf('%d statements executed!', $lines));
} catch (\PDOException $e) {
$printer->writeln('error!')
->writeln($e->getMessage());
}
} else {
// Non-PDO Drivers (ie. OCI8 driver)
$stmt = $conn->prepare($sql);
$rs = $stmt->execute();
if ($rs) {
$printer->writeln('OK!');
} else {
$error = $stmt->errorInfo();
$printer->writeln('error!')
->writeln($error['message']);
}
$stmt->closeCursor();
}
}
} else if (isset($arguments['sql'])) { } else if (isset($arguments['sql'])) {
$em = $this->getConfiguration()->getAttribute('em'); $em = $this->getConfiguration()->getAttribute('em');
......
...@@ -121,7 +121,7 @@ class PhpDriver implements Driver ...@@ -121,7 +121,7 @@ class PhpDriver implements Driver
{ {
$path = $this->_classPaths[$className]; $path = $this->_classPaths[$className];
include $path; require_once $path;
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment