简体   繁体   English

在wamp服务器中使用adodb连接到DB

[英]connect to DB with adodb in wamp server

I try to connect to my database in WAMP server with ADODB plugin but I cant, here my code: 我尝试使用ADODB插件连接到WAMP服务器中的数据库,但是我不能,这是我的代码:

$this->xml = NewADOConnection('mysql://root:@localhost/xml_tarpine');
$this->xml->SetFetchMode(ADODB_FETCH_ASSOC); 
$this->xml->Execute('SET NAMES "utf8"');

Where is the problem? 问题出在哪儿?

Try this simple class 试试这个简单的课程

class AdoConnection {

    public $dbh;

    public function __construct() {
        include_once '../adoconnection/adodb5/adodb.inc.php'; // include your adodb.inc.php file

        $server = "127.0.0.1";
        $user   = "USER/SCHEMA/Database";
        $pwd    = "password";
        $db     = "SID OR Service_Name";

        $this->dbh = NewADOConnection('oci8');
        $this->dbh->Connect(FALSE, $user, $pwd, '(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ' . $server. ')(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = ' . $db . ') (SID = ' . $db . ')))');
    }

    public function select($sql) {
        $result = $this->dbh->Execute($sql);
        $result = $result->GetRows();
        return $result;
    }

    public function insert($sql) {
        $result = $this->dbh->Execute($sql);
        return $result;
    }
}

$dbh = new AdoConnection();

$dbh->select($sql);
$dbh->insert($sql);

Just keep your error_reporting and display_errors On to see the errors. 只需保持您的error_reporting和display_errors开启即可查看错误。

ini_set('display_errors',1);
error_reporting(E_ALL);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM