... | ... |
@@ -894,11 +894,10 @@ sub select { |
894 | 894 |
$self->_add_relation_table($tables, $relation); |
895 | 895 |
|
896 | 896 |
# Select statement |
897 |
- my @sql; |
|
898 |
- push @sql, 'select'; |
|
897 |
+ my $sql = 'select '; |
|
899 | 898 |
|
900 | 899 |
# Prefix |
901 |
- push @sql, $prefix if defined $prefix; |
|
900 |
+ $sql .= "$prefix " if defined $prefix; |
|
902 | 901 |
|
903 | 902 |
# Column clause |
904 | 903 |
if ($columns) { |
... | ... |
@@ -916,26 +915,26 @@ sub select { |
916 | 915 |
$column = join(' ', $column->[0], 'as', $self->_q($column->[1])); |
917 | 916 |
} |
918 | 917 |
unshift @$tables, @{$self->_search_tables($column)}; |
919 |
- push @sql, ($column, ','); |
|
918 |
+ $sql .= "$column, "; |
|
920 | 919 |
} |
921 |
- pop @sql if $sql[-1] eq ','; |
|
920 |
+ $sql =~ s/, $/ /; |
|
922 | 921 |
} |
923 |
- else { push @sql, '*' } |
|
922 |
+ else { $sql .= '* ' } |
|
924 | 923 |
|
925 | 924 |
# Table |
926 |
- push @sql, 'from'; |
|
925 |
+ $sql .= 'from '; |
|
927 | 926 |
if ($relation) { |
928 | 927 |
my $found = {}; |
929 | 928 |
foreach my $table (@$tables) { |
930 |
- push @sql, ($self->_q($table), ',') unless $found->{$table}; |
|
929 |
+ $sql .= $self->_q($table) . ', ' unless $found->{$table}; |
|
931 | 930 |
$found->{$table} = 1; |
932 | 931 |
} |
933 | 932 |
} |
934 | 933 |
else { |
935 | 934 |
my $main_table = $tables->[-1] || ''; |
936 |
- push @sql, $self->_q($main_table); |
|
935 |
+ $sql .= $self->_q($main_table); |
|
937 | 936 |
} |
938 |
- pop @sql if ($sql[-1] || '') eq ','; |
|
937 |
+ $sql =~ s/, $/ /; |
|
939 | 938 |
croak "Not found table name " . _subname |
940 | 939 |
unless $tables->[-1]; |
941 | 940 |
|
... | ... |
@@ -965,19 +964,17 @@ sub select { |
965 | 964 |
unshift @$tables, @{$self->_search_tables($where_clause)}; |
966 | 965 |
|
967 | 966 |
# Push join |
968 |
- $self->_push_join(\@sql, $join, $tables); |
|
967 |
+ $self->_push_join(\$sql, $join, $tables); |
|
969 | 968 |
|
970 | 969 |
# Add where clause |
971 |
- push @sql, $where_clause; |
|
970 |
+ $sql .= "$where_clause "; |
|
972 | 971 |
|
973 | 972 |
# Relation(DEPRECATED!); |
974 |
- $self->_push_relation(\@sql, $tables, $relation, $where_clause eq '' ? 1 : 0); |
|
973 |
+ $self->_push_relation(\$sql, $tables, $relation, $where_clause eq '' ? 1 : 0) |
|
974 |
+ if $relation; |
|
975 | 975 |
|
976 | 976 |
# Append |
977 |
- push @sql, $append if defined $append; |
|
978 |
- |
|
979 |
- # SQL |
|
980 |
- my $sql = join (' ', @sql); |
|
977 |
+ $sql .= $append if defined $append; |
|
981 | 978 |
|
982 | 979 |
# Execute query |
983 | 980 |
my $result = $self->execute($sql, $where_param, table => $tables, %args); |
... | ... |
@@ -1483,7 +1480,7 @@ sub _push_join { |
1483 | 1480 |
|
1484 | 1481 |
# Add join clause |
1485 | 1482 |
foreach my $need_table (@need_tables) { |
1486 |
- push @$sql, $tree->{$need_table}{join}; |
|
1483 |
+ $$sql .= $tree->{$need_table}{join} . ' '; |
|
1487 | 1484 |
} |
1488 | 1485 |
} |
1489 | 1486 |
|
... | ... |
@@ -1889,15 +1886,15 @@ sub _push_relation { |
1889 | 1886 |
my ($self, $sql, $tables, $relation, $need_where) = @_; |
1890 | 1887 |
|
1891 | 1888 |
if (keys %{$relation || {}}) { |
1892 |
- push @$sql, $need_where ? 'where' : 'and'; |
|
1889 |
+ $$sql .= $need_where ? 'where ' : 'and '; |
|
1893 | 1890 |
foreach my $rcolumn (keys %$relation) { |
1894 | 1891 |
my $table1 = (split (/\./, $rcolumn))[0]; |
1895 | 1892 |
my $table2 = (split (/\./, $relation->{$rcolumn}))[0]; |
1896 | 1893 |
push @$tables, ($table1, $table2); |
1897 |
- push @$sql, ("$rcolumn = " . $relation->{$rcolumn}, 'and'); |
|
1894 |
+ $$sql .= "$rcolumn = " . $relation->{$rcolumn} . 'and '; |
|
1898 | 1895 |
} |
1899 | 1896 |
} |
1900 |
- pop @$sql if $sql->[-1] eq 'and'; |
|
1897 |
+ $$sql =~ s/and $/ /; |
|
1901 | 1898 |
} |
1902 | 1899 |
|
1903 | 1900 |
# DEPRECATED! |