2005-12-21 18:43:10 +00:00
|
|
|
;
|
|
|
|
; func_odbc.conf
|
|
|
|
;
|
|
|
|
; Each context is a separately defined function. By convention, all
|
|
|
|
; functions are entirely uppercase, so the defined contexts should also
|
|
|
|
; be all-uppercase, but there is nothing that enforces this. All functions
|
|
|
|
; are case-sensitive, however.
|
|
|
|
;
|
|
|
|
; For substitution, you have ${ARG1}, ${ARG2} ... ${ARGn}
|
|
|
|
; for the arguments to each SQL statement.
|
|
|
|
;
|
|
|
|
; In addition, for write statements, you have ${VAL1}, ${VAL2} ... ${VALn}
|
|
|
|
; parsed, just like arguments, for the values. In addition, if you want the
|
|
|
|
; whole value, never mind the parsing, you can get that with ${VALUE}.
|
2005-12-27 02:02:23 +00:00
|
|
|
;
|
|
|
|
;
|
|
|
|
; If you have data which may potentially contain single ticks, you may wish
|
|
|
|
; to use the dialplan function SQL_ESC() to escape the data prior to its
|
|
|
|
; inclusion in the SQL statement.
|
2006-12-28 20:13:00 +00:00
|
|
|
;
|
|
|
|
;
|
2009-01-29 16:48:25 +00:00
|
|
|
; The following options are available in this configuration file:
|
2006-12-28 20:13:00 +00:00
|
|
|
;
|
|
|
|
; readhandle A comma-separated list of DSNs (from res_odbc.conf) to use when
|
|
|
|
; executing the readsql statement. Each DSN is tried, in
|
|
|
|
; succession, until the statement succeeds. You may specify up to
|
|
|
|
; 5 DSNs per function class. If not specified, it will default to
|
|
|
|
; the value of writehandle or dsn, if specified.
|
|
|
|
; writehandle A comma-separated list of DSNs (from res_odbc.conf) to use when
|
|
|
|
; executing the writesql statement. The same rules apply as to
|
|
|
|
; readhandle. "dsn" is a synonym for "writehandle".
|
|
|
|
; readsql The statement to execute when reading from the function class.
|
|
|
|
; writesql The statement to execute when writing to the function class.
|
2008-10-31 17:18:49 +00:00
|
|
|
; insertsql The statement to execute when writing to the function class
|
|
|
|
; succeeds, but initially indicates that 0 rows were affected.
|
2006-12-28 20:13:00 +00:00
|
|
|
; prefix Normally, all function classes are prefixed with "ODBC" to keep
|
|
|
|
; them uniquely named. You may choose to change this prefix, which
|
|
|
|
; may be useful to segregate a collection of certain function
|
|
|
|
; classes from others.
|
|
|
|
; escapecommas This option may be used to turn off the default behavior of
|
|
|
|
; escaping commas which occur within a field. If commas are
|
|
|
|
; escaped (the default behavior), then fields containing commas
|
|
|
|
; will be treated as a single value when assigning to ARRAY() or
|
|
|
|
; HASH(). If commas are not escaped, then values will be separated
|
|
|
|
; at the comma within fields. Please note that turning this option
|
|
|
|
; off is incompatible with the functionality of HASH().
|
2009-01-29 16:48:25 +00:00
|
|
|
; synopsis Appears in the synopsis field for the command
|
|
|
|
; 'core show function <function name>'
|
|
|
|
; mode This option may be set to 'multirow' to allow the function
|
|
|
|
; specified to return more than a single row. However, this
|
|
|
|
; changes the way that func_odbc normally works. Instead of the
|
|
|
|
; invocation of the function returning a row, it returns an opaque
|
|
|
|
; ID, which may be passed to ODBC_FETCH() to return each row in
|
|
|
|
; turn. ODBC_FETCH_STATUS returns SUCCESS or FAILURE, to indicate
|
|
|
|
; whether any results were stored, and you should call ODBC_Finish
|
|
|
|
; on the ID to clean up any remaining results when you are done
|
|
|
|
; with the query. Also, the variable ODBCROWS is set initially,
|
|
|
|
; which may be used in an iterative fashion to return each row in
|
|
|
|
; the result.
|
|
|
|
; Please note that multirow queries are isolated to the channel,
|
|
|
|
; and rows may not be fetched outside of the channel where the
|
|
|
|
; query was initially performed. Additionally, as the results are
|
|
|
|
; associated with a channel, mode=multirow is incompatible with
|
|
|
|
; the global space.
|
|
|
|
; rowlimit An additional option for within mode=multirow, rowlimit limits
|
|
|
|
; the total number of rows which can be stored for that query.
|
|
|
|
; Otherwise, func_odbc will attempt to store all rows in the
|
|
|
|
; resultset, up to the maximum amount of memory.
|
2005-12-21 18:43:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
; ODBC_SQL - Allow an SQL statement to be built entirely in the dialplan
|
|
|
|
[SQL]
|
|
|
|
dsn=mysql1
|
2006-12-28 20:13:00 +00:00
|
|
|
readsql=${ARG1}
|
2005-12-21 18:43:10 +00:00
|
|
|
|
|
|
|
; ODBC_ANTIGF - A blacklist.
|
|
|
|
[ANTIGF]
|
2006-12-28 20:13:00 +00:00
|
|
|
dsn=mysql1,mysql2 ; Use mysql1 as the primary handle, but fall back to mysql2
|
2009-05-28 14:39:21 +00:00
|
|
|
; if mysql1 is down. Supports up to 5 comma-separated
|
|
|
|
; DSNs. "dsn" may also be specified as "readhandle" and
|
|
|
|
; "writehandle", if it is important to separate reads and
|
|
|
|
; writes to different databases.
|
2006-12-28 20:13:00 +00:00
|
|
|
readsql=SELECT COUNT(*) FROM exgirlfriends WHERE callerid='${SQL_ESC(${ARG1})}'
|
2008-10-02 17:16:54 +00:00
|
|
|
syntax=<callerid>
|
|
|
|
synopsis=Check if a specified callerid is contained in the ex-gf database
|
2005-12-21 18:43:10 +00:00
|
|
|
|
|
|
|
; ODBC_PRESENCE - Retrieve and update presence
|
|
|
|
[PRESENCE]
|
|
|
|
dsn=mysql1
|
2006-12-28 20:13:00 +00:00
|
|
|
readsql=SELECT location FROM presence WHERE id='${SQL_ESC(${ARG1})}'
|
|
|
|
writesql=UPDATE presence SET location='${SQL_ESC(${VAL1})}' WHERE id='${SQL_ESC(${ARG1})}'
|
2005-12-21 18:43:10 +00:00
|
|
|
|