Download the PHP package absorbing/cql-core without Composer

On this page you can find all versions of the php package absorbing/cql-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cql-core

CQL Core

Build Status Version PHP License

CQL (CSV Query Language) is a SQL-like query language designed specifically for querying and manipulating CSV files in PHP. It provides a familiar SQL syntax for filtering, joining, and transforming CSV data without requiring a database.

[!IMPORTANT] As of v0.2.0, CQL supports write operations (INSERT, UPDATE, DELETE) alongside queries. UPDATE and DELETE rewrite files atomically via a temporary file. See CHANGELOG.md for details.

Features

Requirements

Installation

Quick Start

Minimum Query

The simplest valid CQL query requires:

Complete Query

A query with all optional features:

Query Syntax

Language Reference

CQL queries follow a SQL-like syntax with specific requirements:

Component Required Description
DEFINE Yes At least one data source definition
SELECT Yes Column selection
FROM Yes Primary data source
WHERE No Filter conditions
JOIN No Join additional data sources
GROUP BY No Group rows for aggregation
AS No Aliases for tables and columns
INSERT INTO - Append rows to a data source
UPDATE ... SET - Modify rows in place (atomic rewrite)
DELETE FROM - Remove rows (atomic rewrite)

Query Structure:

Write Statement Structure:

Write statements return the number of affected rows:

UPDATE and DELETE rewrite the file through a temporary file in the same directory followed by an atomic rename, so a failure part-way through never corrupts the original. Large files are processed row-by-row using the same streaming rules as queries. INSERT appends under an exclusive flock.

CQL API

The CQL class provides a simple interface for executing queries:

DEFINE Statement

The DEFINE statement declares a CSV data source and assigns it an alias.

Syntax:

Parameters:

Parameter Required Description Default
'path/to/file.csv' Yes Path to CSV file (single or double quotes) -
AS alias No Table alias Auto-generated from filename
WITH HEADERS No CSV has header row -
WITHOUT HEADERS No CSV has no headers (generates column_1, column_2, etc.) Default if neither specified
COLUMNS (...) No Explicitly define column names Auto-generated or from headers

Examples:

Rules:

SELECT Statement

Select specific columns or use wildcards to select all columns.

Syntax:

Options:

Option Description Example
column Select specific column by name SELECT name
alias.column Select column with table qualifier SELECT users.name
* Select all columns from all tables SELECT *
alias.* Select all columns from specific table SELECT users.*
column AS alias Rename column in results SELECT name AS full_name

Examples:

Rules:

FROM Statement

Specify the primary data source for the query.

Syntax:

Parameters:

Parameter Required Description
alias Yes Must match a DEFINE alias

Examples:

Rules:

WHERE Clause

Filter rows based on conditions using comparison and logical operators.

Syntax:

Supported Operators:

Category Operator Description
Comparison = Equal
!=, <> Not equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
IN (...) Value list membership
NOT IN (...) Negated membership
Logical AND Logical AND
OR Logical OR
NOT Negate a condition or group
Existence EXISTS Value is present (not null, not empty string)
Mathematical + Addition
- Subtraction
* Multiplication
/ Division
% Modulus
^ Power (exponentiation)

Examples:

Conditions follow standard SQL precedence: OR binds loosest, then AND, then NOT, then comparison predicates. Use parentheses to override. Trailing tokens after a complete statement raise a SyntaxException rather than being silently ignored.

Rules:

Limitations:

JOIN Clause

Join multiple CSV files together.

Syntax:

Join Types:

Join Type Description
INNER JOIN (default) Returns rows with matches in both tables
LEFT JOIN Returns all rows from left table, matched rows from right
RIGHT JOIN Returns all rows from right table, matched rows from left

Parameters:

Parameter Required Description
right_alias Yes Alias of table to join (must be defined)
ON Yes Join condition keyword
left_alias.key Yes Column from left table
right_alias.key Yes Column from right table

Examples:

Rules:

Limitations:

Aggregate Functions

Perform calculations across multiple rows.

Syntax:

Supported Functions:

Function Description Example
COUNT(*) Count all rows COUNT(*) AS total
COUNT(column) Count non-null values COUNT(name) AS users
SUM(column) Sum of numeric values SUM(amount) AS total_sales
AVG(column) Average of numeric values AVG(price) AS avg_price
MIN(column) Minimum value MIN(age) AS youngest
MAX(column) Maximum value MAX(salary) AS highest_paid

Examples:

Rules:

Limitations:

Date Functions

Extract date components and perform date-based analysis.

Syntax:

Supported Functions:

Function Description Returns Example
YEAR(date) Extract year Integer (2024) YEAR(order_date)
MONTH(date) Extract month Integer (1-12) MONTH(order_date)
DAY(date) Extract day Integer (1-31) DAY(order_date)
DATE(date) Format as date String (YYYY-MM-DD) DATE(created_at)

Examples:

Rules:

Supported Date Formats:

Limitations

Not Yet Supported

The following SQL features are not currently implemented:

Aggregation:

Sorting & Limiting:

Advanced Filtering:

Data Modification:

Advanced Joins:

Other:

Workarounds

Many of these features can be implemented in PHP after querying:

Complete Examples

Example 1: Basic Filtering

Example 2: Joining Multiple Files

Example 3: Column Aliasing

Example 4: Mathematical Expressions

Example 5: Streaming Mode for Large Files

Architecture

CQL Core is built with a clean, modular architecture consisting of three main components:

1. Lexer (Tokenization)

Breaks down query strings into tokens (keywords, identifiers, operators, etc.)

2. Parser (Syntax Analysis)

Converts tokens into an Abstract Syntax Tree (AST) representing the query structure

3. Interpreter (Execution)

Executes the parsed query against CSV data sources and returns results

4. Data Layer

All of these components are accessed through the simple CQL facade class, which handles the entire pipeline automatically.

Exception Handling

CQL Core provides specific exceptions for different error scenarios:

Exception Purpose
DataSourceException CSV file errors (not found, permissions, format issues)
InterpreterException Execution errors (undefined aliases, ambiguous columns)
LexerException Tokenization errors
ParserException Parsing errors (unexpected tokens, malformed syntax)
SyntaxException Query syntax errors (invalid keywords, structure)

Advanced Usage

Custom Operators

Extend the operator system by implementing operator interfaces:

Working with Results

Results are returned as a Collection object with helpful methods:

Performance Considerations

Memory Management

CQL offers three modes for handling CSV files:

1. Normal Mode - Explicitly loads entire CSV into memory

2. Streaming Mode - Explicitly processes rows one at a time

3. Automatic Mode - Automatically selects based on file size

Mode Selection Examples:

Performance Comparison:

File Size Mode Memory Usage Speed
1000 rows (~22KB) Normal ~500 KB Fast
1000 rows (~22KB) Streaming ~0 KB Very Fast
100,000 rows (~2MB) Normal ~50 MB Fast
100,000 rows (~2MB) Streaming ~5 MB Fast
1,000,000 rows (~20MB) Normal ~500 MB Slow
1,000,000 rows (~20MB) Streaming ~50 MB Medium

Other Performance Tips

Limitations

Roadmap

Future features under consideration:

Testing

Run the test suite:

Run static analysis:

Run code style checks:

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Credits

Developed by the Absorbing team.

Support


All versions of cql-core with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package absorbing/cql-core contains the following files

Loading the files please wait ...