dlepera88-php/doctrine-prefixes

Set database and/or table prefix.

0.0.3 2019-12-17 19:02 UTC

This package is auto-updated.

Last update: 2024-04-18 04:30:03 UTC


README

In some cases, we need to install a web application on shared hosts. On shared hosts, database names usually have a prefix, like cPanel, for example. Eg: etc_dbname.

So, I make this package. I hope this help u.

Basic Usage

<?php 
// $connectionOptions and $config set earlier
/** @var $connectionOptions */
/** @var array $config */

$evm = new \Doctrine\Common\EventManager;

// Database Prefix
$database_prefix = new \DoctrinePrefixes\DatabasePrefix('db_');
$evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $database_prefix);

// Table Prefix
$table_prefix = new \DoctrinePrefixes\TablePrefix('prefix_');
$evm->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $table_prefix);

$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm);