PHP - access 2 different databases from one class
Please help me set the required database! Thank you!
<?php
require_once("adodb5/adodb.inc.php");
$web = NewAdoConnection("mysqlt");
$server = "*";
$user = "*";
$password = "*";
$database = "web";
$web->Connect($server, $user, $password, $database);
$modul = NewAdoConnection("mysqlt");
$开发者_如何学Cserver = "*";
$user = "*";
$password = "*";
$database = "modul";
$modul->Connect($server, $user, $password, $database);
$rs = $web->execute("SELECT DATABASE()");
echo $rs->fields[0]; // EXPECTED: "web", ACTUAL: "modul"
?>
Not sure, but I think you're looking for the __construct
function.
EDIT:
Scratch that, I understand your question better now. It looks like you need to use ADOdb_Active_Record. Specifically, look at part 17. This page may also be helpful.
精彩评论