NAME

WordPress::DBIC::Schema - Database schema for WordPress

DESCRIPTION

This is a basic schema (and mostly a work in progress) for the WordPress database, which can be used for migrations, data fetching etc.

It comes with some relationships even if the DB doesn't implement them with foreign keys.

SYNOPSIS

my $schema = WordPress::DBIC::Schema->connect('wordpress');
foreach my $id (@ARGV) {
    if (my $post = $schema->resultset('WpPost')->published
        ->find($id, {
                     prefetch => ['metas', { wp_term_relationships => { wp_term_taxonomy => 'wp_term' } }],
                    })) {
        foreach my $taxonomy ($post->taxonomies) {
            print $post->post_title . ' ' . $taxonomy->wp_term->name . "\n";
        }
        print $post->clean_url . "\n";
        print $post->permalink . "\n";
        foreach my $meta ($post->metas) {
            if ($meta->meta_key eq 'subtitle') {
                print $meta->meta_value . "\n";
            }
        }
        print $post->html_body . "\n";
    }
}

AUTHOR

Marco Pessotto, <melmothx at gmail.com>

BUGS

Please report any bugs or feature requests to the author's email or just use the CPAN's RT.

LICENSE

This module is free software and is published under the same terms as Perl itself.