Download the PHP package luany/database without Composer

On this page you can find all versions of the php package luany/database. 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 database

luany/database

PDO connection, fluent Query Builder, Active Record ORM, Relations, Pagination, Soft Deletes, Migration engine, and Seeders for the Luany ecosystem.

Version: v1.1.0  |  PHP: >= 8.2  |  License: MIT Author: António Ambrósio Ngola  |  Org: luany-ecosystem


Table of Contents

  1. Installation
  2. Connection
  3. QueryBuilder
    • Fluent API
    • Aggregates
    • Pagination
    • Raw Methods
  4. Model
    • Defining a Model
    • CRUD
    • Relationships
    • Eager Loading
    • Soft Deletes
  5. Transactions
  6. Migrations
  7. Seeders
  8. Changelog

1. Installation


2. Connection

Connection is a PDO wrapper. It does not enforce a singleton — that responsibility belongs to the application's DatabaseServiceProvider.

Connection Methods

Method Signature Description
make static make(array $config): static Create from config array
fromPdo static fromPdo(\PDO $pdo): static Wrap an existing PDO
getPdo getPdo(): \PDO Get the underlying PDO
execute execute(string $sql, array $bindings = []): \PDOStatement Prepare and execute
lastInsertId lastInsertId(): string Last inserted row ID
beginTransaction beginTransaction(): bool Begin a transaction
commit commit(): bool Commit the transaction
rollBack rollBack(): bool Roll back the transaction
transaction transaction(callable $callback): mixed Execute callback in a transaction
inTransaction inTransaction(): bool Whether inside a transaction

3. QueryBuilder

Fluent query builder with full prepared-statement safety. All user-supplied values are bound — never interpolated.

3.1 Fluent API

SELECT

WHERE Clauses

ORDER BY, LIMIT, OFFSET

INSERT

UPDATE

DELETE

3.2 Aggregates

3.3 Pagination

paginate() executes two queries: one COUNT(*) to get the total, one SELECT with LIMIT/OFFSET for the page data. All WHERE and ORDER BY clauses are respected by both queries.

Edge cases handled:

3.4 Raw Methods

Available for backward-compatibility and complex queries that the fluent API cannot express.


4. Model

Model is an abstract Active Record base class. Extend it to define your application models.

4.1 Defining a Model

Register the connection (done once in your DatabaseServiceProvider):

4.2 CRUD

4.3 Relationships

Define relationship methods on your model. They return Relation descriptor objects — no query is executed when the method is called. The query runs only on property access (lazy) or via with() (eager).

hasOne — one-to-one (FK on related table)

hasMany — one-to-many (FK on related table)

belongsTo — inverse (FK on THIS table)

Key signatures:

All FK/owner-key arguments are optional. Defaults follow the convention {table_singular}_id (e.g. users → user_id). Pass explicit keys for irregular plurals or non-standard schemas.

Relation results are cached after the first access:

Manual relation management:

4.4 Eager Loading

Prevents N+1 queries. Instead of executing one query per model, with() executes one batched WHERE IN query per relation for the entire collection.

with() returns an EagerProxy that delegates to all() and find(). After execution, the eager-load state is consumed and reset — no cross-request leakage.

4.5 Soft Deletes

Add the SoftDeletes trait to a model. Requires a deleted_at DATETIME DEFAULT NULL column.

Migration:

Behaviour:


5. Transactions


6. Migrations

Migrations live in database/migrations/ and are ordered by filename timestamp.

Defining a Migration

MigrationRunner

The _migrations table is created automatically on first use.


7. Seeders

Seeders live in database/seeders/ and populate the database with initial or test data.

Defining a Seeder

DatabaseSeeder — entry point

DatabaseSeeder is the root seeder. It chains other seeders via $this->call():

All classes referenced via call() are loaded automatically before any seeder runs — no manual require needed.

SeederRunner

SeederRunner loads all PHP files in the seeders directory before executing — call() chains always resolve regardless of file order.

Seeder base class

Method Description
run(\PDO $pdo): void Abstract — implement your insert logic here
call(string ...$classes): void Chain one or more seeders. All receive the same PDO instance.

8. Changelog

v1.1.0 — Seeders

New — src/Seeder/Seeder.php

New — src/Seeder/SeederRunner.php

Tests added: SeederRunnerTest (9 tests)
Total: 178 → 187 tests, 284 → 296 assertions — all green.


v0.3.0 — Phase 3: Relations, Eager Loading, Pagination, Soft Deletes

New — src/Relations/

New — src/Concerns/SoftDeletes.php

New — src/EagerProxy.php

New — src/PaginationResult.php

Modified — src/QueryBuilder.php

Modified — src/Model.php

Tests added: RelationsTest (15), EagerLoadTest (13), PaginateTest (27), SoftDeletesTest (21)
Total: 170 tests, 274 assertions — all green.


v0.2.0 — Phase 1: Fluent QueryBuilder & Transactions

New — QueryBuilder fluent API

New — Connection transaction methods

New — Connection::fromPdo() and Connection::make()

Modified — Model

Tests: 94 tests, 136 assertions.


v0.1.3 and earlier

Initial release. Raw-query-only QueryBuilder. Basic Model with hand-built SQL strings. MigrationRunner, MigrationRepository, Migration base class.


All versions of database with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
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 luany/database contains the following files

Loading the files please wait ...