开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜