我可以使用此连接字符串连接到iseries DB2数据库;
$server="systemdnsfile1"; #the name of the iSeries
$user="user"; #a valid username that will connect to the DB
$pass="pass"; #a password for the username
$conn=odbc_connect($server,$user,$pass); #you may have to remove quotes
我想与PDO连接但我找不到正确的代码 这是mysql的工作代码,如何将其转换为系统dns类型?
@n$db = @new PDO(
"mysql:host={$sql_details['host']};dbname={$sql_details['db']}",
$sql_details['user'],
$sql_details['pass'],
array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )
);
答案 0 :(得分:0)
你试过了吗?
$user= ...;
$password=...;
try {
$connection = new PDO("ibm:YOUR_DSN_NAME", $user, $password, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
);
}
catch (Exception $e) {
echo($e->getMessage());
}