Skip to main content
FiQueLa provides several ways to open a file and obtain a query object. All approaches ultimately produce the same chainable query interface.
Use Stream\Provider::fromFile() to open a file. The format is detected from the file extension automatically, or you can pass an explicit Format enum.
use FQL\Enum;
use FQL\Stream;

// Format detected from extension
$xml = Stream\Provider::fromFile('just/a/path/to/whatever/file.xml');

// Explicit format
$xml = Stream\Provider::fromFile('just/a/path/to/whatever/file', Enum\Format::XML);

$query = $xml->query()
    ->selectAll()
    ->from('SHOP.SHOPITEM')
    ->where('EAN', Enum\Operator::EQUAL, '1234567891011')
    ->or('PRICE', Enum\Operator::LESS_THAN_OR_EQUAL, 200)
    ->orderBy('PRICE')->desc()
    ->limit(10);

FileQuery syntax

The FileQuery string is a compact notation used in fromFileQuery() and inside FQL FROM, JOIN, and INTO clauses.
format(pathToFile[, params]).path.to.data
PartDescription
formatFormat name written directly before the parenthesis: xml, json, csv, yaml, neon, ods, xls, dir
pathToFileFirst argument — a relative or absolute path to the file (unquoted)
paramsOptional additional arguments: positional ("value") or named (key: "value"). Cannot be mixed
path.to.dataDot-separated path to the data root within the file
Examples:
xml(feed.xml).SHOP.ITEM
csv(data.csv, "windows-1250", ";").*
csv(data.csv, encoding: "windows-1250", delimiter: ";").*
json(data.json).data.users

Default parameter values

Default values are omitted from the serialized output. For example, csv(data.csv) is equivalent to csv(data.csv, "utf-8", ",").
FormatParameterDefault
CSVencodingutf-8
CSVdelimiter,
XMLencodingutf-8

Querying from a string

You can also open an in-memory string rather than a file using Stream\Provider::fromString().
use FQL\Enum;
use FQL\Stream;

$json = Stream\Provider::fromString(
    '{"data":[{"id":3,"name":"Product"}]}',
    Enum\Format::JSON
);

$query = $json->query()
    ->selectAll()
    ->from('data');
All opening methods return the same Interface\Query object, so you can chain the same fluent methods regardless of how you opened the file.