Download the PHP package timmit/db-mysql without Composer

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

timmit/db-mysql

CI

A simple database layer in PHP for MySQL and MariaDB, built on mysqli.

It gives you static helpers for running queries, a small builder for WHERE conditions, read/write/fallback connections, transactions, schema reconciliation (dbDelta) and CSV export, with support for MariaDB Galera clusters.

Requirements

Installation

Quick start

Always escape values that end up in a query: use DB::clean4DB() for strings and cast numbers. Note that clean4DB() also escapes % and _ (meant for LIKE conditions); DB::cleanFromDB() reverses the escaping when reading values back.

The connection can also be set up in two steps with DB::loadConfig() and DB::connect(). DB::disconnect(), DB::reconnect() and DB::ping() manage the connection afterwards.

Read, write and fallback nodes

new DB($primary, $write, $fallback) takes three connection settings arrays:

Argument Purpose
$primary The main connection, used for reads (and writes if no write node is set)
$write Optional separate node for writes
$fallback Optional node to connect to when connecting to the primary fails

Most query methods take a $writeNode argument. selectQuery() reads from the primary node by default, while insertQuery(), updateQuery(), deleteQuery() and executeQuery() use the write node.

Building WHERE conditions

Where\Collection and Where\Param build escaped conditions, so you do not have to concatenate them by hand:

Collections can be nested with addCollection('OR'). An empty collection renders as an empty string by default; use setIfEmptyThenShowAll(true) or setIfEmptyThenShowNothing(true) to make it render as (1=1) or (1=0).

Available conditions on Param: is, isNot, greater, greaterOrEqual, lower, lowerOrEqual, inArray, notInArray, inQuery, notInQuery, regexMatch and betweenRange.

Transactions

commitTransaction() and rollbackTransaction() are available as well.

Other features

Errors are thrown as TiMMiT\MySQL\DBException.

Development

Task Command
Static analysis (level 9) vendor/bin/phpstan analyse
Unit tests vendor/bin/phpunit -c ./
Code style and docblocks phpcs --standard=.phpcs-docblock.xml --extensions=php ./src

The integration tests need a database and are skipped when DB_TEST_HOST is not set. To run them, set DB_TEST_HOST, DB_TEST_USER, DB_TEST_PASSWORD, DB_TEST_DATABASE and DB_TEST_PORT. The CI uses a MariaDB 11.4 service with user, password and database db_test.

Pull requests run the same checks in GitHub Actions (.github/workflows/ci.yml): YAML lint, code style, PHPStan, PHPUnit, secret detection and a dependency audit. Every run has an overview with the results of all checks.

License

MIT. Created by Tim Schoondergang.


All versions of db-mysql with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
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 timmit/db-mysql contains the following files

Loading the files please wait ...