GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Cycle ORM
  • GitHub
  • Documentation
  • Wippy.ai
  • Spiral Framework
  • RoadRunner

This view

  • Original page
  • New address

GeezerVison is showing cycle-orm.dev — Cycle ORM: Databases - Database Isolation

  • Table of Contents
  • About Cycle ORM
  • Installation
  • Integrations
  • Upgrade Guide
  • Contributing
  • Issue with Test Case
  • Versioning
  • LICENSE
  • Create, Update, Delete
  • Direct Database Queries
  • Select
  • Custom Repositories
  • Simple Relation
  • Without Annotations
  • Prerequisites
  • Entities
  • Embeddings
  • Relations
  • Has One
  • Has Many
  • Belongs To
  • Refers To
  • Many To Many
  • Embedding Entities
  • Morphed Relations
  • Collections
  • Bulk Loading
  • Basics
  • Extended Builder Usage
  • Querying Relations
  • Complex Queries
  • Security
  • Install
  • UUID
  • Auto Timestamps
  • Soft delete
  • Optimistic lock
  • Hooks
  • Event listener
  • Extensions
  • Events
  • Configuring Schema Builder
  • Manually defined Mapping Schema
  • Dynamic Mapping Schema
  • Column wrappers and typecast
  • DateTime properties
  • Composite PK
  • Installation and Configuration
  • Connect to Database
  • Access Database
  • Profiling and Logging
  • Database Isolation
  • Query Builders
  • Transactions
  • Schema Introspection
  • Schema Declaration
  • Migrations
  • Synchronizing Database Schema (Migrations)
  • Errata
  • About
  • Proxy Mapper
  • Classless Mapper
  • Std Mapper
  • Promise Mapper
  • Mapper extending
  • References
  • Typecasting
  • Customize Schema Defaults
  • Scopes
  • Single Table Inheritance
  • Joined Table Inheritance
  • Caching
  • Pagination
  • Chained Repository
  • Persist Repositories
  • Active Record
  • Schema
  • Entity, Heap, Node, State
  • Entity manager (Unit of Work)
  • Entity Iterator
  • Node Parser
  • Long-Running Applications
  • Commands
  • Testing
  • Limitations
  • Introduction
  • Installation
  • Active Entities
  • Active Query
  • Active Repository
Revision: Wed, 04 Nov 2026 16:26:00 GMT

Database - Logical Isolation

  • Configuration
  • Runtime configuration

The cycle/database component provides the ability to use a single connection for multiple, logically isolated databases. The isolation performed using table prefix, which automatically added to every SQL identifier.

#Configuration

To enable database prefix use option prefix of your database:

php
<?php

declare(strict_types=1);

use Cycle\Database\DatabaseManager;
use Cycle\Database\Config;

$dbal = new DatabaseManager(new Config\DatabaseConfig([
    'databases'   => [
        'default' => ['connection' => 'sqlite', 'prefix' => 'my_prefix_'],
    ],
    'connections' => [
        'sqlite' => new Config\SQLiteDriverConfig(
            connection: new Config\SQLite\MemoryConnectionConfig(),
            queryCache: true,
        ),
    ],
]));

#Runtime configuration

You can isolate database in runtime using withPrefix method:

php
$db = $dbal->database();
print_r($db->withPrefix('my_db_prefix')->getTables());

The schema introspection and declaration will work with the isolated database by automatically adding a prefix to all declared tables.

← PREVIOUS Profiling and Logging
NEXT → Query Builders
2.x
2.x
1.x
Edit this page
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.