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:
@@ -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) !== '') {
|
||||
|
Reference in New Issue
Block a user