在Bluemix,我創建了一個PHP應用程序,並綁定新的SQL服務實例。然而,當我嘗試連接到SQL服務實例,我收到以下錯誤:在Bluemix,當我得到這個errorCall未定義功能mssql_connect()
Call to undefined function mssql_connect().
有人可以幫我解釋一下爲什麼? 謝謝
在Bluemix,我創建了一個PHP應用程序,並綁定新的SQL服務實例。然而,當我嘗試連接到SQL服務實例,我收到以下錯誤:在Bluemix,當我得到這個errorCall未定義功能mssql_connect()
Call to undefined function mssql_connect().
有人可以幫我解釋一下爲什麼? 謝謝
根據您的意見,您正在使用基於DB2的Bluemix SQLDB服務。
有一個在下面dashDB鏈接一個示例代碼,但它是SQLDB類似的還有:
但基本上,這裏是你必須做的:
//parse vcap
if(getenv("VCAP_SERVICES")) {
$json = getenv("VCAP_SERVICES");
}
# No DB credentials
else {
throw new Exception("No Database Information Available.", 1);
}
# Decode JSON and gather DB Info
$services_json = json_decode($json,true);
$bludb_config = $services_json["sqldb"][0]["credentials"];
// create DB connect string
$conn_string = "DRIVER={IBM DB2 ODBC DRIVER};DATABASE=".
$bludb_config["db"].
";HOSTNAME=".
$bludb_config["host"].
";PORT=".
$bludb_config["port"].
";PROTOCOL=TCPIP;UID=".
$bludb_config["username"].
";PWD=".
$bludb_config["password"].
";";
// connect to database
$conn = db2_connect($conn_string, '', '');
最後,你必須使用DB2 Heroku的PHP buildpack部署應用程序(默認PHP buildpack沒有DB2客戶機):
$ cf push app-name -b https://github.com/ibmdb/db2heroku-buildpack-php
請張貼相關的代碼。如果沒有 –
<?php $ serverName =「75.126.155.153」; $ username =「user15298」; $ password =「GnhtBEErQ4fg」; $ database =「SQLDB_ZQ」; #DO未在此行編輯 $ connection = mssql_connect('75 .126.155.153',$ username,$ password); print(「hello world」); ?> – zhuli
<?php $ serverName =「75.126.155.153」; $ username =「user15298」; $ password =「GnhtBEErQ4fg」; $ database =「SQLDB_ZQ」; $ connection = mssql_connect('75 .126.155.153',$ username,$ password); print(「hello world」); ?> – zhuli