Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    Konstrukt::Doc::Tutorial::Plugin::Note::DBI 0.5 Beta 7

    Download button

    No screenshots available
    Downloads: 349  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Thomas Wittek | More programs
    Perl Artistic License / FREE
    October 12th, 2007, 23:05 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    Konstrukt::Doc::Tutorial::Plugin::Note::DBI description

    Konstrukt::Doc::Tutorial::Plugin::Note::DBI - Using Perl DBI to store your data in a database tutorial.

    Konstrukt::Doc::Tutorial::Plugin::Note::DBI - Using Perl DBI to store your data in a database tutorial.

    This tutorial will teach you how to use DBI to store your data.

    Additionally we will extend the plugin to allow the creation of multiple notes.

    Note: This tutorial builds up on the results of the previous tutorial.

    CONVENTIONS AND SETTINGS

    By convention the backends for each plugin are implemented as a separate plugin module. This way the backends are easily exchangeable by setting up a different backend in the konstrukt.settings.

    Thus the main plugin will have a new setting

    note/backend DBI #default backend: DBI

    which will be initialized in the init method, where the specified backend will also be loaded. So we add those lines to the init method:

    $Konstrukt::Settings->default("note/backend" => 'DBI');
    $self->{backend} = use_plugin "note::" . $Konstrukt::Settings->get('note/backend') or return undef;

    THE DBI BACKEND PLUGIN

    Backend Settings

    Create a new directory /path/to/your/site/lib/Konstrukt/Plugin/note and inside this directory create a file named DBI.pm.

    The backend plugin itself should also be configurable with these settings:

    note/backend/DBI/source dbi:mysql:database:host
    note/backend/DBI/user user
    note/backend/DBI/pass pass

    If no database settings are set, the website-wide defaults of the Konstrukt DBI helper will be used automatically.

    You should specify the website-wide database defaults in your konstrukt.settings:

    dbi/source dbi:mysql:database:host
    dbi/user user
    dbi/pass pass

    It it doesn't exist, you have to create this database now. An example query for this can be found in the blog tutorial.

    Skeleton

    The skeleton for the backend module including the init method will look like this:

    package Konstrukt::Plugin::note::DBI;

    use strict;
    use warnings;

    use base 'Konstrukt::Plugin';

    sub init {
    my ($self) = @_;

    #get connection settings
    my $db_source = $Konstrukt::Settings->get('blog/backend/DBI/source');
    my $db_user = $Konstrukt::Settings->get('blog/backend/DBI/user');
    my $db_pass = $Konstrukt::Settings->get('blog/backend/DBI/pass');

    #save settings in a handy hashref for later use
    $self->{db_settings} = [$db_source, $db_user, $db_pass];

    return 1;
    }

    1;

    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Perl DBI | database storage | Perl module | Perl | DBI | database

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM