#!/usr/bin/perl -w use strict; use DBI; #use autodie; $\="\n"; my $res_tbl="SOMETABLE"; my $loc_tbl="OTHERTABLE"; my $res_select_stmt = "Select * from $res_tbl order by id"; my $loc_select_stmt = "Select location from $loc_tbl where resource_id = ?"; my $db="SOMEDB"; my $dbun="SOMEUN"; my $dbpw = 'SOMEPW'; my $dbhost="SOMEHOST.hostedresource.com"; my $res_tbl="resource_list"; my $loc_tbl="matrix_locations"; my $drh = DBI->install_driver("mysql") || print "install_driver failed: $DBI::errstr
+"; my $dsn = "DBI:mysql:database=$db;host=$dbhost"; my $dbh = DBI->connect($dsn,$dbun,$dbpw) || print "DB connect failed: $DBI::errstr
" my $res_select_stmt = "Select * from $res_tbl order by id"; my $loc_select_stmt = "Select location from $loc_tbl where resource_id = ?"; my $update_res_stmt = "UPDATE $res_tbl SET name=?, link=?, availability=? WHERE id=?"; print "Updating $res_tbl item with stuff \n"; my $sth = $dbh->prepare($update_res_stmt) or warn "prepare UPDATE statement failed: $dbh->errstr"; my $rv = $sth->execute("test","link test", "test availability", 7) || warn "Execute update failed: $dbh->errstr"; $sth->finish; print "$res_tbl updated with return value '$rv'.\n"; my $select_sth = $dbh->prepare($res_select_stmt) || print "prepare statement failed: $DBI::errstr
"; $select_sth->execute() || print "execute statement failed: $DBI::errstr
"; my $results = $select_sth->fetchall_arrayref(); $select_sth->finish(); foreach my $row (@$results){ print join ',' , @$row; print '\n'; } $dbh->disconnect();