0

我尝试使用 ADODB 插件连接到 WAMP 服务器中的数据库,但我不能,这里是我的代码:

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

问题出在哪里?

4

1 回答 1

0

试试这个简单的类

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);

只需保持您的 error_reporting 和 display_errors On 即可查看错误。

ini_set('display_errors',1);
error_reporting(E_ALL);
于 2016-04-14T14:33:19.153 回答