These functions mimic the behaviour
of the RLIB PHP API but their declaration
differ in a way that the RLIB compatibility
API in OpenCReports create and use
OpenCReport
objects,
making the OpenCReports methods and
RLIB compatibility functions inter-operable.
function rlib_init(): ?OpenCReport;
Note that initializing the report using this function automatically enables some RLIB compatibility settings, like the output parameter "xml_rlib_compat".
function rlib_add_datasource_mysql( OpenCReport $r, string $source_name, string $host, string $user, string $password, string $dbname): OpenCReport\Datasource;
This function is equivalent to using
OpenCReport::datasource_add()
with the MariaDB input driver with expanded connection
parameters, but without specifying a custom port:
$o = new OpenCReport(); $conn_params = [ "host" => "myserver", "dbname" => "ocrpttest", "user" => "ocrpt" ]; $ds = $o->datasource_add("mariadb", "mariadb", $conn_params);
function rlib_add_datasource_mysql_from_group( OpenCReport $r, string $source_name, string $group, ?string $option_file = null): OpenCReport\Datasource;
This function is equivalent to using
OpenCReport::datasource_add()
with MariaDB input driver, using the option file and
group parameters:
$o = new OpenCReport(); $conn_params = [ "optionfile" => "./mariadb/ocrpt.cnf", "group" => "ocrpt" ]; $ds = $o->datasource_add("mariadb", "mariadb", $conn_params);
function rlib_add_datasource_postgres( OpenCReport $r, string $source_name, ?string $connection_info = null): OpenCReport\Datasource;
This function is equivalent to using
OpenCReport::datasource_add()
with the PostgreSQL input driver using
the connection info string:
$o = new OpenCReport(); $conn_params = [ "connstr" => "dbname=ocrpttest user=ocrpt" ]; $ds = $o->datasource_add("pgsql", "postgresql", $conn_params);
function rlib_add_datasource_odbc( OpenCReport $r, string $source_name, string $dbname, ?string $user, = null, ?string $password = null): OpenCReport\Datasource;
This function is equivalent to using
OpenCReport::datasource_add()
with the ODBC input driver with expanded connection
parameters:
$o = new OpenCReport(); $conn_params = [ "dbname" => "mydb", "user" => "myuser" ]; $ds = $o->datasource_add("odbc", "odbc", $conn_params);
function rlib_add_datasource_array( OpenCReport $r, string $source_name): OpenCReport\Datasource;
This function is equivalent to using
OpenCReport::datasource_add()
with the array input driver:
$o = new OpenCReport(); $ds = $o->datasource_add("array", "array");
function rlib_add_datasource_xml( OpenCReport $r, string $source_name): OpenCReport\Datasource;
This function is equivalent to using
OpenCReport::datasource_add()
with the XML input driver:
$o = new OpenCReport(); $ds = $o->datasource_add("xml", "xml");
function rlib_add_datasource_csv( OpenCReport $r, string $source_name): OpenCReport\Datasource;
This function is equivalent to using
OpenCReport::datasource_add()
with the CSV input driver:
$o = new OpenCReport(); $ds = $o->datasource_add("csv", "csv");
This function is equivalent to
OpenCReport\Datasource::query_add()
with a different order of parameters.
The query name is the last parameter.
function rlib_add_query_as( OpenCReport $r, string $source_name, string $array_or_file_or_sql, string $name): OpenCReport\Datasource;
This function is about equivalent to
OpenCReport\Query::add_follower()
.
The $leader
and
$follower
are query
names.
function rlib_add_resultset_follower( OpenCReport $r, string $leader, string $follower): bool;
This function is about equivalent to
OpenCReport\Query::add_follower_n_to_1()
.
The former allows an arbitrary match expression,
while the RLIB compatibility function
will use the $leader_field = $follower_field
expression. Similarly to the above
function, $leader
and
$follower
are query
names.
function rlib_add_resultset_follower_n_to_1( OpenCReport $r, string $leader, string $leader_field, string $follower, string $follower_field): bool;
This function is equivalent to
OpenCReport\Datasource::set_encoding()
.
See Section 12.5.3
function rlib_set_datasource_encoding( OpenCReport $r, string $name, string $encoding): void;
This function is equivalent to
OpenCReport::parse_xml()
.
function rlib_add_report( OpenCReport $r, string $filename): bool;
This function is equivalent to
OpenCReport::parse_xml_from_buffer()
.
function rlib_add_report_from_buffer( OpenCReport $r, string $buffer): bool;
This function is equivalent to
OpenCReport::add_search_path()
.
function rlib_add_search_path( OpenCReport $r, string $path): bool;
This function is equivalent to
OpenCReport::set_locale()
.
function rlib_set_locale( OpenCReport $r, string $locale): void;
This function is equivalent to
OpenCReport::bindtextdomain()
.
function rlib_bindtextdomain( OpenCReport $r, string $domain, string $dirname): void;
This function is about equivalent to
OpenCReport::set_output_format()
but accepts textual format names (like
pdf
instead of the
numeric constants like OpenCReport::OUTPUT_PDF
function rlib_set_output_format_from_text( OpenCReport $r, string $format): void;
This function is the RLIB compatible
variant of OpenCReport::function_add()
.
Unlike the OpenCReports API, the function
added by this function does not have
the control knobs to optimize it properly.
After this function returns, subsequently
parsed expressions may use a function
name passed in with $name
.
The PHP function name is in $function
function rlib_add_function( OpenCReport $r, string $name, string $function, long $params): void;
The interface of the PHP function must follow the
below prototype. It must contain the exact number
of arguments passed in via $params
,
i.e. it may not pass -1
to indicate
variadic arguments.
function my_function($arg1, $arg2, ...)
The function implementation may return
any PHP base type (string
,
long
, double
or bool
).
This function silently does nothing. For PDF, it's not relevant. Other (CURRENTLY NOT IMPLEMENTED) output formats will all use UTF-8.
function rlib_set_output_encoding( OpenCReport $r, string $encoding): void;
This function is equivalent to OpenCReport::set_mvariable().
function rlib_add_parameter( OpenCReport $r, string $param, ?string $value = null): void;
Set output parameters for the report. For accepted parameters, see Section 12.3.6
function rlib_set_output_parameter( OpenCReport $r, string $param, string $value): void;
This function is equivalent to executing OpenCReport::query_refresh(). The same limitations apply.
function rlib_query_refresh(OpenCReport $r): void;
This function adds a callback for
the specified $signal
in an RLIB compatible way. The signal
name may be row_change
,
report_done
,
report_start
,
report_iteration
,
part_iteration
or
precalculation_done
.
function rlib_signal_connect( OpenCReport $r, string $signal, string $function): void;
The PHP function prototype must follow this:
function my_callback()
This function is different from the
methods that add specific callback
types for parts, reports, breaks, etc.
in that the callback is added to the toplevel
OpenCReport
object context,
meaning that a report_start
callback will be called for every report
in case there are multiple reports in the same
context. Similarly, the same
part_iteration
callback
will be called for every part in a multi-part
report.
Since there is no way to know which part or
which report triggers the callback, it is recommended
to use rlib_signal_connect()
for single-part single-report reports. For
more special purposes, the callback creation
class methods are recommended.
It is equivalent to OpenCReport::execute()
function rlib_execute(OpenCReport $r): bool;
It is equivalent to OpenCReport::spool()
function rlib_spool(OpenCReport $r): ?string;
It is equivalent to OpenCReport::get_content_type()
function rlib_get_content_type(OpenCReport $r): ?string;
This function silently does nothing. Formatting numbers correctly follow the locale information regarding the decimal separator.
function rlib_set_radix_character(OpenCReport $r): void;
function rlib_compile_infix(string $expr_string): string|double|null;
Since only the expression string is passed
but not the $r
resource
in RLIB, the compatibility implementation
of this function is equivalent to the
sequence of creating an internal
OpenCReport
object,
parsing, optimizing and evaluating the
expression, converting its result to
a PHP base type, then destroying the
internal object. For this reason, the
expression may not reference any query
columns or report variables.
This function silently does nothing. GRAPHING IS NOT IMPLEMENTED YET.
function rlib_graph_add_bg_region( OpenCReport $r, string $graph, string $region, string $color, double $start, double $end): void;
This function silently does nothing. GRAPHING IS NOT IMPLEMENTED YET.
function rlib_graph_clear_bg_region( OpenCReport $r, string $graph): void;
This function silently does nothing. GRAPHING IS NOT IMPLEMENTED YET.
function rlib_graph_set_x_minor_tick( OpenCReport $r, string $graph, string $x): void;
This function silently does nothing. GRAPHING IS NOT IMPLEMENTED YET.
function rlib_graph_set_x_minor_tick_by_location( OpenCReport $r, string $graph, double $location): void;