1
0
mirror of https://github.com/dg/dibi.git synced 2025-08-04 21:28:02 +02:00

DibiConnection::loadFile() supports DELIMITER [Closes #119]

This commit is contained in:
David Grudl
2014-02-04 03:05:41 +01:00
parent 2769f1ae0a
commit 738c0c91ed

View File

@@ -641,14 +641,21 @@ class DibiConnection extends DibiObject
}
$count = 0;
$delimiter = ';';
$sql = '';
while (!feof($handle)) {
$s = fgets($handle);
$sql .= $s;
if (substr(rtrim($s), -1) === ';') {
$s = rtrim(fgets($handle));
if (substr($s, 0, 10) === 'DELIMITER ') {
$delimiter = substr($s, 10);
} elseif (substr($s, -strlen($delimiter)) === $delimiter) {
$sql .= substr($s, 0, -strlen($delimiter));
$this->driver->query($sql);
$sql = '';
$count++;
} else {
$sql .= $s . "\n";
}
}
if (trim($sql) !== '') {