migrate_example_oracle.module

Tracking 7.x-2.x branch
  1. drupal
    1. 6 contributions/migrate/migrate_example/migrate_example_oracle/migrate_example_oracle.module
    2. 7 contributions/migrate/migrate_example/migrate_example_oracle/migrate_example_oracle.module

Functions & methods

NameDescription
migrate_example_oracle_generateGenerate a text string of reproducible contents for a given length.
migrate_example_oracle_sample_dataReturn an array of data rows for testing Oracle import. Note that 4000 is a magic number for Oracle LOB datatypes, so we testing lengths above and below that limit.

File

View source
  1. <?php
  2. include_once('migrate_example_oracle.features.inc');
  3. /**
  4. * Generate a text string of reproducible contents for a given length.
  5. *
  6. * @param int $length
  7. * Number of characters to generate.
  8. *
  9. * $return
  10. * String of the given length.
  11. */
  12. function migrate_example_oracle_generate($length) {
  13. $base = 'word '; // Five characters long
  14. $multiplier = ($length / 5) + 1; // 80% chance of going a bit long, thus substr below
  15. $data = str_repeat($base, $multiplier);
  16. $data = substr($data, 0, $length);
  17. return $data;
  18. }
  19. /**
  20. * Return an array of data rows for testing Oracle import. Note that 4000 is a magic
  21. * number for Oracle LOB datatypes, so we testing lengths above and below that limit.
  22. */
  23. function migrate_example_oracle_sample_data() {
  24. $image = file_get_contents('misc/druplicon.png');
  25. return array(
  26. array('oid' => 3, 'title' => 'Sample title', 'body' => 'Sample body',
  27. 'mainimage' => $image, 'created' => '2011/05/01 01:02:03',
  28. 'updated' => '2011/06/30 04:05:06'),
  29. array('oid' => 5, 'title' => 'Another title', 'body' => migrate_example_oracle_generate(3900),
  30. 'mainimage' => $image, 'created' => '2011/08/12 07:08:09',
  31. 'updated' => '2011/12/25 10:11:12'),
  32. array('oid' => 7, 'title' => 'Yet another title', 'body' => migrate_example_oracle_generate(4500),
  33. 'mainimage' => $image, 'created' => '2012/01/01 13:14:15',
  34. 'updated' => '2012/03/14 16:17:18'),
  35. );
  36. }