summaryrefslogtreecommitdiffstats
path: root/bin/add_book.pl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/add_book.pl')
-rwxr-xr-xbin/add_book.pl57
1 files changed, 0 insertions, 57 deletions
diff --git a/bin/add_book.pl b/bin/add_book.pl
deleted file mode 100755
index a7364db..0000000
--- a/bin/add_book.pl
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/perl -w
-
-use warnings;
-use strict;
-use strict 'vars';
-
-use DBI;
-
-my $dbfile = 'ksiazki.db';
-my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile", "", "");
-
-my $sth=$dbh->prepare("select * from ksiazki where id=(select max(id) from ksiazki)");
-$sth->execute;
-(my @dupa)=$sth->fetchall_arrayref;
-my $max_id = ${$dupa[0]}[0][0];
-
-my $id=$max_id+1; #Nowe id tworzymy, biorac stare najwieksze i dodajac 1
-print 'Podaj isbn:';
-my $isbn = <STDIN>;
-chomp $isbn;
-print 'Podaj tytul:';
-my $title = <STDIN>;
-chomp $title;
-$title='\''.$title.'\'';
-print 'Podaj autora:';
-my $author = <STDIN>;
-chomp $author;
-$author = '\''.$author.'\'';
-print 'Podaj wlasciciela:';
-my $owner = <STDIN>;
-chomp $owner;
-$owner = '\''.$owner.'\'';
-print 'Czy ksiazke mozna pozyczac?:';
-my $can_borrow = <STDIN>;
-chomp $can_borrow;
-while (1)
-{
- if ($can_borrow eq 'Tak')
- {
- $can_borrow = 1;
- last;
- }
- elsif ($can_borrow eq 'Nie')
- {
- $can_borrow = 0;
- last;
- }
- else
- {
- print 'Odpowiedz Tak lub Nie!';
- $can_borrow = <STDIN>;
- chomp $can_borrow;
- }
-}
-$sth=$dbh->prepare("insert into ksiazki values($id,$isbn,$title,$author,$owner,1,$can_borrow)"); #Zakladamy, ze dodawana ksiazka jest na miejscu,
-#wiec zamiast sie o to pytac, wpisuje, ze jest.
-$sth->execute or die 'Blad przy pisaniu do bazy!';