Lines 373-379
sub get_criteria {
Link Here
|
373 |
return ( \@criteria_array ); |
373 |
return ( \@criteria_array ); |
374 |
} |
374 |
} |
375 |
|
375 |
|
376 |
sub nb_rows($) { |
376 |
sub nb_rows { |
377 |
my $sql = shift or return; |
377 |
my $sql = shift or return; |
378 |
my $sth = C4::Context->dbh->prepare($sql); |
378 |
my $sth = C4::Context->dbh->prepare($sql); |
379 |
$sth->execute(); |
379 |
$sth->execute(); |
Lines 407-426
the user in a user-supplied SQL query WILL apply in any case.
Link Here
|
407 |
# ~ remove any LIMIT clause |
407 |
# ~ remove any LIMIT clause |
408 |
# ~ repace SELECT clause w/ SELECT count(*) |
408 |
# ~ repace SELECT clause w/ SELECT count(*) |
409 |
|
409 |
|
410 |
sub select_2_select_count ($) { |
410 |
sub select_2_select_count { |
411 |
# Modify the query passed in to create a count query... (I think this covers all cases -crn) |
411 |
# Modify the query passed in to create a count query... (I think this covers all cases -crn) |
412 |
my ($sql) = strip_limit(shift) or return; |
412 |
my ($sql) = strip_limit(shift) or return; |
413 |
$sql =~ s/\bSELECT\W+(?:\w+\W+){1,}?FROM\b|\bSELECT\W\*\WFROM\b/SELECT count(*) FROM /ig; |
413 |
$sql =~ s/\bSELECT\W+(?:\w+\W+){1,}?FROM\b|\bSELECT\W\*\WFROM\b/SELECT count(*) FROM /ig; |
414 |
return $sql; |
414 |
return $sql; |
415 |
} |
415 |
} |
416 |
sub strip_limit ($) { |
416 |
sub strip_limit { |
417 |
my $sql = shift or return; |
417 |
my $sql = shift or return; |
418 |
($sql =~ /\bLIMIT\b/i) or return ($sql, 0, undef); |
418 |
($sql =~ /\bLIMIT\b/i) or return ($sql, 0, undef); |
419 |
$sql =~ s/\bLIMIT\b\s*(\d+)(\s*\,\s*(\d+))?\s*/ /ig; |
419 |
$sql =~ s/\bLIMIT\b\s*(\d+)(\s*\,\s*(\d+))?\s*/ /ig; |
420 |
return ($sql, (defined $2 ? $1 : 0), (defined $3 ? $3 : $1)); # offset can default to 0, LIMIT cannot! |
420 |
return ($sql, (defined $2 ? $1 : 0), (defined $3 ? $3 : $1)); # offset can default to 0, LIMIT cannot! |
421 |
} |
421 |
} |
422 |
|
422 |
|
423 |
sub execute_query ($;$$$) { |
423 |
sub execute_query { |
424 |
|
424 |
|
425 |
my ( $sql, $offset, $limit, $no_count ) = @_; |
425 |
my ( $sql, $offset, $limit, $no_count ) = @_; |
426 |
|
426 |
|
Lines 754-767
sub _get_column_defs {
Link Here
|
754 |
my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $columns_def_file, $section,$cgi); |
754 |
my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $columns_def_file, $section,$cgi); |
755 |
|
755 |
|
756 |
my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file"; |
756 |
my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file"; |
757 |
open (COLUMNS,$full_path_to_columns_def_file); |
757 |
|
758 |
while (my $input = <COLUMNS>){ |
758 |
open (my $fh , '<' ,$full_path_to_columns_def_file); |
|
|
759 |
while (my $input = <$fh>){ |
759 |
chomp $input; |
760 |
chomp $input; |
760 |
my @row =split(/\t/,$input); |
761 |
my @row =split(/\t/,$input); |
761 |
$columns{$row[0]}= $row[1]; |
762 |
$columns{$row[0]}= $row[1]; |
762 |
} |
763 |
} |
763 |
|
764 |
|
764 |
close COLUMNS; |
765 |
close $fh; |
765 |
return \%columns; |
766 |
return \%columns; |
766 |
} |
767 |
} |
767 |
1; |
768 |
1; |
768 |
- |
|
|