Download the PHP package toropyga/db without Composer

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

DB

A lightweight PHP 8.1+ library that provides a unified interface for working with MySQL, PostgreSQL, Oracle, and PDO-supported databases. It includes prepared statements, SQL query helpers, metadata access, configurable error handling, logging, and backward compatibility with the legacy PDO_LIB adapter name.

License Version PHP

The preferred PDO adapter name is PDOLIB. A temporary PDO_LIB extends PDOLIB compatibility wrapper is still available for applications migrating from v2.x; new code should use Toropyga\DB\PDOLIB.

Content

General description

The library includes 4 main adapters and the DBAPI factory:

  1. MySQL - class for working with MySQL database.
  2. PostgreSQL - class for working with PostgreSQL database.
  3. Oracle - class for working with Oracle database.
  4. PDOLIB - a generic class that uses the PDO library, including PostgreSQL and SQLite.

DBAPI provides a single entry point for selecting an adapter by connection type and passing connection parameters as an array.

Functions are standardized in all libraries.

See CHANGELOG.md for release history and unreleased changes.

Changelog

Release history is maintained in CHANGELOG.md.

All adapters implement DatabaseAdapterInterface. Use getQuery() (or the adapter's prepared execution methods) for user-controlled values. The getInsertSQL(), getUpdateSQL(), and getDeleteSQL() methods only generate SQL text for inspection or integration with external tooling.

Errors are written to the adapter log. When the *_ERROR_EXIT option or setErrorExit(true) is enabled, a DatabaseException is thrown instead of terminating the application or rendering HTML.

Installation

The recommended way to install the DB library is using Composer:

Requirements

Only install and enable the extensions required by the adapter you use.

Backwards-incompatible API changes

This release tightens parameter types on several public methods. Passing an invalid value that previously returned false can now raise TypeError. The affected methods are:

Validate arguments before calling these methods and update integrations that relied on the old permissive behavior. This is an intentional backwards-incompatible API change; see CHANGELOG.md.

Support matrix

The PHP column describes the declared language compatibility from composer.json. Database-driver combinations require both ext-pdo and the matching PDO driver.

Adapter / driver PHP 8.1+ Required extensions Status
MySQL Yes ext-mysqli Declared support
PostgreSQL Yes ext-pgsql Declared support
Oracle Yes ext-oci8 Declared support
PDOLIB + mysql Yes ext-pdo, ext-pdo_mysql Declared support
PDOLIB + pgsql Yes ext-pdo, ext-pdo_pgsql Declared support
PDOLIB + oci Yes ext-pdo, ext-pdo_oci Declared support
PDOLIB + odbc Yes ext-pdo, ext-pdo_odbc Declared support
PDOLIB + sqlite Yes ext-pdo, ext-pdo_sqlite Declared support
PDOLIB + sqlsrv Yes ext-pdo, ext-pdo_sqlsrv Declared support
PDOLIB + dblib Yes ext-pdo, ext-pdo_dblib Declared support
PDOLIB + firebird Yes ext-pdo, ext-pdo_firebird Declared support
JSON array values Yes ext-json Required only when arrays are encoded

The matrix is a compatibility declaration, not a replacement for integration tests against each database server and driver version.

Configuration

Pre-setting of default parameters can be done directly in the class itself or using a named constant. Named constants are declared when the class is called, for example in a configuration file, and define default parameters.

Configuration constants PostgreSQL

Configuration constants MySQL

Configuration constants ORACLE

Configuration constants PDOLIB

Work description

Including a class file


Classes initialisation

The adapters can also be initialized with explicit constructor parameters:

Unified DBAPI entry point

DBAPI::connect() returns the concrete adapter selected by the connection type. The instance form also proxies adapter methods:

Supported native types include mysql, postgresql, and oracle. Supported PDO types include pdo_mysql, pdo_pgsql, pdo_oci, pdo_odbc, pdo_sqlite, pdo_sqlsrv, pdo_dblib, and pdo_firebird.


Getting a list of tables


Creating INSERT, DELETE and UPDATE queries from arrays

Sending a request

For parameterized SELECT queries, use getQuery() instead of concatenating values into SQL. The adapter uses real bound parameters:

getInsertSQL(), getUpdateSQL(), getDeleteSQL(), and getQuerySQL() build SQL text for inspection or logging. For user-controlled values, prefer the execution methods with bound parameters (getQuery(), prepare()/execute()) where the adapter supports them. Where:

$one can take values:

6/'dub_all' and 7/'explain' are supported by all three classes, with one exception:

You can also execute a query without processing the result (UPDATE, INSERT, etc.):

For Oracle, ordinary SELECT statements are executed through the parsed statement. Enable setCursor(true) only when the PL/SQL request uses an OUT cursor such as :res; regular SELECT requests do not require cursor mode.

getListFields() returns a list of column names. Metadata lookup failures return false and do not reuse a stale prepared statement or connection.

Use NULL or NOT NULL as a condition value to generate IS NULL or IS NOT NULL, for example: ['deleted_at' => 'NULL'].


All versions of db with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.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 toropyga/db contains the following files

Loading the files please wait ...