|
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 772-785
sub _get_column_defs {
Link Here
|
| 772 |
my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $columns_def_file, $section,$cgi); |
772 |
my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $columns_def_file, $section,$cgi); |
| 773 |
|
773 |
|
| 774 |
my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file"; |
774 |
my $full_path_to_columns_def_file="$htdocs/$theme/$lang/$columns_def_file"; |
| 775 |
open (COLUMNS,$full_path_to_columns_def_file); |
775 |
|
| 776 |
while (my $input = <COLUMNS>){ |
776 |
open (my $fh , '<' ,$full_path_to_columns_def_file); |
|
|
777 |
while (my $input = <$fh>){ |
| 777 |
chomp $input; |
778 |
chomp $input; |
| 778 |
my @row =split(/\t/,$input); |
779 |
my @row =split(/\t/,$input); |
| 779 |
$columns{$row[0]}= $row[1]; |
780 |
$columns{$row[0]}= $row[1]; |
| 780 |
} |
781 |
} |
| 781 |
|
782 |
|
| 782 |
close COLUMNS; |
783 |
close $fh; |
| 783 |
return \%columns; |
784 |
return \%columns; |
| 784 |
} |
785 |
} |
| 785 |
1; |
786 |
1; |
| 786 |
- |
|
|