You are in Home page » Products » Opensource » CPAN » HTML::Puzzle » Help on line |
![]() |
![]() |
|||
![]() |
![]() |
NAMEHTML::Puzzle::DBTable - Connection module to data tables
SYNOPSISuse HTML::Puzzle::DBTable; my $comp = new HTML::Puzzle::DBTable( dbh => $dbh, name => 'Test' ); # create data table $comp->create; # add an item my $addItem = { 'title' => "First title", 'txt_short' => "First short text", 'txt_long' => "First very long long text :-)", 'link' => "http://a.link.itm/", 'link_img' => "http://a.link.img/", 'data' => '2002-07-21' }; $comp->add($addItem); # get item as an array ref my $itm = $comp->array_items(); # return something like # [ # [ # 'id', # 'title', # 'txt_short', # 'txt_long', # 'link', # 'link_img', # 'enable', # 'data', # 'ts' # ], # [ # '1', # 'First title', # 'First short text', # 'First very long long text :-)', # 'http://a.link.itm/', # 'http://a.link.img/', # '1', # '2002-07-21 00:00:00', # '02' # ] # ]; # get item as an hash ref my $itm = $comp->hash_items(); # return something like # [ # { # 'ts' => '02', # 'title' => 'First title', # 'txt_long' => 'First very long long text :-)', # 'data' => '2002-07-21 00:00:00', # 'id' => '1', # 'link_img' => 'http://a.link.img/', # 'txt_short' => 'First short text', # 'enable' => '1', # 'link' => 'http://a.link.itm/' # } # ]; # delete record $comp->delete(2); # delete group of records $comp->delete([2,5,7,9]); # drop table $comp->table; From command line to create or drop table: [root]# perl -MHTML::Puzzle::DBTable -e 'HTML::Puzzle::DBTable::create' Enter the DBD driver name [mysql]: Enter the database hostname [localhost]: Enter database port number [3128]: Enter database name: PuzzleTest Enter an userid which can manage tables [root]: Enter password: ******** Enter table name: test Table test created succesful [root]# perl -MHTML::Puzzle::DBTable -e 'HTML::Puzzle::DBTable::drop' Enter the DBD driver name [mysql]: Enter the database hostname [localhost]: Enter database port number [3128]: Enter database name: PuzzleTest Enter an userid which can manage tables [root]: Enter password: ******** Enter table name: test Table test succesful dropped =head1 DESCRIPTION This module interact with a single db table containing data to be consumed by other modules of this package. With this module you can add, delete,or get data present in the table further that create or drop table itself. Standard db structure have some usefull fields for building every kind of web component like news, forums, helpdesk, guestbook pages. There is an id that univocally identify the db data record, a title that you could use for news title, a txt_short for a short description of data, a txt_long with long description, a link and link_img for storing links,a data field for datetiming and an enable field that you can use for identify old news. Table also have a timestamp field ts to save time entry. Anyway db table can be personalized.
METHODS
|
![]() |
|
![]() |
![]() | ||
Copyright© 1997-2006 Emiliano Bruni | Online from 16/08/1998 with |
Write me to:
![]() |