Documentation API PHP
From RLIB
rlib_init
$rlib = rlib_init();
Start RLIB.
Returns a pointer to an rlib instance.
rlib_add_datasource_mysql
rlib_add_datasource_mysql(rlib rlib, string datasource_name, string hostname, string username, string password, string database)
Add a mysql datasource. The datasource_name is used in rlib_add_query_as to tell rlib which
datasource to run the query with.This function is only available if rlib is compiled with mysql support.
rlib_add_datasource_postgre
rlib_add_datasource_postgre(rlib, datasource_name, connection_string)
Add a postgre datasource. The datasource_name is used in rlib_add_query_as to tell rlib which
datasource to run the query with. The connection_string is the standard postgre connection
string.. which might contain user and password information, among other things.
This function is only available if rlib is compiled with postgre support.
rlib_add_datasource_odbc
rlib_add_datasource_odbc(rlib, datasource_name, user_name, password)
Add a odbc datasource. The datasource_name is used in rlib_add_query_as to tell rlib which
datasource to run the query with. The user name and password are that of your database you
are connecting to
This function is only available if rlib is compiled with odbc support.
rlib_add_datasource_xml
rlib_add_datasource_xml(rlib * rlib_ptr, datasource_name)
Adds a XML datasource to RLIB. Pass XML files to rlib instead of queries.
rlib_add_query_as
rlib_add_query_as(rlib, datasource_name, query, rlib_query_name)
The query is added to an execution queue, but it is not executed at this time. The name is important
because you can reference result sets directly in your rlib xml files. The first query added
is assumed to be the main loop query. The datasource name must match a datasource the your
provided rlib, such as one of the mysql or postgre datasources.
rlib_add_report
rlib_add_report(rlib, rlib_xml_file)
rlib_add_report_from_buffer
rlib_add_report_from_buffer(rlib, xml_in_memory)
A report is added to the report execution queue but not compiled at this time.
rlib_set_output_format_from_text
rlib_set_output_format_from_text
rlib_set_output_format_from_text(rlib, type)
Type can be one of the following: html, pdf, txt, or csv.
rlib_execute
rlib_execute(rlib)
Connects to the database, runs queries, compiles xmls and buffers up a report.
rlib_get_content_type
rlib_get_content_type(rlib)
This will return a string content type Use it with the php header function. Even if you ask for a
PDF you might not get a PDF because errors might occur. If this is the case, rlib defaults to html
and sends out error messages.
rlib_signal_connect
rlib_signal_connect(rlib,signal_number, callback_function)
Connect a user callback function to a RLIB Signal. This is usally to manuipulate data and then
refresh the datasource.
rlib_signal_connect_string
rlib_signal_connect(rlib, signal_name, callback_function)
Connect a user callback function to a RLIB Signal. This is usally to manuipulate data and then
refresh the datasource.
rlib_query_refresh
rlib_query_refresh(rlib)
Causes RLIB to refresh all queries and put the row pointer back at the 1st row.
rlib_set_output_parameter
rlib_set_output_parameter(rlib, parameter, value)
Set an output paramteter.
SEE Output Control.
rlib_spool
rlib_spool(rlib)
Rlib will send the output out stdout.
rlib_add_parameter
int rlib_add_parameter(rlib, namestring, valuestring)
Adds the name/value pair to the memory parameters. Values added in this manner supercede
values passed in the environment. The names are searched in a case sensitive manner.
rlib_free
rlib_free(rlib)
Free rlib’s memory that it allocated
rlib_add_resultset_follower
rlib_add_resultset_follower(rlib, leader, follower)
Adds the ability to have more then one main loop query. leader and follower are the names of
the queries you set in rlib_add_query_as.
Example:
rlib_add_resultset_follower($rlib, 'leader', 'follower');
rlib_add_resultset_follower_n_to_1
rlib_add_resultset_follower(rlib, leader, leader_field, follower, follower_field)
Adds the ability to have more then one main loop query. leader and follower are the names of
the queries you set in rlib_add_query_as. The leader_fields and follower_fields are normal RLIB
expressions. Use this feature when the rows in the datasets are uneven and needs to be linked
together using a common criteria.
rlib_version
rlib_version()
Returns a string containing the RLIB version number or the libarary.
rlib_set_output_encoding(rlib, encodingstring)
Sets the output character encoding, overriding any encoding that is set in the current Locale.
By default RLIB will use the character encoding indicated in the current Locale settings. All
reports will use this encoding unless overriden by a call to rlib_set_report_output_encoding. If
the encoding is NULL, or a null string, the output will be left in UTF-8 encoding.
rlib_set_report_output_encoding
rlib_set_report_output_encoding(rlib, reportnumber, encodingstring)
Sets the output character encoding for the indicated report. This setting will override the default
setting. If this is not set or encoding is NULL or a null string, the default rlib encoding is used.
rlib_set_datasource_encoding
rlib_set_datasource_encoding(rlib, input_name, encoding)
Sets the output character encoding, overriding any encoding that is set in the current Locale.
By default RLIB will use the character encoding indicated in the current Locale settings. All
reports will use this encoding unless overriden by a call to rlib_set_report_output_encoding. If
the encoding is NULL, or a null string, the output will be left in UTF-8 encoding.
rlib_set_locale
rlib_set_locale(rlibr, locale string)
Sets the locale to the passed locale. The locale must be one of the values returned by the shell
command: locale -a. Returns true if the locale was successfully set.
rlib_add_function
rlib_add_function(rlibr, rlib_function_name, php_function_name, param count)
This function will add a PHP function to Rlib such that the function may be used in the XML report definition.
Example of a function definition:
function format_time($p_minutes) {
$t = $p_minutes;
return sprintf("%02d:%02d",$t/60,$t%60);
}
The input is an integer number of minutes to be formatted. The output from this function is a string that contains the time formatted as "hh:mm". The returned strings use will be defined in the XML.
Example of the PHP code:
rlib_add_function($rlibr, "format_time", "format_time", 1)
Example if the functions use within the XML file:
<Line>
<literal width="14" />
<field value="format_time(v.ttl_wrk)" format="'%s'" width="9" align="right" />
</Line>
