PHPackages                             phico/database - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. phico/database

ActiveLibrary

phico/database
==============

Lightweight database support for Phico

07HTML

Since Nov 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/phico-php/database)[ Packagist](https://packagist.org/packages/phico/database)[ RSS](/packages/phico-database/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Database
========

[](#database)

The Database package provides *multiple connections* to SQL databases, *fluent schema generation* and support for *migrations*.

Currently MySQL (and MariaDB), PostgreSQL and SQlite databases are supported through the PDO drivers.

Features
--------

[](#features)

- **Supports multiple connections** Easily switch connections with the `use()` method
- **Lazy load connections** Connections are not made until they are used
- **Supports prepared statements** Prevent against SQL injection attacks with PDO prepared statements
- **Transactions and Savepoints** Ensure consistency with transactions and savepoints to rollback to
- **Schema generation** Create and update database tables via a fluent API
- **Migrations support** Version your table changes in migrations via the CLI
- **Seeding support** Populate your tables with seed data via the CLI
- **Consistent error handling** All exceptions are returned as DatabaseException instances

Requirements
------------

[](#requirements)

The following composer packages are required:

- **phico/cli** For command line support
- **phico/config** For config file support
- **phico/filesystem** For migrations and seed files support

Contents
--------

[](#contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [Database](#database)
    - [Connections](#connections)
    - [Queries](#queries)
    - [Transactions](#transactions)
    - [Savepoints](#savepoints)
    - [Exceptions](#exceptions)
- [Migrations](#migrations)
- [Seeds](#seeds)
- [Contributing](#contributing)
- [License](#license)

Installation
------------

[](#installation)

Using composer

```
composer require phico/database
```

Configuration
-------------

[](#configuration)

The database class requires the following config structure.

A single `use` string to identify the default connection followed by a `connections` array detailing your application database connections and settings for `migrations` and `seeds`.

```
