<<

NAME

MT::PluginData - Arbitrary data storage for Movable Type plugins

SYNOPSIS

    use MT::PluginData;
    my $data = MT::PluginData->new;
    $data->plugin('my-plugin');
    $data->key('unique-key');
    $data->data($big_data_structure);
    $data->save or die $data->errstr;

    ## ... later ...

    my $data = MT::PluginData->load({ plugin => 'my-plugin',
                                      key    => 'unique-key' });
    my $big_data_structure = $data->data;

DESCRIPTION

MT::PluginData is a data storage mechanism for Movable Type plugins. It uses the same backend datasource as the rest of the Movable Type system: Berkeley DB, MySQL, etc. Plugins can use this class to store arbitrary data structures in the database, keyed on a string specific to the plugin and a key, just like a big associate array. Data structures are serialized using Storable.

USAGE

As a subclass of MT::Object, MT::PluginData inherits all of the data-management and -storage methods from that class; thus you should look at the MT::Object documentation for details about creating a new object, loading an existing object, saving an object, etc.

DATA ACCESS METHODS

The MT::PluginData object holds the following pieces of data. These fields can be accessed and set using the standard data access methods described in the MT::Object documentation.

  • id

    The numeric ID of the record.

  • plugin

    A unique name identifying the plugin.

  • key

    A key--like the key in an associative array--that, with the plugin column, uniquely identifies this record.

  • data

    The data structure that is being stored. When setting the value for this column, the value provided must be a reference. For example, the following will die with an error:

        $data->data('string');

    You must use

        $data->data(\'string');

    instead.

DATA LOOKUP

In addition to numeric ID lookup, you can look up or sort records by any combination of the following fields. See the load documentation in MT::Object for more information.

  • plugin
  • key

AUTHOR & COPYRIGHTS

Please see the MT manpage for author, copyright, and license information.

<<