This class has no constructor, so such an object
cannot be created or used on its own. A datasource
only is only useful as part of a report. The
OpenCReport::datasource_add()
method return an object of this class.
class OpenCReport\Datasource { public final free(): void; public final query_add(string $name, string $array_or_file_or_sql, ?string $coltypes = null): OpenCReport\Query; public final set_encoding(string $encoding): void; }
The datasource is freed for the
parent OpenCReport
object.
public final OpenCReport\Datasource::free(): void;
Add a query to the parent
OpenCReport
object
associated with the
OpenCReport\Datasource
.
public final OpenCReport\Datasource::query_add(string $name, string $array_or_file_or_sql, ?string $coltypes = null): OpenCReport\Query;
$name
is the query name
that Expressions may use
as the identifier domain.
$array_or_file_or_sql
contains the array name (for an array datasource),
the file name (for a file based datasource,
like JSON, CSV or XML), or the SQL query statement
for SQL based datasources (like MariaDB, PostgreSQL
or ODBC).
Passing $coltypes
is
optional and is only valid for array or
file based datasources. File based datasources
may or may not include column type specification.
Array datasources don't. The $coltypes
array contains long values
OpenCReport::RESULT_*
.
See The OpenCReport class. It helps
the engine to add automatic data conversion
for query column data.
SQL based datasources provide the data type
for query columns.
Set encoding for the datasource. By default, UTF-8 is expected.
public final OpenCReport\Datasource::set_encoding(string $encoding): void;