Download the PHP package brick/db without Composer

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

Brick\Db

A collection of helper tools for interacting with databases.

Build Status Coverage Status Latest Stable Version Total Downloads License

Installation

This library is installable via Composer:

Requirements

This library requires PHP 7.4 or later.

For PHP 7.1, 7.2 & 7.3 compatibility, you can use version 0.1. Note that these PHP versions are EOL and not supported anymore. If you're still using one of these PHP versions, you should consider upgrading as soon as possible.

Package overview

This package contains two helpers: BulkInserter and BulkDeleter. These classes, built on top of PDO, allow you to speed up database rows insertion & deletion by performing multiple operations per query, with a clean OO API.

BulkInserter

This class takes advantage of the extended insert / multirow syntax available in MySQL, PostgreSQL and SQLite.

It basically replaces the need to send a batch of queries:

with a single, faster query:

To use it, create a BulkInserter instance with:

Example

The queue() method does not do anything until either flush() is called, or the number of inserts per query is reached.

Note: queue() returns false when the insert has been queued only, and true when the number of inserts per query has been reached and the batch has therefore been flushed to the database. This can be useful to monitor the progress of the batch.

Do not forget to call flush() after all your inserts have been queued. Failure to do so would result in records not being inserted.

BulkDeleter

This class allows you to delete multiple records at a time.

It basically replaces the need for these queries:

with a single, faster query:

The constructor parameters are the same as BulkInserter.

For obvious performance reasons, the list of columns used to identify a record should match the primary key or a unique index of the table.

Example

With a single column primary key / unique index:

With a composite key:

Do not forget to call flush() after all your deletes have been queued. Failure to do so would result in records not being deleted.

Performance tips

To get the maximum performance out of this library, you should:

These two tips combined can get you up to 50% more throughput in terms of inserts per second. Sample code:

The library could do this automatically, but doesn't for the following reasons:

Respecting the limits

Be careful when raising the number of operations per query, as you might hit these limits:

You can tweak these settings if you have access to your server's configuration, however it's important to benchmark with different batch sizes, to determine the optimal size and see if increasing the server limits is worth the effort. In most cases, 100 inserts per query should give you at least 80% of the maximum throughput:

Extended inserts benchmark

See this article for a more in-depth analysis.

MySQL also has a limit of 65535 placeholders per statement, effectively limiting the number of operations per query to floor(65535 / number of columns). This does not apply if PDO emulates prepared statements.


All versions of db with dependencies

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

Loading the files please wait ....