简体   繁体   中英

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:

$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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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