[{"data":1,"prerenderedAt":147},["ShallowReactive",2],{"\u002Fsetdb-code-examples":3},{"id":4,"title":5,"body":6,"createdAt":135,"description":136,"draft":137,"extension":138,"image":139,"mastodonThread":139,"meta":140,"navigation":141,"path":142,"seo":143,"stem":144,"tags":145,"updatedAt":135,"__hash__":146},"content\u002FSetDB Code Examples.md","SetDB_Code_Examples",{"type":7,"value":8,"toc":132},"minimark",[9,26],[10,11,12,13,16],"p",{},"Here is some actual working code from SetDB 0.2:",[14,15],"br",{},[17,18,19,20,22,23,25],"code",{},"use strict;",[14,21],{},"\nuse DBI;",[14,24],{},"\nuse SetDB;",[17,27,28,33,37,40,44,50,54,60,64,67,71,79,83,92,96,99,103,111,121,127],{},[29,30,32],"h1",{"id":31},"must-turn-off-no-strict-subs-so-i-can-use-magical-barewords","Must turn off no strict subs so I can use magical barewords",[29,34,36],{"id":35},"this-is-certainly-not-required-for-using-this-module","This is certainly not required for using this module",[10,38,39],{},"no strict 'subs';",[29,41,43],{"id":42},"okay-first-we-set-up-our-dbi-connection","Okay, first we set up our DBI connection",[10,45,46,47,49],{},"my $dbi = DBI->connect(",[14,48],{},"\n'DBI:mysql:database=setdb_test;host=localhost', 'setdb', 'setdb');",[29,51,53],{"id":52},"now-we-set-up-our-schema","Now we set up our schema",[10,55,56,57,59],{},"use vars qw( $schema );",[14,58],{},"\ndo 'schema.pl';",[29,61,63],{"id":62},"this-creates-our-setdb-database","This creates our SetDB database",[10,65,66],{},"my $db = new SetDB($dbi, $schema);",[29,68,70],{"id":69},"lets-get-a-set-of-people-and-their-books","Lets get a set of people and their books",[10,72,73,74,78],{},"my $people = $db->newSet(person, ",[75,76,77],"span",{},"book",");",[29,80,82],{"id":81},"now-loop-through-and-print-out-each-person","Now loop through and print out each person",[10,84,85,86,88,89,91],{},"while(my $person = $people->fetchNext())",[14,87],{},"\n{",[14,90],{},"\nprint \"Name: $person->{name}\\n\";",[29,93,95],{"id":94},"this-is-the-set-of-books-which-that-person-has","This is the set of books which that person has",[10,97,98],{},"my $books = $person->{book};",[29,100,102],{"id":101},"lets-go-ahead-and-print-all-of-their-books","Lets go ahead and print all of their books",[10,104,105,106,88,108,110],{},"while(my $book = $books->fetchNext())",[14,107],{},[14,109],{},"\nprint \"  Book: $book->{title}\\n\";",[112,113,118],"pre",{"className":114,"code":116,"language":117},[115],"language-text","# Demonstrate updates by adding ' sucks!' to the book's title\n$book->{title} .= ' sucks!';\n","text",[17,119,116],{"__ignoreMap":120},"",[10,122,123,124,126],{},"}",[14,125],{},"\n}",[112,128,130],{"className":129,"code":120,"language":117},[115],[17,131,120],{"__ignoreMap":120},{"title":120,"searchDepth":133,"depth":133,"links":134},2,[],"2004-02-24T01:29-05:00","Here is some actual working code from SetDB 0.2:use strict;\nuse DBI;\nuse SetDB;",false,"md",null,{},true,"\u002Fsetdb-code-examples",{"title":5,"description":136},"SetDB Code Examples",[],"0jFGMwawaftM8N-zemE7MlbyxX1FAjPMyNGWiIifkRE",1778988312983]