Download the PHP package roolith/database without Composer

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

roolith-database

PHP database driver

Supports MySQL, PostgreSQL (pgsql), and SQLite via PDO. Any other PDO driver only works when you pass a raw DSN string directly.

Supported databases

Driver type value Connect example
MySQL mysql (default) ['type' => 'mysql', 'host' => 'localhost', 'port' => 3306, 'name' => 'dbname', 'user' => 'username', 'pass' => 'password']
PostgreSQL pgsql ['type' => 'pgsql', 'host' => 'localhost', 'port' => 5432, 'name' => 'dbname', 'user' => 'username', 'pass' => 'password']
SQLite sqlite ['type' => 'sqlite', 'name' => 'path/to/database.sqlite']

Raw PDO DSN strings are also passed through, for example $db->connect('sqlite::memory:');.

Install

Usage

Select

Note: condition is a trusted SQL literal escape hatch. Never interpolate input into it, pass variables via bindings.

Insert

Insert data when supplied email [email protected] not exists in table users:

Response:
Update

Note: array where only. Raw string where is unsupported to prevent injection.

update username if nobody else is using same username

Response:
Delete
Response:
Connect

or

Disconnect
Others

Search users table with LIKE operator

Get user by id 1

Pluck name and email from users table

Get total record of users table

Pagination

or

CLI / test safe pagination without $_GET / $_SERVER:

Transactions

transaction() commits on success, rolls back and rethrows on failure. Nesting is unsupported. Use inTransaction() when a helper may run inside or outside a transaction.

Return a value from the callback.

Throwing inside the callback triggers a rollback.

Manual commit and rollback.

Reusable helper that is safe in both contexts.

These all throw.

Bindings

Values are always bound, never interpolated:

Debug mode

Note: Once debug-mode is active queries are collected via getDebugLog() with no echo output!

Upgrade to 2.0

Breaking:

  1. update() requires array where (string where removed).
  2. delete() return shape drops debug key.
  3. pageNumbers() ellipsis is '...' (was '.').
  4. new Paginate no longer reads $_GET/$_SERVER (use Paginate::fromGlobals() for legacy web or Paginate::fromRequest()).
  5. New required interface methods (buildConditionFragment, transactions, debug log, orderBy/limit/offset).
  6. Requires php >= 8.0.

Notes:

  1. getDetails() returns from=0,to=0 past the last page.
  2. fromRequest() preserves query params minus pageParam.
  3. Transactions reject nesting and stray commit/rollBack (check inTransaction()).

Development

Run tests:

Run coverage (needs phpdbg, no PCOV/Xdebug required):


All versions of database with dependencies

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

Loading the files please wait ...