@RainbowPower

Не выходит использовать несколько баз данных RedBeanPHP?

Добрый вечер.
Есть у меня две бд, получается использовать их по одиночке, но не выходит вместе.
Вот запрос:
Db::getConnection(1);

$new = R::dispense('test');

$new->content = R::isoDateTime();

$result = R::store($new);

echo $result . '<br>';



Db::getConnection(2);

$new = R::dispense('test');

$new->content = R::isoDateTime();

$result = R::store($new);

echo $result . '<br>';

В первую бд пишет, а со второй ошибка, если поменять базы местами, все наоборот.
Коннект к бд:
public static function getConnection($type)
    {
        if($type == '1'){
            Db::getConnectionDataBaseOne();
        }else if($type == '2'){
            Db::getConnectionDataBaseTwo();
        }
    }
 public static function getConnectionDataBaseOne()
    {
        $params = require_once(ROOT . '/config/db_params.php');

        require_once(ROOT . '/include/redBean/rb-postgres.php');


        $dsn_office = "pgsql:host={$params['host_office']};dbname={$params['dbname_office']}";
        R::addDatabase('office', $dsn_office, $params['user_office'], $params['password_office'], false);

        R::selectDatabase('office');

        $out = R::testConnection();

        return $out;
    }

    public static function getConnectionDataBaseTwo()
    {
        $params = require_once(ROOT . '/config/db_params.php');

        require_once(ROOT . '/include/redBean/rb-postgres.php');


        $dsn_record = "pgsql:host={$params['host_record']};dbname={$params['dbname_record']}";
        R::addDatabase('record', $dsn_record, $params['user_record'], $params['password_record'], false);

        R::selectDatabase('record');

        $out = R::testConnection();

        return $out;
    }


ошибка:
Fatal error: Uncaught PDOException: Could not connect to database (?). in /var/www/html/include/redBean/rb-postgres.php:1011 Stack trace: #0 /var/www/html/include/redBean/rb-postgres.php(735): RedBeanPHP\Driver\RPDO->connect() #1 /var/www/html/include/redBean/rb-postgres.php(1035): RedBeanPHP\Driver\RPDO->runQuery('SELECT table_na...', Array) #2 /var/www/html/include/redBean/rb-postgres.php(1056): RedBeanPHP\Driver\RPDO->GetAll('SELECT table_na...', Array) #3 /var/www/html/include/redBean/rb-postgres.php(4183): RedBeanPHP\Driver\RPDO->GetCol('SELECT table_na...', Array) #4 /var/www/html/include/redBean/rb-postgres.php(6676): RedBeanPHP\Adapter\DBAdapter->getCol('SELECT table_na...') #5 /var/www/html/include/redBean/rb-postgres.php(5857): RedBeanPHP\QueryWriter\PostgreSQL->getTables() #6 /var/www/html/include/redBean/rb-postgres.php(8031): RedBeanPHP\QueryWriter\AQueryWriter->tableExists('test') #7 /var/www/html/include/redBean/rb-postgres.php(8133): RedBeanPHP\Repository->tableExists('test') #8 /var/www/html/include/redBe in /var/www/html/include/redBean/rb-postgres.php on line 1011

Сам, увы, не нашел ответ.
Спасибо!
  • Вопрос задан
  • 268 просмотров
Пригласить эксперта
Ответы на вопрос 1
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
18 апр. 2024, в 21:56
2000 руб./за проект
18 апр. 2024, в 21:00
150 руб./за проект