}
         MatrixDAL::execPdoQuery($prepared_sql);
         $trans_count++;
         if ($trans_count % 10000 == 0) {
             MatrixDAL::commit();
             MatrixDAL::beginTransaction();
             $trans_count = 0;
         }
     }
     printName('Inserting Data (' . number_format($start) . ' - ' . number_format($start + $count) . ' rows)');
     printUpdateStatus('OK', "\r");
     MatrixDAL::commit();
     /**
      * Switch to the source db connector to get the data..
      */
     MatrixDAL::changeDb($source_db);
     /**
      * we got less than the limit?
      * no point hitting the db again, we won't get anything.
      */
     if (count($source_data) < $num_to_fetch) {
         break;
     }
     $start += $num_to_fetch;
     $fetch_source_sql = db_extras_modify_limit_clause($source_sql, $source_dsn['type'], $num_to_fetch, $start);
     $source_data = MatrixDAL::executeSqlAll($fetch_source_sql);
     $count = count($source_data);
 }
 printUpdateStatus(null, "\n");
 /**
  * switch back to the dest db
 /**
  * Connects to the host/database.
  *
  * @param string $conn_string Squiz Matrix system root.
  *
  * @return boolean true on success, false on failure
  */
 public function connect($conn_string)
 {
     $SYSTEM_ROOT = $conn_string;
     if (empty($SYSTEM_ROOT) || !is_dir($SYSTEM_ROOT)) {
         echo "You need to supply the path to the System Root as the first argument\n";
         exit(1);
     }
     require_once $SYSTEM_ROOT . '/fudge/dev/dev.inc';
     require_once $SYSTEM_ROOT . '/core/include/general.inc';
     require_once $SYSTEM_ROOT . '/core/lib/DAL/DAL.inc';
     require_once $SYSTEM_ROOT . '/core/lib/MatrixDAL/MatrixDAL.inc';
     require_once $SYSTEM_ROOT . '/data/private/conf/db.inc';
     $this->_dsn = $db_conf['db2'];
     $this->_db_type = $db_conf['db2']['type'];
     // Attempt to connect
     MatrixDAL::dbConnect($this->_dsn, $this->_db_type);
     MatrixDAL::changeDb($this->_db_type);
     // Matrix will throw a FATAL error if it can't connect, so if we got here
     // we're all good
     return true;
 }
}
require_once $SYSTEM_ROOT . '/data/private/conf/db.inc';
require_once $SYSTEM_ROOT . '/core/include/init.inc';
require_once $SYSTEM_ROOT . '/core/lib/DAL/DAL.inc';
require_once $SYSTEM_ROOT . '/core/lib/MatrixDAL/MatrixDAL.inc';
$db_error = false;
try {
    $db_connection = MatrixDAL::dbConnect($db_conf['db']);
} catch (Exception $e) {
    echo "Unable to connect to the db: " . $e->getMessage() . "\n";
    $db_error = true;
}
if ($db_error) {
    exit;
}
MatrixDAL::changeDb('db');
/**
 * A couple of indexes for postgres do some automatic casting
 * - sq_ast_attr_val_concat
 * - sq_rb_ast_attr_val_concat
 *
 * Postgres does this automatically.
 *
 * It changes this:
 * ((assetid || '~' || attrid));
 * to
 * ((((assetid)::text||'~'::text)||attrid))
 *
 * So just skip checking those definitions.
 */
$skip_definition_checks = array('sq_ast_attr_val_concat', 'sq_rb_ast_attr_val_concat');