Download the PHP package frootbox/db without Composer

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

Frootbox Db

Frootbox Db is a small PHP database abstraction and Active Record layer for MySQL. It wraps PDO, provides a lightweight query builder, maps result rows to row objects, and offers a migration path from dynamic Active Record accessors to explicit getter and setter methods.

The package is intentionally compact. It is useful when you want simple models and rows without adopting a full ORM.

Installation

Install the package with Composer:

Requirements:

Creating A Connection

Create a DBMS adapter and wrap it in Frootbox\Db\Db:

Db exposes low-level methods such as query(), prepare(), fetch(), update(), delete(), and transaction helpers.

Rows

A row represents one database record. Extend Frootbox\Db\Row for your entities:

Rows store their raw database values internally and track changed attributes. Call save() to persist changed values and delete() to remove the record.

Legacy Dynamic Accessors

Older projects can still call accessors that are not explicitly defined:

These calls are handled by Row::__call() for backward compatibility. New code should add explicit methods that delegate to getAttribute() and setAttribute(). Deprecated dynamic calls are logged once per call site by default.

Disable that logging when needed:

Models

A model acts as a repository for one table:

Fetch rows:

Fetch one row:

Insert a row:

insert() is still available as a deprecated alias for persist().

Conditions

Condition objects can be used in where arrays for comparisons beyond equality:

Available conditions include:

Results

Frootbox\Db\Result is an iterator, Countable, and JsonSerializable. It lazily converts raw database records into row objects while iterating.

Useful helpers:

Nested Sets

The package includes optional nested-set base classes:

They provide helpers such as appendChild(), getChildren(), getParent(), getTrace(), getSiblings(), and rewriteIds().

Generating Explicit Accessors

The package ships a Composer binary:

Generate missing getter and setter methods for existing row classes:

When the command is run from a project root containing localconfig.php, it automatically reads the database connection from:

Use a custom config path when needed:

Alternatively, a bootstrap file can return a Frootbox\Db\Db instance, or an array with a db key:

You can also pass connection details directly:

Preview changes without writing files:

The generator scans concrete classes extending Frootbox\Db\Row, reads their protected $table value, loads columns from INFORMATION_SCHEMA.COLUMNS, and adds missing methods. Existing methods are not overwritten.

Transactions

Use transactionStart() and transactionCommit() around multi-step changes:

Call rollback() if a transaction should be reverted.

Error Handling

Model::persist() maps common MySQL integrity errors to package exceptions:

All extend Frootbox\Db\Exception\DatabaseException.

License

This package is licensed under the GPL-3.0-or-later license.


All versions of db with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-pdo Version *
frootbox/exceptions Version ^0.1
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 frootbox/db contains the following files

Loading the files please wait ...