sub _SELECT {
my @params = @_;
- my $query = "SELECT $params[0] FROM $params[1]";
+ my $query = "SELECT `$params[0]` FROM $params[1]";
$params[2] ? $query .= " WHERE $params[2];" : $query .= ';';
my $sth = C4::Context->dbh->prepare($query);
# $sth->{'TraceLevel'} = 3;
sub _build_query {
my ( $params, $table ) = @_;
my @fields = exists $params->{fields} ? @{ $params->{fields} } : ();
- my $query = "SELECT " . ( @fields ? join(', ', @fields ) : '*' ) . " FROM $table";
+ my $query = "SELECT " . ( @fields ? join(', ', map {"`$_`"} @fields ) : '*' ) . " FROM $table";
my @where_args;
if ( exists $params->{filters} ) {
$query .= ' WHERE 1 ';
$sth->do("INSERT INTO `creator_layouts_tmp` (layout_id, barcode_type, printing_type, layout_name, guidebox, callnum_split, text_justify, format_string) SELECT layout_id, barcode_type, printing_type, layout_name, guidebox, callnum_split, text_justify, format_string FROM labels_layouts;") or die "DB ERROR: " . $sth->errstr . "\n";
-$sth->do("INSERT INTO `creator_templates_tmp` (template_id, template_code, template_desc, page_width, page_height, label_width, label_height, top_margin, left_margin, cols, rows, col_gap, row_gap, units) SELECT template_id, template_code, template_desc, page_width, page_height, label_width, label_height, top_margin, left_margin, cols, rows, col_gap, row_gap, units FROM labels_templates;") or die "DB ERROR: " . $sth->errstr . "\n";
+$sth->do("INSERT INTO `creator_templates_tmp` (template_id, template_code, template_desc, page_width, page_height, label_width, label_height, top_margin, left_margin, cols, `rows`, col_gap, row_gap, units) SELECT template_id, template_code, template_desc, page_width, page_height, label_width, label_height, top_margin, left_margin, cols, `rows`, col_gap, row_gap, units FROM labels_templates;") or die "DB ERROR: " . $sth->errstr . "\n";
# Drop old tables....
(profile_id , template_code, template_desc, page_width,
page_height , label_width , label_height , top_text_margin,
left_text_margin, top_margin , left_margin , cols,
- rows , col_gap , row_gap , units,
+ `rows` , col_gap , row_gap , units,
creator)
VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
my $insert_sth = $dbh->prepare($query);
$query = '
SELECT count(*)
FROM creator_templates
- WHERE rows = 7
+ WHERE `rows` = 7
';
$count = $dbh->selectrow_array($query);
is( $count, 1, 'There is 1 template matching' );