Two databases with PHP PDO?

Asked

Viewed 156 times

2

I’m trying to make a connection to two databases with PDO ta thus.

Config.php

<?php
  class config{
  var $host = 'meuhost';
  var $usuario = 'meuusuario';
  var $senha = 'minhasenha';
  var $db = 'banco1','banco2';

  }
?>

And where I’m doing the class is like this.

<?php

   include_once 'config.php';

    class conecta extends config
    {
        var $pdo;

        function __construct()
        {
             $this->pdo = new PDO('mysql:host='.
                $this->host.';dbname='.
                $this->db, $this->usuario, $this->senha); 
        }
     }
?>

I just don’t know how to do the job construct connect with both banks only with the banco1.

  • It won’t work this way

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.