summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCranix <you@example.com>2013-03-25 16:15:35 -0400
committerCranix <you@example.com>2013-03-25 16:15:35 -0400
commita6efcc3ef84dab60410d975fe2f964b6ba9ff5ee (patch)
tree05f5b4308b209014446e0dd52e8f920b5f00e634
parent8aaed63fc2929e9c04432caa65091a91d4837ab0 (diff)
downloadBiblioteka-a6efcc3ef84dab60410d975fe2f964b6ba9ff5ee.tar.gz
Biblioteka-a6efcc3ef84dab60410d975fe2f964b6ba9ff5ee.tar.bz2
Biblioteka-a6efcc3ef84dab60410d975fe2f964b6ba9ff5ee.zip
Dany inny (wcześniejszy) przykładowy plik bazy, o dziwo działa.
Namierzania problemu ciąg dalszy.
-rwxr-xr-xbin/app.pl21
-rw-r--r--bin/ksiazki.dbbin2048 -> 3072 bytes
2 files changed, 8 insertions, 13 deletions
diff --git a/bin/app.pl b/bin/app.pl
index 1c56ec0..7842b0f 100755
--- a/bin/app.pl
+++ b/bin/app.pl
@@ -13,13 +13,10 @@ my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", "");
get '/' => sub
{
- my $sth = $dbh->prepare("select * from ksiazki");
- $sth->execute();
-
- my $i=0;
+ my $sth = $dbh->prepare("select * from ksiazki;") or die "Nie mozna spreparowac zapytania";
+ $sth->execute() or die "Nie mozna wykonac zapytania";
+ #my $sth=$dbh->do("select * from ksiazki");
my @result;
- my $ii=0;
-
(@result)=@{$sth->fetchall_arrayref} or die "blad przy pobieraniu danych";
# |kolejne rekordy|kolejne pola rekordow
@@ -35,13 +32,13 @@ get '/req/:book' => sub
my $id=params->{book};
my $sth;
- $sth=$dbh->prepare("select type from ksiazki where id=?");
- $sth->execute($id);
- my $type = $sth->fetchrow_array;
+ $sth=$dbh->prepare("select type from ksiazki where id=?") or die "Nie mozna spreparowac zapytania";
+ $sth->execute($id) or die "Nie mozna wykonac";
+ my $type = $sth->fetchrow_array or die "Nie mozna pobrac danych";
if ($type == 1)
{
- $sth = $dbh->prepare("update ksiazki set state=not state where id=?");
- $sth->execute($id);
+ $sth = $dbh->prepare("update ksiazki set state=not state where id=?") or die "Nie mozna spreparowac zapytania";
+ $sth->execute($id) or die "Nie mozna wykonac zapytania";
return 0;
}
elsif ($type == 0)
@@ -54,7 +51,5 @@ get '/req/:book' => sub
}
};
-$sth->finish();
-$dbh->disconnect();
dance;
diff --git a/bin/ksiazki.db b/bin/ksiazki.db
index 0b16197..ff6d6ee 100644
--- a/bin/ksiazki.db
+++ b/bin/ksiazki.db
Binary files differ