|
@@ -11,7 +11,7 @@ Daniel-Constantin Mierla
|
|
|
|
|
|
<[email protected]>
|
|
<[email protected]>
|
|
|
|
|
|
- Copyright © 2008 http://www.asipto.com
|
|
|
|
|
|
+ Copyright © 2008 http://www.asipto.com
|
|
__________________________________________________________________
|
|
__________________________________________________________________
|
|
|
|
|
|
Table of Contents
|
|
Table of Contents
|
|
@@ -27,6 +27,7 @@ Daniel-Constantin Mierla
|
|
3. Exported Parameters
|
|
3. Exported Parameters
|
|
|
|
|
|
3.1. sqlcon (str)
|
|
3.1. sqlcon (str)
|
|
|
|
+ 3.2. sqlres (str)
|
|
|
|
|
|
4. Exported Functions
|
|
4. Exported Functions
|
|
|
|
|
|
@@ -40,9 +41,10 @@ Daniel-Constantin Mierla
|
|
List of Examples
|
|
List of Examples
|
|
|
|
|
|
1.1. Set sqlcon parameter
|
|
1.1. Set sqlcon parameter
|
|
- 1.2. sql_query() usage
|
|
|
|
- 1.3. sql_result_free() usage
|
|
|
|
- 1.4. $dbr(result=>key) usage
|
|
|
|
|
|
+ 1.2. Set sqlres parameter
|
|
|
|
+ 1.3. sql_query() usage
|
|
|
|
+ 1.4. sql_result_free() usage
|
|
|
|
+ 1.5. $dbr(result=>key) usage
|
|
|
|
|
|
Chapter 1. Admin Guide
|
|
Chapter 1. Admin Guide
|
|
|
|
|
|
@@ -57,6 +59,7 @@ Chapter 1. Admin Guide
|
|
3. Exported Parameters
|
|
3. Exported Parameters
|
|
|
|
|
|
3.1. sqlcon (str)
|
|
3.1. sqlcon (str)
|
|
|
|
+ 3.2. sqlres (str)
|
|
|
|
|
|
4. Exported Functions
|
|
4. Exported Functions
|
|
|
|
|
|
@@ -81,7 +84,7 @@ Chapter 1. Admin Guide
|
|
* access via pseudo-variables - the content of the SQL query result
|
|
* access via pseudo-variables - the content of the SQL query result
|
|
is accessible via pseudo-variables. Please note that only integer
|
|
is accessible via pseudo-variables. Please note that only integer
|
|
and string variables are supported at the moment because of the
|
|
and string variables are supported at the moment because of the
|
|
- internal usage of "AVPs" to hold the values. So its not possible
|
|
|
|
|
|
+ internal usage of “AVPs� to hold the values. So it is not possible
|
|
for example to return floating point or big integer values this
|
|
for example to return floating point or big integer values this
|
|
way.
|
|
way.
|
|
* array indexes - fast access to result values via array position:
|
|
* array indexes - fast access to result values via array position:
|
|
@@ -108,6 +111,7 @@ Chapter 1. Admin Guide
|
|
3. Exported Parameters
|
|
3. Exported Parameters
|
|
|
|
|
|
3.1. sqlcon (str)
|
|
3.1. sqlcon (str)
|
|
|
|
+ 3.2. sqlres (str)
|
|
|
|
|
|
3.1. sqlcon (str)
|
|
3.1. sqlcon (str)
|
|
|
|
|
|
@@ -118,7 +122,7 @@ Chapter 1. Admin Guide
|
|
This parameter may be set multiple times to get many DB connections in
|
|
This parameter may be set multiple times to get many DB connections in
|
|
the same configuration file.
|
|
the same configuration file.
|
|
* connection_name - string specifying the name of a DB connection.
|
|
* connection_name - string specifying the name of a DB connection.
|
|
- This string is used by the "sql_query()" function to refer to the
|
|
|
|
|
|
+ This string is used by the “sql_query()� function to refer to the
|
|
DB connection.
|
|
DB connection.
|
|
* database_url - Standardized database URL used to connect to
|
|
* database_url - Standardized database URL used to connect to
|
|
database.
|
|
database.
|
|
@@ -131,16 +135,31 @@ modparam("sqlops","sqlcon","cb=>mysql://openser:[email protected]/testdb")
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
...
|
|
...
|
|
|
|
|
|
|
|
+3.2. sqlres (str)
|
|
|
|
+
|
|
|
|
+ The definition of a DB result ID. The value of the parameter can be any
|
|
|
|
+ string. Results IDs are also added at fixup time when sql_query()
|
|
|
|
+ parameters are parsed, there is no need to decalare them via module
|
|
|
|
+ parameter unless you want to use them from within other modules and be
|
|
|
|
+ available in all application processes.
|
|
|
|
+
|
|
|
|
+ Default value is NULL.
|
|
|
|
+
|
|
|
|
+ Example 1.2. Set sqlres parameter
|
|
|
|
+...
|
|
|
|
+modparam("sqlops", "sqlres", "ra")
|
|
|
|
+...
|
|
|
|
+
|
|
4. Exported Functions
|
|
4. Exported Functions
|
|
|
|
|
|
4.1. sql_query(connection, query, result)
|
|
4.1. sql_query(connection, query, result)
|
|
4.2. sql_result_free(result)
|
|
4.2. sql_result_free(result)
|
|
|
|
|
|
-4.1. sql_query(connection, query, result)
|
|
|
|
|
|
+4.1. sql_query(connection, query, result)
|
|
|
|
|
|
Make a SQL query using 'connection' and store data in 'result'.
|
|
Make a SQL query using 'connection' and store data in 'result'.
|
|
* connection - the name of the connection to be used for query
|
|
* connection - the name of the connection to be used for query
|
|
- (defined via the "sqlcon" parameter).
|
|
|
|
|
|
+ (defined via the “sqlcon� parameter).
|
|
* query - SQL query string or pseudo-variables containing SQL query.
|
|
* query - SQL query string or pseudo-variables containing SQL query.
|
|
* result - string name to identify the result. Will be used by
|
|
* result - string name to identify the result. Will be used by
|
|
$dbr(...) pseudo-variable to access result attributes.
|
|
$dbr(...) pseudo-variable to access result attributes.
|
|
@@ -148,7 +167,7 @@ modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
|
|
ONREPLY_ROUTE, BRANCH_ROUTE.
|
|
ONREPLY_ROUTE, BRANCH_ROUTE.
|
|
|
|
|
|
- Example 1.2. sql_query() usage
|
|
|
|
|
|
+ Example 1.3. sql_query() usage
|
|
...
|
|
...
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
...
|
|
...
|
|
@@ -157,14 +176,14 @@ xlog("number of rows in table domain: $dbr(ra=>rows)\n");
|
|
sql_result_free("ra");
|
|
sql_result_free("ra");
|
|
...
|
|
...
|
|
|
|
|
|
-4.2. sql_result_free(result)
|
|
|
|
|
|
+4.2. sql_result_free(result)
|
|
|
|
|
|
Free data in SQL 'result'.
|
|
Free data in SQL 'result'.
|
|
|
|
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
|
|
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE,
|
|
ONREPLY_ROUTE, BRANCH_ROUTE.
|
|
ONREPLY_ROUTE, BRANCH_ROUTE.
|
|
|
|
|
|
- Example 1.3. sql_result_free() usage
|
|
|
|
|
|
+ Example 1.4. sql_result_free() usage
|
|
...
|
|
...
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
...
|
|
...
|
|
@@ -182,10 +201,10 @@ sql_result_free("ra");
|
|
|
|
|
|
Access hash table entries.
|
|
Access hash table entries.
|
|
|
|
|
|
- The "result" must be the name identifying a SQL result (third parameter
|
|
|
|
|
|
+ The “result� must be the name identifying a SQL result (third parameter
|
|
of sql_query(...)).
|
|
of sql_query(...)).
|
|
|
|
|
|
- The "key" can be:
|
|
|
|
|
|
+ The “key� can be:
|
|
* rows - return the number of rows in query result
|
|
* rows - return the number of rows in query result
|
|
* cols - return the number of columns in the result.
|
|
* cols - return the number of columns in the result.
|
|
* [row,col] - return the value at position (row,col) in the result
|
|
* [row,col] - return the value at position (row,col) in the result
|
|
@@ -193,7 +212,7 @@ sql_result_free("ra");
|
|
integer.
|
|
integer.
|
|
* colname[N] - return the name of the N-th column in the result set.
|
|
* colname[N] - return the name of the N-th column in the result set.
|
|
|
|
|
|
- Example 1.4. $dbr(result=>key) usage
|
|
|
|
|
|
+ Example 1.5. $dbr(result=>key) usage
|
|
...
|
|
...
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
modparam("sqlops","sqlcon","ca=>dbdriver://username:password@dbhost/dbname")
|
|
...
|
|
...
|