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

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

Konstrukt::Doc::Tutorial::Plugin::Note::DBI Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Thomas Wittek
  • Publisher web site:
  • http://search.cpan.org/~twittek/Konstrukt-0.5-beta7/lib/Konstrukt/Doc/Tutorial/Plugin/Note/DBI.pod

Konstrukt::Doc::Tutorial::Plugin::Note::DBI Tags


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 SETTINGSBy 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: DBIwhich 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 PLUGINBackend SettingsCreate 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 passIf 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 passIt it doesn't exist, you have to create this database now. An example query for this can be found in the blog tutorial.SkeletonThe 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} = ; return 1; } 1; Requirements: · Perl


Konstrukt::Doc::Tutorial::Plugin::Note::DBI Related Software