GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DBIX::SQLITE::SIMPLE::TABLE (3)

.ds Aq ’

NAME

DBIx::SQLite::Simple::Table - superclass only used to handle SQL tables

CONTENTS

SYNOPSIS



   # Example of a table with a primary key

   package TPub;

   require DBIx::SQLite::Simple::Table;
   our @ISA = qw(DBIx::SQLite::Simple::Table);

   our @AS = qw(
      idPub
      pub
   );
   __PACKAGE__->cgBuildIndices;
   __PACKAGE__->cgBuildAccessorsScalar(\@AS);

   # our $Id and our @Fields are named Id and Fields for a good
   # reason, so do not name these variables by another name.
   our $Id     = $AS[0];
   our @Fields = @AS[1..$#AS];

   1;

   # Example of a table with no key at all

   package TBeer;

   require DBIx::SQLite::Simple::Table;
   our @ISA = qw(DBIx::SQLite::Simple::Table);

   our @AS = qw(
      beer
      country
   );
   __PACKAGE__->cgBuildIndices;
   __PACKAGE__->cgBuildAccessorsScalar(\@AS);

   our @Fields = @AS;

   1;

   # Now, we have two tables, we can play with the database

   package main;

   require DBIx::SQLite::Simple;
   my $db = DBIx::SQLite::Simple->new(db => sqlite.db);

   # Create to object to play with the two tables
   my $tPub = TPub->new;
   my $tBeer = TBeer->new;

   # Create tables
   $tPub->create  unless $tPub->exists;
   $tBeer->create unless $tBeer->exists;

   # Create some entries
   my @pubEntries;
   push @pubEntries, TPub->new(pub => $_) for (qw(corner friends));

   my @beerEntries;
   push @beerEntries, TBeer->new(beer => $_, country => BE)
      for (qw(grim leffe bud));

   # Now insert those entries;
   $tPub->insert(\@pubEntries);
   $tBeer->insert(\@beerEntries);

   # Get friends pub
   my $friends = $tPub->select(pub => friends);

   # Lookup id
   my $id = $tPub->lookupId(pub => friends);

   # Lookup string
   my $str = $tPub->lookupString(pub, idPub => $id);

   # Add a beer from chez moi
   my $dremmwel = TBeer->new(beer => Dremmwel, country => ?);
   $tBeer->insert([ $dremmwel ]);

   $tPub->commit;
   $tBeer->commit;

   # Update Dremmwel
   my $dremmwelOld = $dremmwel->cgClone;
   $dremmwel->country(BZH);
   $tBeer->update([ $dremmwel ], $dremmwelOld);
   $tBeer->commit;

   # Delete all pubs
   $tPub->delete(\@pubEntries);



ATTRIBUTES

<B>dboB> Stores a DBIx::SQLite::Simple object.

METHODS

<B>newB> Object creator. Will return an object used to access corresponding SQL table. You can pass an optional parameter: dbo. By default, it uses the global variable $DBIx::SQLite::Simple::Dbo.
<B>commitB> Just a convenient method to commit pending changes to the whole database.
<B>createB> Method to create the table.
<B>existsB> Method to verify existence of a table.
<B>selectB> If called without parameters, returns the whole content as an arrayref. If called with a hash as argument containing some table fields with values, it plays as multiple where clauses (return result as an arrayref also). See SYNOPSIS.
<B>selectByIdB> This method returns a reference to an array with each array indice set to the corresponding table object id.
<B>getKeyB> Method used to generate a unique key, using to store and retrieve a database element quickly. By default, the key is the first field in the table schema (excluding the id field). It is user responsibility to override this method to use an appropriate key.
<B>selectByKeyB> Method used to cache a table content. It uses <B>getKeyB> to store the object into a reference to a hash. You access a cached element by calling <B>getKeyB> on an object.
<B>deleteB>($arrayref) Deletes all entries specified in the arrayref (they are all objects of type DBIx::SQLite::Simple::Table).
<B>insertB>($arrayref) Insert all entries specified in the arrayref (they are all objects of type DBIx ::SQLite::Simple::Table).
<B>updateB>($arrayref) Will update elements specified within the arrayref (they are all objects of type DBIx::SQLite::Simple::Table). If an additionnal argument is passed, it will act as a where clause. See SYNOPSIS.
<B>lookupIdB>(%hash) Returns the the id if the specified field/value hash.
<B>lookupStringB>($field, field2 => value) Returns the content of the specified field. See SYNOPSIS.

AUTHOR

Patrice <GomoR> Auffret

COPYRIGHT AND LICENSE

Copyright (c) 2005-2015, Patrice <GomoR> Auffret

You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DBIX::SQLITE::SIMPLE::TABLE (3) 2015-01-04

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.