|
Lines 29-34
use CGI;
Link Here
|
| 29 |
use C4::Context; |
29 |
use C4::Context; |
| 30 |
use C4::Charset; |
30 |
use C4::Charset; |
| 31 |
use C4::Auth qw/check_cookie_auth/; |
31 |
use C4::Auth qw/check_cookie_auth/; |
|
|
32 |
use JSON qw/ to_json /; |
| 32 |
|
33 |
|
| 33 |
my $input = new CGI; |
34 |
my $input = new CGI; |
| 34 |
my $query = $input->param('term'); |
35 |
my $query = $input->param('term'); |
|
Lines 54-67
$sql .= qq( ORDER BY $field);
Link Here
|
| 54 |
my $sth = $dbh->prepare($sql); |
55 |
my $sth = $dbh->prepare($sql); |
| 55 |
$sth->execute("$query%", "% $query%", "%-$query%"); |
56 |
$sth->execute("$query%", "% $query%", "%-$query%"); |
| 56 |
|
57 |
|
| 57 |
print "["; |
58 |
my $a = []; |
| 58 |
my $i = 0; |
|
|
| 59 |
while ( my $rec = $sth->fetchrow_hashref ) { |
59 |
while ( my $rec = $sth->fetchrow_hashref ) { |
| 60 |
if($i > 0){ print ","; } |
60 |
push @$a, { fieldvalue => nsb_clean($rec->{$field}) }; |
| 61 |
print "{\"fieldvalue\":\"" . nsb_clean($rec->{$field}) . "\"" . |
|
|
| 62 |
"}"; |
| 63 |
$i++; |
| 64 |
} |
61 |
} |
| 65 |
print "]"; |
|
|
| 66 |
|
| 67 |
|
62 |
|
| 68 |
- |
63 |
print to_json($a); |