X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=cf0ac3b2ff5ac233721acdbb69c59e78a1a4df5d;hb=d5de3968350034bfc4b9e1c3fb163e6ee1ca5fb5;hp=f0026d5d2c8ad3631fb5703b6624e1449b75cc2e;hpb=b8cfd0780aa40bb07f3215bf9cb58011f5e32a35;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index f0026d5d2..cf0ac3b2f 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -180,7 +180,7 @@ sub create { } } -=item qsearch TABLE, HASHREF, SELECT, EXTRA_SQL, CACHE_OBJ +=item qsearch TABLE, HASHREF, SELECT, EXTRA_SQL, CACHE_OBJ, AS Searches the database for all records matching (at least) the key/value pairs in HASHREF. Returns all the records found as `FS::TABLE' objects if that @@ -199,7 +199,7 @@ objects. =cut sub qsearch { - my($stable, $record, $select, $extra_sql, $cache ) = @_; + my($stable, $record, $select, $extra_sql, $cache, $as ) = @_; #$stable =~ /^([\w\_]+)$/ or die "Illegal table: $table"; #for jsearch $stable =~ /^([\w\s\(\)\.\,\=]+)$/ or die "Illegal table: $stable"; @@ -223,6 +223,7 @@ sub qsearch { } my $statement = "SELECT $select FROM $stable"; + $statement .= " AS $as" if $as; if ( @real_fields or @virtual_fields ) { $statement .= ' WHERE '. join(' AND ', ( map { @@ -1424,7 +1425,7 @@ on the column first. sub ut_foreign_key { my( $self, $field, $table, $foreign ) = @_; qsearchs($table, { $foreign => $self->getfield($field) }) - or return "Can't find $field ". $self->getfield($field). + or return "Can't find ". $self->table. ".$field ". $self->getfield($field). " in $table.$foreign"; ''; }