You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need option to use existing "db" connection. I'm using sqlite in-memory option in my unit tests, in-memory option is not shareable between apps. That's why i have to share my apps db connection with yarak. Here is my workaround in ConnectionResolver class
<?php
namespace Yarak\DB;
use Phalcon\Exception;
use Phalcon\Di;
class ConnectionResolver
{
/**
* Get connection to database.
*
* @param array $dbConfig
*
* @throws Exception
*
* @return \Phalcon\Db\Adapter\Pdo
*/
public function getConnection(array $dbConfig)
{
$di = DI::getDefault();
if($di->has('db'))
return $di->getShared('db');
$dbClass = sprintf('\Phalcon\Db\Adapter\Pdo\%s', $dbConfig['adapter']);
if (!class_exists($dbClass)) {
throw new Exception(
sprintf('PDO adapter "%s" not found.', $dbClass)
);
}
unset($dbConfig['adapter']);
return new $dbClass($dbConfig);
}
}
The text was updated successfully, but these errors were encountered:
I need option to use existing "db" connection. I'm using sqlite in-memory option in my unit tests, in-memory option is not shareable between apps. That's why i have to share my apps db connection with yarak. Here is my workaround in ConnectionResolver class
The text was updated successfully, but these errors were encountered: