my $field = $q->param("f$i");
my $limit = $q->param("v$i");
my $field = $q->param("f$i");
my $limit = $q->param("v$i");
+ my $filter = $q->param("filter");
+
my $html;
my $index = new index_DBI(
my $html;
my $index = new index_DBI(
$cfg_global->val('global', 'dbi_passwd') || ''
);
$cfg_global->val('global', 'dbi_passwd') || ''
);
- my $total = $index->count($field,$limit);
+ my $total = $index->count($field,$limit,$filter);
+ if (! defined($total)) {
my $tmpl = $self->load_tmpl(url_ex($q,'no_index.html'));
$tmpl->param('field',$field);
$html = $tmpl->output;
my $tmpl = $self->load_tmpl(url_ex($q,'no_index.html'));
$tmpl->param('field',$field);
$html = $tmpl->output;
make_pager($q, $tmpl, $pager);
make_pager_vars($q, $tmpl, @persist_vars);
make_pager($q, $tmpl, $pager);
make_pager_vars($q, $tmpl, @persist_vars);
- my @pager_data_list = $index->fetch($field,$limit, $pager->first - 1, $pager->entries_on_this_page);
+ my @pager_data_list = $index->fetch($field,$limit, $pager->first - 1, $pager->entries_on_this_page, $filter);
$tmpl->param('PAGER_DATA_LIST', \@pager_data_list);
return in_template($q,$tmpl->output);
$tmpl->param('PAGER_DATA_LIST', \@pager_data_list);
return in_template($q,$tmpl->output);
library=Psihologija
library_url=http://knjiznice.ffzg.hr/info.html#psiho
library=Psihologija
library_url=http://knjiznice.ffzg.hr/info.html#psiho
-#[ps-peri]
-# isis_db=/backup/isis_backup/sunce2/isisdata/latest/PERI/PERI
-# type=isis
-# materialtype=Èasopis
-# library=Psihologija
-# library_url=http://knjiznice.ffzg.hr/info.html#psiho
-#
+[ps-peri]
+ isis_db=/data/isis_data/ps/PERI/PERI
+ type=isis
+ materialtype=Èasopis
+ library=Psihologija
+ library_url=http://knjiznice.ffzg.hr/info.html#psiho
+
#[pu-libri]
# isis_db=/backup/isis_backup/C124-2A/ISISDATA/latest/LIBRI/LIBRI
# type=isis
#[pu-libri]
# isis_db=/backup/isis_backup/C124-2A/ISISDATA/latest/LIBRI/LIBRI
# type=isis
my $db = new Biblio::Isis( isisdb => $isis_db );
my $max_rowid = $db->count || die "can't find maxmfn";
my $db = new Biblio::Isis( isisdb => $isis_db );
my $max_rowid = $db->count || die "can't find maxmfn";
print STDERR "Reading database: $isis_db [$max_rowid rows]\n";
print STDERR "Reading database: $isis_db [$max_rowid rows]\n";
my $field = shift;
my $where = shift;
my $field = shift;
my $where = shift;
- my $sql = "select count(*) from index where name = ? and upper(item) like upper(?)||'%'";
+ my $filter = shift;
+
+ my $tables_sql = 'index';
+ my $where_sql = '';
+ my @sql_args = ( $field, $where );
+
+ if ($filter) {
+ $tables_sql .= ",filters";
+ $where_sql .= "
+ and index.ord = filters.ord
+ and filter = ?
+ ";
+ push @sql_args, $filter;
+ }
+
+ my $sql = qq{
+ select count(*)
+ from $tables_sql
+ where name = ? and upper(item) like upper(?)||'%'
+ $where_sql
+ };
- my $sth = $self->{dbh}->prepare($sql) || die $self->{dbh}->errstr();
- $sth->execute($field,$where) || die "sql: $sql; ".$self->{dbh}->errstr();
+ my $sth = $self->{dbh}->prepare($sql) || confess $self->{dbh}->errstr();
+ $sth->execute(@sql_args) || confess "sql: $sql; ".$self->{dbh}->errstr();
my ($total) = $sth->fetchrow_array();
# no results, count all
if (! $total) {
my ($total) = $sth->fetchrow_array();
# no results, count all
if (! $total) {
- my $sql = "select count(*) from index wheere name = ?";
-
- my $sth = $self->{dbh}->prepare($sql) || die $self->{dbh}->errstr();
- $sth->execute($field) || die "sql: $sql; ".$self->{dbh}->errstr();
+ my $sql = qq{
+ select count(*)
+ from $tables_sql
+ where index.name = ?
+ $where_sql
+ };
+
+ @sql_args = ( $field );
+ push @sql_args, $filter if ($filter);
+
+ my $sth = $self->{dbh}->prepare($sql) || confess $self->{dbh}->errstr();
+ $sth->execute(@sql_args) || confess "sql: $sql; ".$self->{dbh}->errstr();
$total = $sth->fetchrow_array();
}
$total = $sth->fetchrow_array();
}
my $offset = shift || 0;
my $rows = shift || 10;
my $offset = shift || 0;
my $rows = shift || 10;
+ my $tables_sql = 'index';
+ my $where_sql = '';
- my $sql = qq{
- select item,display,count
- from index
- where name = ?
- and ord > ?
- order by ord
- limit ? offset ?
- };
+ my @sql_args = ( $field, $where );
- if ($where) {
- my $sql2 = "select ord from index where name = ? and upper(item) like upper(?)||'%'";
- my $sth = $self->{dbh}->prepare($sql2) || die "sql2: $sql2; ".$self->{dbh}->errstr();
+ if ($filter) {
+ $tables_sql .= ",filters";
+ $where_sql .= "
+ and index.ord = filters.ord
+ and filter = ?
+ ";
+ push @sql_args, $filter;
+ }
- $sth->execute($field, $where) || die "sql2: $sql2; ".$self->{dbh}->errstr();
+ if ($where) {
+ my $sql2 = qq{
+ select index.ord as ord
+ from $tables_sql
+ where name = ? and upper(item) like upper(?)||'%'
+ $where_sql
+ };
+ my $sth = $self->{dbh}->prepare($sql2) || confess "sql2: $sql2; ".$self->{dbh}->errstr();
+
+ $sth->execute(@sql_args) || confess "sql2: $sql2; ".$self->{dbh}->errstr();
if (my $row = $sth->fetchrow_hashref) {
$from_ord += $row->{ord} - 1;
} else {
# if no match is found when searching from beginning
# of word in index, try substring match anywhere
if (my $row = $sth->fetchrow_hashref) {
$from_ord += $row->{ord} - 1;
} else {
# if no match is found when searching from beginning
# of word in index, try substring match anywhere
- $sql2 = "select ord from index where name = ? and upper(item) like '% '||upper(?)||'%'";
- $sth = $self->{dbh}->prepare($sql2) || die "sql2: $sql2; ".$self->{dbh}->errstr();
- $sth->execute($field, $where) || die "sql2: $sql2; ".$self->{dbh}->errstr();
+ $sql2 = qq{
+ select index.ord as ord
+ from $tables_sql
+ where name = ? and upper(item) like '% '||upper(?)||'%'
+ $where_sql
+ };
+
+ $sth = $self->{dbh}->prepare($sql2) || confess "sql2: $sql2; ".$self->{dbh}->errstr();
+ $sth->execute(@sql_args) || confess "sql2: $sql2; ".$self->{dbh}->errstr();
+
if (my $row = $sth->fetchrow_hashref) {
$from_ord += $row->{ord} - 1;
}
}
}
if (my $row = $sth->fetchrow_hashref) {
$from_ord += $row->{ord} - 1;
}
}
}
- my $sth = $self->{dbh}->prepare($sql) || die "prepare: $sql; ".$self->{dbh}->errstr();
- $sth->execute($field,$from_ord,$rows,$offset) || die "execute: $sql; ".$self->{dbh}->errstr();
+ @sql_args = ( $field, $from_ord );
+ push @sql_args, $filter if ($filter);
+ push @sql_args, ( $rows, $offset );
+
+ my $sql = qq{
+ select item,display,index.count as count
+ from $tables_sql
+ where name = ?
+ and index.ord > ?
+ $where_sql
+ order by index.ord
+ limit ? offset ?
+ };
+
+ my $sth = $self->{dbh}->prepare($sql) || confess "prepare: $sql; ".$self->{dbh}->errstr();
+ $sth->execute(@sql_args) || confess "execute: $sql; ".$self->{dbh}->errstr();
my @arr;
while (my $row = $sth->fetchrow_hashref) {
$row->{item} = HTML::Entities::encode($row->{item},' <>&"');
my @arr;
while (my $row = $sth->fetchrow_hashref) {
$row->{item} = HTML::Entities::encode($row->{item},' <>&"');
return if (! $self->{dbh});
return if (! $self->{dbh});
- $self->{dbh}->begin_work || die $self->{dbh}->errstr();
+ $self->{dbh}->begin_work || confess $self->{dbh}->errstr();
$self->delete_and_create('index', qq{
create table index (
$self->delete_and_create('index', qq{
create table index (
- $self->{dbh}->commit || die $self->{dbh}->errstr();
+ $self->{dbh}->commit || confess $self->{dbh}->errstr();
$self->bench("vacuuming");
$self->bench("vacuuming");