⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plugindata.pm

📁 1. 记录每个帖子的访问人情况
💻 PM
字号:
# Copyright 2001-2005 Six Apart.# SCRiPTMAFiA 2005 - THE DiRTY HANDS ON YOUR SCRiPTS## $Id: PluginData.pm 10197 2005-03-09 00:27:57Z ezra $package MT::PluginData;use strict;use Storable qw( freeze thaw );use MT::Object;@MT::PluginData::ISA = qw( MT::Object );__PACKAGE__->install_properties ({    columns => [        'id', 'plugin', 'key', 'data',    ],    indexes => {        plugin => 1,        key => 1,    },    column_defs => {        data => 'blob',    },    datasource => 'plugindata',    primary_key => 'id',});sub data {    my $data = shift;    $data->column('data', freeze(shift)) if @_;    thaw($data->column('data'));} 1;__END__=head1 NAMEMT::PluginData - Arbitrary data storage for Movable Type plugins=head1 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;=head1 DESCRIPTIONI<MT::PluginData> is a data storage mechanism for Movable Type plugins. Ituses the same backend datasource as the rest of the Movable Type system:Berkeley DB, MySQL, etc. Plugins can use this class to store arbitrarydata structures in the database, keyed on a string specific to the pluginand a key, just like a big associate array. Data structures are serializedusing I<Storable>.=head1 USAGEAs a subclass of I<MT::Object>, I<MT::PluginData> inherits all of thedata-management and -storage methods from that class; thus you should lookat the I<MT::Object> documentation for details about creating a new object,loading an existing object, saving an object, etc.=head1 DATA ACCESS METHODSThe I<MT::PluginData> object holds the following pieces of data. These fieldscan be accessed and set using the standard data access methods described inthe I<MT::Object> documentation.=over 4=item * idThe numeric ID of the record.=item * pluginA unique name identifying the plugin.=item * keyA key--like the key in an associative array--that, with the I<plugin>column, uniquely identifies this record.=item * dataThe data structure that is being stored. When setting the value for thiscolumn, the value provided must be a reference. For example, the followingwill die with an error:    $data->data('string');You must use    $data->data(\'string');instead.=back=head1 DATA LOOKUPIn addition to numeric ID lookup, you can look up or sort records by anycombination of the following fields. See the I<load> documentation inI<MT::Object> for more information.=over 4=item * plugin=item * key=back=head1 AUTHOR & COPYRIGHTSPlease see the I<MT> manpage for author, copyright, and license information.=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -