sqlite_create_function
Register an user defined function.
Syntax
$sqlite_create_function ( conn, func_name, func_alias [, num_args [, prop ] ] )
/sqlite_create_function conn func_name func_alias [ num_args [ prop ] ] |
Parameters
conn
The connection identifier.
func_name
The SQL function name to register.
func_alias
The mIRC alias to register as function.
num_args
The number of arguments the function accepts. Optional.
prop
A custom property you want to use with alias name. Optional.
Return Value
1 if the function was registered successfully, or $null if there was an error.
Remarks
$sqlite_create_function allows users to register their own functions in SQL.You can also use $sqlite_create_function to override default functionality of SQLite's core functions.
The optional argument num_args can be used to hint SQLite if there's a predetermined amount of arguments.
If an user defined function is used with different parameter count as what was instructed with num_args, the query will raise an SQL error.
The default, -1, means that an arbitrary number of parameters can be passed to the function.
It is usually ok to ignore the return value of $sqlite_create_function if you know that the parameters are valid.
For more information about user defined functions, see User Defined Functions.
Example
; Returns a specified amount of characters from left side of a md5 generated string
alias md5_left { var %str = $1, %len = $2 return $left($md5(%str), %len) } ; Registers the user defined function in an existing connection %db sqlite_create_function %db md5_left md5_left 2 ; Registers mIRC's $base as convert_base (3 first parameters, no zeropadding or precision) sqlite_create_function %db convert_base base 3 ; Example queries ; SELECT md5_left(value, 8) FROM strings ; SELECT convert_base(15, 10, 16) |