View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
BBC (British Broadcasting Corporation) > Pinwheel > Pinwheel::Fixtures



Annotate this POD


New  2
Open  0
View/Report Bugs




    use Pinwheel::Fixtures;
    fixtures('episodes', 'brands', 'series', 'networks');

The episodes.yml file might resemble:

      id: 1
      name: When Frogs Go Berserk
      short_description: This is the short description
      long_description: This is the long description of the episode
      pid: pid001
      series_id: 1
      position: 1


Pinwheel::Fixtures provides a mechanism for loading YAML files into the database. Database access is via the Pinwheel::Database module.

The convention is the same as in Rails: the name of the YAML file is the name of the database table. The first element in the YAML is an identifier for the tuple. Each item for the tuple should be a row in the database using its field name.



TODO, properly document me.

This method is called to import the fixture data for the database tables specified as a list of fieldnames.

scenario(NAME, OPTIONS)

TODO, properly document me.

Import a collection of fixtures in one go. If called with an OPTIONS value of root => 0 then fixtures at the root of the fixture directory are ignored.

$int = identify($string)

Hashes $string to some integer. This can be used to automatically pick IDs that would normally be generated automatically by the database.


Empties all the tables in the database. (Specifically, uses DELETE to do so).

insert_fixtures($fixtures, $table)

Loads the data given by $fixtures into the given database $table.

Enumerates the columns in the given $table. Columns named (created|updated)_(at|on) are assigned a default of the current time. Any integer columns named like *_id are deemed to be foreign keys.

For each $label, $row in %$fixtures (where $row is a hash ref of column name / value pairs):

  • If the table has an 'id' column and there is no 'id' entry in $row, the id is filled in using identify($label).
  • For each column identified as a foreign key, if the value in $row is present but contains any non-digit characters, then the value is replaced by identify($value).
  • The row is then written to the database (using REPLACE INTO).


Exported by default: fixtures scenario identify

May be exported: insert_fixtures empty_tables


The documentation doesn't describe how the fixtures are loaded, and how 'helpers' are used. The synopsis mentions "the episodes.yaml" file, without first mentioning that YAML is even used.


A&M Network Publishing <>

syntax highlighting: