Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to doctrine dbal #164

Closed
devudopw opened this issue Mar 14, 2021 · 2 comments
Closed

add support to doctrine dbal #164

devudopw opened this issue Mar 14, 2021 · 2 comments

Comments

@devudopw
Copy link

Hello

I want to use low level db layer such as doctrine/dbal, how to config in webman?

@walkor
Copy link
Owner

walkor commented Mar 15, 2021

  1. Create config/dbal.php
<?php
return array(
    'dbname' => 'mydb',
    'user' => 'user',
    'password' => 'secret',
    'host' => 'localhost',
    'driver' => 'pdo_mysql',
);
  1. Create app/support/Dbal.php
<?php
namespace app\support\Dbal;
class Dbal {
    protected $instance = null;
    public static function instance() {
        if (!self::$instance) {
            self::$instance = \Doctrine\DBAL\DriverManager::getConnection(config('dbal'));
        }
        return self::$instance;
    } 
}
  1. Usage
use app\support\Dbal;

Dbal::instance()->query('your sql');

@devudopw
Copy link
Author

good, please consider add this to the document

@devudopw devudopw closed this as completed Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants