summaryrefslogtreecommitdiff
path: root/FS/FS/Record.pm
diff options
context:
space:
mode:
authorivan <ivan>2011-01-30 22:32:18 +0000
committerivan <ivan>2011-01-30 22:32:18 +0000
commit2fcf7ebdbdcc55890fdbebb239396fdabc15d905 (patch)
tree10462cf0311c5abd8d86d2c80163c2f1f7947088 /FS/FS/Record.pm
parentc404d562d57430f96284f4855135f6f9af79fb00 (diff)
fix bw graphs for mysql?, RT#10574
Diffstat (limited to 'FS/FS/Record.pm')
-rw-r--r--FS/FS/Record.pm29
1 files changed, 27 insertions, 2 deletions
diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm
index 29e5322ef..e23699cce 100644
--- a/FS/FS/Record.pm
+++ b/FS/FS/Record.pm
@@ -30,8 +30,10 @@ use Tie::IxHash;
@ISA = qw(Exporter);
#export dbdef for now... everything else expects to find it here
-@EXPORT_OK = qw(dbh fields hfields qsearch qsearchs dbdef jsearch
- str2time_sql str2time_sql_closing regexp_sql not_regexp_sql );
+@EXPORT_OK = qw(
+ dbh fields hfields qsearch qsearchs dbdef jsearch
+ str2time_sql str2time_sql_closing regexp_sql not_regexp_sql concat_sql
+);
$DEBUG = 0;
$me = '[FS::Record]';
@@ -3099,6 +3101,29 @@ sub not_regexp_sql {
}
+=item concat_sql [ DRIVER_NAME ] ITEMS_ARRAYREF
+
+Returns the items concatendated based on database type, using "CONCAT()" for
+mysql and " || " for Pg and other databases.
+
+You can pass an optional driver name such as "Pg", "mysql" or
+$dbh->{Driver}->{Name} to return a function for that database instead of
+the current database.
+
+=cut
+
+sub concat_sql {
+ my $driver = ref($_[0]) ? driver_name : shift;
+ my $items = shift;
+
+ if ( $driver =~ /^mysql/i ) {
+ 'CONCAT('. join(',', @$items). ')';
+ } else {
+ join('||', @$items);
+ }
+
+}
+
=back
=head1 BUGS