websk/php-db

There is no license information available for the latest version (2.0.0) of this package.

DB Service

2.0.0 2024-08-22 07:54 UTC

This package is auto-updated.

Last update: 2025-02-22 09:58:49 UTC


README

Configuration example

$config = [
    'settings' => [
        'db' => [
            'db_skif' => [
                'host' => 'mysql',
                'db_name' => 'skif',
                'user' => 'root',
                'password' => 'root',
            ]
        ]
    ]
];

Registering a service

$container->set('DB_SERVICE_CONTAINER_ID', function (ContainerInterface $container) {
    $settings = $container->get('settings');
    $db_config = $settings['db']['db_skif'];

    return new DBServiceFactory::factoryMySQL($db_config);
});

Use DBWrapper

Set DBWrapper db service in App

DBWrapper::setDbService($container->get('DB_SERVICE_CONTAINER_ID'));