You are here

public function MySQLiSource::importFromFile in Backup and Migrate 8.4

Import to this source from the given backup file. This is the main restore function for this source.

Parameters

\BackupMigrate\Core\File\BackupFileReadableInterface $file: The file to read the backup from. It will not be opened for reading

Return value

bool|int

Overrides SourceInterface::importFromFile

1 method overrides MySQLiSource::importFromFile()
DrupalMySQLiSource::importFromFile in src/Source/DrupalMySQLiSource.php
Import to this source from the given backup file. This is the main restore function for this source.

File

lib/backup_migrate_core/src/Source/MySQLiSource.php, line 88

Class

MySQLiSource
Class MySQLiSource.

Namespace

BackupMigrate\Core\Source

Code

public function importFromFile(BackupFileReadableInterface $file) {
  $num = 0;
  if ($conn = $this
    ->_getConnection()) {

    // Open (or rewind) the file.
    $file
      ->openForRead();

    // Read one line at a time and run the query.
    while ($line = $this
      ->_readSQLCommand($file)) {

      //        if (_backup_migrate_check_timeout()) {
      //          return FALSE;
      //        }
      if ($line) {

        // Execute the sql query from the file.
        $conn
          ->query($line);
        $num++;
      }
    }

    // Close the file, we're done reading it.
    $file
      ->close();
  }
  return $num;
}