77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/cuca/stdlib/listwidget/dblist.rb', line 77
def query(query_def)
findstuff = {:conditions => where_clause(query_def) }
findstuff[:order] = "#{query_def.order_by} #{query_def.order}" unless (query_def.order_by.nil? || query_def.order_by == '')
findstuff[:offset] = query_def.range.first
findstuff[:limit] = query_def.range.last-query_def.range.first+1
findstuff[:joins] = @joins || nil
findstuff[:group] = @group_by if @group_by.to_s != ''
sel = @query_columns.collect do |c|
ret = c.has_key?(:query) ? "#{c[:query]} as #{c[:id]}" : c[:id]
ret = nil if c[:query] == false
ret
end
findstuff[:select] = sel.compact.join(',')
@data = @model_class.find(:all, findstuff)
@additional_data = @data.dup
rowcount_findstuff = findstuff.dup
rowcount_findstuff.delete(:limit)
rowcount_findstuff.delete(:offset)
rowcount_findstuff.delete(:order)
@data = normalize_result(@data)
@total_rows= @model_class.count(rowcount_findstuff)
if @total_rows.kind_of?(Hash) then
@total_rows = @total_rows.size
end
end
|