You are here

public function MigrateSourceDB2::computeCount in Migrate 7.2

Return a count of all available source records.

File

plugins/sources/db2.inc, line 116
Define a MigrateSource class for importing from IBM DB2 databases.

Class

MigrateSourceDB2
Implementation of MigrateSource, to handle imports from remote DB2 servers.

Code

public function computeCount() {
  migrate_instrument_start('MigrateSourceDB2 count');

  // Make sure we're connected.
  if ($this
    ->connect()) {

    // Execute the count query.
    $stmt = db2_exec($this->connection, $this->countQuery);

    // If something went wrong, throw an exception with the error message.
    if (!$stmt) {
      $e = db2_stmt_errormsg($stmt);
      throw new Exception($e);
    }

    // Grab the first row as an array.
    $count_array = db2_fetch_array($stmt);

    // The first item in this array will be our count.
    $count = reset($count_array);
  }
  else {

    // Connection failed.
    $count = FALSE;
  }
  migrate_instrument_stop('MigrateSourceDB2 count');
  return $count;
}