THE LACK THEREOF

SetDB Code Examples

Here is some actual working code from SetDB 0.2:

use strict;
use DBI;
use SetDB;

# Must turn off no strict subs so I can use magical barewords
# This is certainly not required for using this module
no strict 'subs';

# Okay, first we set up our DBI connection
my $dbi = DBI->connect(
  'DBI:mysql:database=setdb_test;host=localhost', 'setdb', 'setdb');

# Now we set up our schema
use vars qw( $schema );
do 'schema.pl';

# This creates our SetDB database
my $db = new SetDB($dbi, $schema);

# Lets get a set of people and their books
my $people = $db->newSet(person, [book]);

# Now loop through and print out each person
while(my $person = $people->fetchNext())
{
  print "Name: $person->{name}\n";

  # This is the set of books which that person has
  my $books = $person->{book};

  # Lets go ahead and print all of their books
  while(my $book = $books->fetchNext())
  {
    print "  Book: $book->{title}\n";

    # Demonstrate updates by adding ' sucks!' to the book's title
    $book->{title} .= ' sucks!';
  }
}

Navigation

Blog

https://thelackthereof.org/pics/16px-Feed-icon.svg.png Blog RSS Feed

Tweets


2019-04-06

2019-03-29

2019-03-28

2019-03-24

2019-03-20

Toots (Mastodon)

2018-07-02

2018-06-30

Code

Follow @awwaiid

Wiki Edits

https://thelackthereof.org/pics/16px-Feed-icon.svg.png Wiki RSS Feed

... more changes