-
Notifications
You must be signed in to change notification settings - Fork 92
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
start to providing reconnection ability #124
base: master
Are you sure you want to change the base?
Conversation
Do you think we could come up with a separate interface for adapters that might not be connected? I don't want to have to bump a major version for this? That way the check could be... if ($adaptor instanceof SomethingInterface && !$adaptor->isConnected()) {
// ...
} |
A separate interface would end up being more work I would think, since your adapters implement the interface, but the adapters themselves would still be the same. If you had a second interface, you'd have to have two copies of every adapter, one for each interface. With the implementation I started, the interface just adds one method Since the actual code for reconnecting is built into the This also doesn't break backwards compatability (once |
Classes can implement more than one interface, so that wouldn't be a problem.
It does break BC, because other people who have created custom adapters etc would have their migration process broken. |
the multiple inheritance I didn't see as an issue so much as how it would be implemented, <?php
use Phpmig\Adapter;
use Zend\Mvc\Application;
$container = new ArrayObject();
$container['zend'] = Zend\Mvc\Application::init(require 'config/application.config.php');
$config = $container['zend']->getServiceManager()->get('config');
$container['phpmig.adapter'] = function() use ($config) {
$pdo = new PDO($config['database']['dsn'], $config['database']['username'], $config['database']['password']);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return new Adapter\PDO\Sql($pdo, 'migrations');
};
$container['phpmig.migrations_path'] = __DIR__ . DIRECTORY_SEPARATOR . 'migrations';
return $container; You're right in that I could've written a separate custom adapter instead of modifying The other kink is that because by default I agree that changing |
So this is a start to the issue raised in #123 about MySQL going away from phpmig itself. I modified it so that you can provide a function to
['phpmig.adapter']
instead of the actual adapter, which will return the Adapter itself.It's expandable so that each adapter can have it's own test to see if it's still connected or not (only wrote one for MySQL for now).