Project

General

Profile

« Previous | Next » 

Revision 9468

lib/sh/db.sh: added mk_select() and use it in mk_select_var

View differences:

db.sh
27 27
	echo -n "${limit:+${prefix}LIMIT $limit}"
28 28
}
29 29

  
30
# export func usage: export_func() { ...; mk_select_var; ... }
31
# caller usage: {query=... | table=... [cols=...] [filter=...]} export_func
32
# cmd line usage: [limit=...] caller
33
alias mk_select_var='mk_table_esc
34
declare query="$(rtrim "${query:-SELECT ${cols:-*} ${cols:+
30
mk_select() # usage: {query=... | table=... [cols=...] [filter=...]} mk_select
31
{
32
	echo_func; kw_params query table cols filter; mk_table_esc
33
	echo "$(rtrim "${query:-SELECT ${cols:-*} ${cols:+
35 34
}FROM $table_esc
36 35
${filter:+WHERE $filter
37 36
}}")\
38 37
$(limit)"
39
'
38
}
40 39

  
40
# export func usage: export_func() { ...; mk_select_var; ... }
41
# caller usage: {query=... | table=... [cols=...] [filter=...]} export_func
42
# cmd line usage: [limit=...] caller
43
alias mk_select_var='declare query="$(mk_select)"'
44

  
41 45
fi # load new aliases
42 46
if self_being_included; then
43 47

  

Also available in: Unified diff